[ { "hash": "5000b0e62f4e9f7d6b2cf01eab6cb66c0a70477c", "msg": "Exit gracefully from interpreter shutdown.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-02T19:38:22+00:00", "author_timezone": 0, "committer_date": "2004-10-02T19:38:22+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "45b7bb2f7ae441343634ec61d6392fdae236a3d9" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 4, "lines": 5, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/pexec.py", "new_path": "scipy_base/pexec.py", "filename": "pexec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -55,6 +55,9 @@ def run(self):\n try:\n exec (code, frame.f_globals,frame.f_locals)\n except Exception:\n- traceback.print_exc()\n+ try:\n+ traceback.print_exc()\n+ except AttributeError:\n+ pass\n if wait_for_code is not None:\n wait_for_code.set()\n", "added_lines": 4, "deleted_lines": 1, "source_code": "#\n# Title: Provides ParallelExec to execute commands in\n# other (background or parallel) threads.\n# Author: Pearu Peteson \n# Created: October, 2003\n#\n\n__all__ = ['ParallelExec']\n\nimport sys\nimport threading\nimport Queue\nimport traceback\nimport types\nimport inspect\nimport time\nimport atexit\n\nclass ParallelExec(threading.Thread):\n \"\"\" Create a thread of parallel execution.\n \"\"\"\n def __init__(self):\n threading.Thread.__init__(self)\n self.__queue = Queue.Queue(0)\n self.__frame = sys._getframe(1)\n self.setDaemon(1)\n self.start()\n\n def __call__(self,code,frame=None,wait=0):\n \"\"\" Execute code in parallel thread inside given frame (default\n frame is where this instance was created).\n If wait is True then __call__ returns after code is executed,\n otherwise code execution happens in background.\n \"\"\"\n if wait:\n wait_for_code = threading.Event()\n else:\n wait_for_code = None\n self.__queue.put((code,frame,wait_for_code))\n if wait:\n wait_for_code.wait()\n\n def shutdown(self):\n \"\"\" Shutdown parallel thread.\"\"\"\n self.__queue.put((None,None,None))\n\n def run(self):\n \"\"\" Called by threading.Thread.\"\"\"\n while 1:\n code, frame, wait_for_code = self.__queue.get()\n if code is None:\n break\n if frame is None:\n frame = self.__frame\n try:\n exec (code, frame.f_globals,frame.f_locals)\n except Exception:\n try:\n traceback.print_exc()\n except AttributeError:\n pass\n if wait_for_code is not None:\n wait_for_code.set()\n", "source_code_before": "#\n# Title: Provides ParallelExec to execute commands in\n# other (background or parallel) threads.\n# Author: Pearu Peteson \n# Created: October, 2003\n#\n\n__all__ = ['ParallelExec']\n\nimport sys\nimport threading\nimport Queue\nimport traceback\nimport types\nimport inspect\nimport time\nimport atexit\n\nclass ParallelExec(threading.Thread):\n \"\"\" Create a thread of parallel execution.\n \"\"\"\n def __init__(self):\n threading.Thread.__init__(self)\n self.__queue = Queue.Queue(0)\n self.__frame = sys._getframe(1)\n self.setDaemon(1)\n self.start()\n\n def __call__(self,code,frame=None,wait=0):\n \"\"\" Execute code in parallel thread inside given frame (default\n frame is where this instance was created).\n If wait is True then __call__ returns after code is executed,\n otherwise code execution happens in background.\n \"\"\"\n if wait:\n wait_for_code = threading.Event()\n else:\n wait_for_code = None\n self.__queue.put((code,frame,wait_for_code))\n if wait:\n wait_for_code.wait()\n\n def shutdown(self):\n \"\"\" Shutdown parallel thread.\"\"\"\n self.__queue.put((None,None,None))\n\n def run(self):\n \"\"\" Called by threading.Thread.\"\"\"\n while 1:\n code, frame, wait_for_code = self.__queue.get()\n if code is None:\n break\n if frame is None:\n frame = self.__frame\n try:\n exec (code, frame.f_globals,frame.f_locals)\n except Exception:\n traceback.print_exc()\n if wait_for_code is not None:\n wait_for_code.set()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "pexec.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 22, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , code , frame = None , wait = 0 )", "filename": "pexec.py", "nloc": 8, "complexity": 3, "token_count": 53, "parameters": [ "self", "code", "frame", "wait" ], "start_line": 29, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "shutdown", "long_name": "shutdown( self )", "filename": "pexec.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 43, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "pexec.py", "nloc": 16, "complexity": 7, "token_count": 77, "parameters": [ "self" ], "start_line": 47, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "pexec.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 22, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , code , frame = None , wait = 0 )", "filename": "pexec.py", "nloc": 8, "complexity": 3, "token_count": 53, "parameters": [ "self", "code", "frame", "wait" ], "start_line": 29, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "shutdown", "long_name": "shutdown( self )", "filename": "pexec.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 43, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "pexec.py", "nloc": 13, "complexity": 6, "token_count": 71, "parameters": [ "self" ], "start_line": 47, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "run", "long_name": "run( self )", "filename": "pexec.py", "nloc": 16, "complexity": 7, "token_count": 77, "parameters": [ "self" ], "start_line": 47, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 44, "complexity": 12, "token_count": 228, "diff_parsed": { "added": [ " try:", " traceback.print_exc()", " except AttributeError:", " pass" ], "deleted": [ " traceback.print_exc()" ] } } ] }, { "hash": "90f61af37ffc5219f3721a14c3820d43819cd783", "msg": "Added is_Athlon64 and is_64bit methods.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-04T08:54:50+00:00", "author_timezone": 0, "committer_date": "2004-10-04T08:54:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "5000b0e62f4e9f7d6b2cf01eab6cb66c0a70477c" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 19, "lines": 19, "files": 1, "dmm_unit_size": 0.6875, "dmm_unit_complexity": 0.6875, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/cpuinfo.py", "new_path": "scipy_distutils/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -47,6 +47,9 @@ def __getattr__(self,name):\n def _getNCPUs(self):\n return 1\n \n+ def _is_32bit(self):\n+ return not self.is_64bit()\n+\n class linux_cpuinfo(cpuinfo_base):\n \n info = None\n@@ -64,6 +67,11 @@ def __init__(self):\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n+ import commands\n+ status,output = commands.getstatusoutput('uname -m')\n+ if not status:\n+ if not info: info.append({})\n+ info[-1]['uname_m'] = string.strip(output)\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n@@ -91,6 +99,10 @@ def _is_AthlonMP(self):\n return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n self.info[0]['model name']) is not None\n \n+ def _is_Athlon64(self):\n+ return re.match(r'.*?Athlon\\(tm\\) 64\\b',\n+ self.info[0]['model name']) is not None\n+\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n@@ -203,6 +215,13 @@ def _has_3dnow(self):\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n \n+ def _is_64bit(self):\n+ if self.info[0].get('clflush size','')=='64':\n+ return 1\n+ if self.info[0]['uname_m']=='x86_64':\n+ return 1\n+ return 0\n+\n class irix_cpuinfo(cpuinfo_base):\n \n info = None\n", "added_lines": 19, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpu']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n def _getNCPUs(self):\n return 1\n\n def _is_32bit(self):\n return not self.is_64bit()\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n import commands\n status,output = commands.getstatusoutput('uname -m')\n if not status:\n if not info: info.append({})\n info[-1]['uname_m'] = string.strip(output)\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n def _is_AthlonMP(self):\n return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n self.info[0]['model name']) is not None\n\n def _is_Athlon64(self):\n return re.match(r'.*?Athlon\\(tm\\) 64\\b',\n self.info[0]['model name']) is not None\n\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n\n def _is_Opteron(self):\n return re.match(r'.*?Opteron\\b',\n self.info[0]['model name']) is not None\n\n def _is_Hammer(self):\n return re.match(r'.*?Hammer\\b',\n self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium.*?II\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumPro(self):\n return re.match(r'.*?PentiumPro\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumMMX(self):\n return re.match(r'.*?Pentium.*?MMX\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium.*?III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium.*?(IV|4)\\b',\n self.info[0]['model name']) is not None\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['model name']) is not None\n\n def _is_XEON(self):\n return re.match(r'.*?XEON\\b',\n self.info[0]['model name']) is not None\n\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n\n def _is_64bit(self):\n if self.info[0].get('clflush size','')=='64':\n return 1\n if self.info[0]['uname_m']=='x86_64':\n return 1\n return 0\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def _getNCPUs(self):\n return int(self.info[0].get('NUM_PROCESSORS'))\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n status,output = commands.getstatusoutput('sysctl hw')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['sysctl_hw'] = d\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _getNCPUs(self):\n try: return int(self.info[0]['sysctl_hw']['hw.ncpu'])\n except: return 1\n\n def _is_Power_Macintosh(self):\n return self.info[0]['sysctl_hw']['hw.machine']=='Power Macintosh'\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nclass sunos_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('mach')\n if not status:\n if not info: info.append({})\n info[-1]['mach'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -i')\n if not status:\n if not info: info.append({})\n info[-1]['uname_i'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -X')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['uname_X'] = d\n status,output = commands.getstatusoutput('isainfo -b')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_b'] = string.strip(output)\n status,output = commands.getstatusoutput('isainfo -n')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_n'] = string.strip(output)\n status,output = commands.getstatusoutput('psrinfo -v 0')\n if not status:\n if not info: info.append({})\n for l in string.split(output,'\\n'):\n m = re.match(r'\\s*The (?P

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

[\\w\\d]+) processor operates at',l)\n if m:\n info[-1]['processor'] = m.group('p')\n break\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_32bit(self):\n return self.info[0]['isainfo_b']=='32'\n def _is_64bit(self):\n return self.info[0]['isainfo_b']=='64'\n\n def _is_i386(self):\n return self.info[0]['isainfo_n']=='i386'\n def _is_sparc(self):\n return self.info[0]['isainfo_n']=='sparc'\n def _is_sparcv9(self):\n return self.info[0]['isainfo_n']=='sparcv9'\n\n def _getNCPUs(self):\n try: return int(self.info[0]['uname_X']['NumCPU'])\n except: return 1\n\n def _is_sun4(self):\n return self.info[0]['arch']=='sun4'\n\n def _is_SUNW(self):\n return re.match(r'SUNW',self.info[0]['uname_i']) is not None\n def _is_sparcstation5(self):\n return re.match(r'.*SPARCstation-5',self.info[0]['uname_i']) is not None\n def _is_ultra1(self):\n return re.match(r'.*Ultra-1',self.info[0]['uname_i']) is not None\n def _is_ultra250(self):\n return re.match(r'.*Ultra-250',self.info[0]['uname_i']) is not None\n def _is_ultra2(self):\n return re.match(r'.*Ultra-2',self.info[0]['uname_i']) is not None\n def _is_ultra30(self):\n return re.match(r'.*Ultra-30',self.info[0]['uname_i']) is not None\n def _is_ultra4(self):\n return re.match(r'.*Ultra-4',self.info[0]['uname_i']) is not None\n def _is_ultra5_10(self):\n return re.match(r'.*Ultra-5_10',self.info[0]['uname_i']) is not None\n def _is_ultra5(self):\n return re.match(r'.*Ultra-5',self.info[0]['uname_i']) is not None\n def _is_ultra60(self):\n return re.match(r'.*Ultra-60',self.info[0]['uname_i']) is not None\n def _is_ultra80(self):\n return re.match(r'.*Ultra-80',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice(self):\n return re.match(r'.*Ultra-Enterprise',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice10k(self):\n return re.match(r'.*Ultra-Enterprise-10000',self.info[0]['uname_i']) is not None\n def _is_sunfire(self):\n return re.match(r'.*Sun-Fire',self.info[0]['uname_i']) is not None\n def _is_ultra(self):\n return re.match(r'.*Ultra',self.info[0]['uname_i']) is not None\n\n def _is_cpusparcv7(self):\n return self.info[0]['processor']=='sparcv7'\n def _is_cpusparcv8(self):\n return self.info[0]['processor']=='sparcv8'\n def _is_cpusparcv9(self):\n return self.info[0]['processor']=='sparcv9'\n\nclass win32_cpuinfo(cpuinfo_base):\n\n info = None\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n # XXX: what does the value of\n # HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\n # mean?\n\n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n #XXX: Bad style to use so long `try:...except:...`. Fix it!\n import _winreg\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n prgx = re.compile(r\"family\\s+(?P\\d+)\\s+model\\s+(?P\\d+)\"\\\n \"\\s+stepping\\s+(?P\\d+)\",re.IGNORECASE)\n chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,pkey)\n pnum=0\n while 1:\n try:\n proc=_winreg.EnumKey(chnd,pnum)\n except _winreg.error:\n break\n else:\n pnum+=1\n print proc\n info.append({\"Processor\":proc})\n phnd=_winreg.OpenKey(chnd,proc)\n pidx=0\n while True:\n try:\n name,value,vtpe=_winreg.EnumValue(phnd,pidx)\n except _winreg.error:\n break\n else:\n pidx=pidx+1\n info[-1][name]=value\n if name==\"Identifier\":\n srch=prgx.search(value)\n if srch:\n info[-1][\"Family\"]=int(srch.group(\"FML\"))\n info[-1][\"Model\"]=int(srch.group(\"MDL\"))\n info[-1][\"Stepping\"]=int(srch.group(\"STP\"))\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['VendorIdentifier']=='AuthenticAMD'\n\n def _is_Am486(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_Am5x86(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_AMDK5(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [0,1,2,3]\n\n def _is_AMDK6(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [6,7]\n\n def _is_AMDK6_2(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==8\n\n def _is_AMDK6_3(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==9\n\n def _is_Athlon(self):\n return self.is_AMD() and self.info[0]['Family']==6\n\n def _is_Athlon64(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==4\n\n def _is_Opteron(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==5\n\n # Intel\n\n def _is_Intel(self):\n return self.info[0]['VendorIdentifier']=='GenuineIntel'\n\n def _is_i386(self):\n return self.info[0]['Family']==3\n\n def _is_i486(self):\n return self.info[0]['Family']==4\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['Family']==6\n\n def _is_Pentium(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_PentiumMMX(self):\n return self.is_Intel() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==4\n\n def _is_PentiumPro(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model']==1\n\n def _is_PentiumII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [3,5,6]\n\n def _is_PentiumIII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [7,8,9,10,11]\n\n def _is_PentiumIV(self):\n return self.is_Intel() and self.info[0]['Family']==15\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_mmx(self):\n if self.is_Intel():\n return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \\\n or (self.info[0]['Family'] in [6,15])\n elif self.is_AMD():\n return self.info[0]['Family'] in [5,6,15]\n\n def _has_sse(self):\n if self.is_Intel():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [7,8,9,10,11]) \\\n or self.info[0]['Family']==15\n elif self.is_AMD():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [6,7,8,10]) \\\n or self.info[0]['Family']==15\n\n def _has_sse2(self):\n return self.info[0]['Family']==15\n\n def _has_3dnow(self):\n # XXX: does only AMD have 3dnow??\n return self.is_AMD() and self.info[0]['Family'] in [5,6,15]\n\n def _has_3dnowext(self):\n return self.is_AMD() and self.info[0]['Family'] in [6,15]\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\nelif sys.platform[:5] == 'sunos':\n cpuinfo = sunos_cpuinfo\nelif sys.platform[:5] == 'win32':\n cpuinfo = win32_cpuinfo\nelif sys.platform[:6] == 'cygwin':\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\ncpu = cpuinfo()\n\nif __name__ == \"__main__\":\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_':\n r = getattr(cpu,name[1:])()\n if r:\n if r!=1:\n print '%s=%s' %(name[1:],r),\n else:\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 180, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 206, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 3, "token_count": 41, "parameters": [ "self" ], "start_line": 218, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 229, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 256, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 277, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 302, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 331, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 335, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 368, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 417, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 419, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 429, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 433, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 444, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 446, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 456, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 458, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 460, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 462, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 464, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 467, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 471, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 482, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 533, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 536, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 548, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 555, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 565, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 568, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 571, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 574, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 583, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 587, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 591, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 595, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 604, "end_line": 605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 607, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 610, "end_line": 615, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 617, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 634, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 54, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 108, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 111, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 128, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 134, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 179, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 182, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 185, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 188, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 200, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 210, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 234, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 237, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 240, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 258, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 283, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 316, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 319, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 324, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 349, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 398, "end_line": 399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 400, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 403, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 405, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 407, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 410, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 414, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 417, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 419, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 421, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 423, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 425, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 427, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 429, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 433, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 435, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 437, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 439, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 441, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 445, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 463, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 508, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 517, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 521, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 529, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 533, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 536, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 546, "end_line": 547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 555, "end_line": 556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 558, "end_line": 559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 561, "end_line": 562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 564, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 568, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 572, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 576, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 585, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 591, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 598, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 608, "end_line": 609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 611, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 615, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 3, "token_count": 41, "parameters": [ "self" ], "start_line": 218, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 } ], "nloc": 532, "complexity": 218, "token_count": 4870, "diff_parsed": { "added": [ " def _is_32bit(self):", " return not self.is_64bit()", "", " import commands", " status,output = commands.getstatusoutput('uname -m')", " if not status:", " if not info: info.append({})", " info[-1]['uname_m'] = string.strip(output)", " def _is_Athlon64(self):", " return re.match(r'.*?Athlon\\(tm\\) 64\\b',", " self.info[0]['model name']) is not None", "", " def _is_64bit(self):", " if self.info[0].get('clflush size','')=='64':", " return 1", " if self.info[0]['uname_m']=='x86_64':", " return 1", " return 0", "" ], "deleted": [] } } ] }, { "hash": "bb6b4f440d3f46f1644ef85663706c30802052a1", "msg": "Alpha is always 64-bit.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-04T09:01:36+00:00", "author_timezone": 0, "committer_date": "2004-10-04T09:01:36+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "90f61af37ffc5219f3721a14c3820d43819cd783" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 2, "lines": 2, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/cpuinfo.py", "new_path": "scipy_distutils/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -216,6 +216,8 @@ def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n \n def _is_64bit(self):\n+ if self.is_Alpha():\n+ return 1\n if self.info[0].get('clflush size','')=='64':\n return 1\n if self.info[0]['uname_m']=='x86_64':\n", "added_lines": 2, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpu']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n def _getNCPUs(self):\n return 1\n\n def _is_32bit(self):\n return not self.is_64bit()\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n import commands\n status,output = commands.getstatusoutput('uname -m')\n if not status:\n if not info: info.append({})\n info[-1]['uname_m'] = string.strip(output)\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n def _is_AthlonMP(self):\n return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n self.info[0]['model name']) is not None\n\n def _is_Athlon64(self):\n return re.match(r'.*?Athlon\\(tm\\) 64\\b',\n self.info[0]['model name']) is not None\n\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n\n def _is_Opteron(self):\n return re.match(r'.*?Opteron\\b',\n self.info[0]['model name']) is not None\n\n def _is_Hammer(self):\n return re.match(r'.*?Hammer\\b',\n self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium.*?II\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumPro(self):\n return re.match(r'.*?PentiumPro\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumMMX(self):\n return re.match(r'.*?Pentium.*?MMX\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium.*?III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium.*?(IV|4)\\b',\n self.info[0]['model name']) is not None\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['model name']) is not None\n\n def _is_XEON(self):\n return re.match(r'.*?XEON\\b',\n self.info[0]['model name']) is not None\n\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n\n def _is_64bit(self):\n if self.is_Alpha():\n return 1\n if self.info[0].get('clflush size','')=='64':\n return 1\n if self.info[0]['uname_m']=='x86_64':\n return 1\n return 0\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def _getNCPUs(self):\n return int(self.info[0].get('NUM_PROCESSORS'))\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n status,output = commands.getstatusoutput('sysctl hw')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['sysctl_hw'] = d\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _getNCPUs(self):\n try: return int(self.info[0]['sysctl_hw']['hw.ncpu'])\n except: return 1\n\n def _is_Power_Macintosh(self):\n return self.info[0]['sysctl_hw']['hw.machine']=='Power Macintosh'\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nclass sunos_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('mach')\n if not status:\n if not info: info.append({})\n info[-1]['mach'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -i')\n if not status:\n if not info: info.append({})\n info[-1]['uname_i'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -X')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['uname_X'] = d\n status,output = commands.getstatusoutput('isainfo -b')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_b'] = string.strip(output)\n status,output = commands.getstatusoutput('isainfo -n')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_n'] = string.strip(output)\n status,output = commands.getstatusoutput('psrinfo -v 0')\n if not status:\n if not info: info.append({})\n for l in string.split(output,'\\n'):\n m = re.match(r'\\s*The (?P

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

[\\w\\d]+) processor operates at',l)\n if m:\n info[-1]['processor'] = m.group('p')\n break\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_32bit(self):\n return self.info[0]['isainfo_b']=='32'\n def _is_64bit(self):\n return self.info[0]['isainfo_b']=='64'\n\n def _is_i386(self):\n return self.info[0]['isainfo_n']=='i386'\n def _is_sparc(self):\n return self.info[0]['isainfo_n']=='sparc'\n def _is_sparcv9(self):\n return self.info[0]['isainfo_n']=='sparcv9'\n\n def _getNCPUs(self):\n try: return int(self.info[0]['uname_X']['NumCPU'])\n except: return 1\n\n def _is_sun4(self):\n return self.info[0]['arch']=='sun4'\n\n def _is_SUNW(self):\n return re.match(r'SUNW',self.info[0]['uname_i']) is not None\n def _is_sparcstation5(self):\n return re.match(r'.*SPARCstation-5',self.info[0]['uname_i']) is not None\n def _is_ultra1(self):\n return re.match(r'.*Ultra-1',self.info[0]['uname_i']) is not None\n def _is_ultra250(self):\n return re.match(r'.*Ultra-250',self.info[0]['uname_i']) is not None\n def _is_ultra2(self):\n return re.match(r'.*Ultra-2',self.info[0]['uname_i']) is not None\n def _is_ultra30(self):\n return re.match(r'.*Ultra-30',self.info[0]['uname_i']) is not None\n def _is_ultra4(self):\n return re.match(r'.*Ultra-4',self.info[0]['uname_i']) is not None\n def _is_ultra5_10(self):\n return re.match(r'.*Ultra-5_10',self.info[0]['uname_i']) is not None\n def _is_ultra5(self):\n return re.match(r'.*Ultra-5',self.info[0]['uname_i']) is not None\n def _is_ultra60(self):\n return re.match(r'.*Ultra-60',self.info[0]['uname_i']) is not None\n def _is_ultra80(self):\n return re.match(r'.*Ultra-80',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice(self):\n return re.match(r'.*Ultra-Enterprise',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice10k(self):\n return re.match(r'.*Ultra-Enterprise-10000',self.info[0]['uname_i']) is not None\n def _is_sunfire(self):\n return re.match(r'.*Sun-Fire',self.info[0]['uname_i']) is not None\n def _is_ultra(self):\n return re.match(r'.*Ultra',self.info[0]['uname_i']) is not None\n\n def _is_cpusparcv7(self):\n return self.info[0]['processor']=='sparcv7'\n def _is_cpusparcv8(self):\n return self.info[0]['processor']=='sparcv8'\n def _is_cpusparcv9(self):\n return self.info[0]['processor']=='sparcv9'\n\nclass win32_cpuinfo(cpuinfo_base):\n\n info = None\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n # XXX: what does the value of\n # HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\n # mean?\n\n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n #XXX: Bad style to use so long `try:...except:...`. Fix it!\n import _winreg\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n prgx = re.compile(r\"family\\s+(?P\\d+)\\s+model\\s+(?P\\d+)\"\\\n \"\\s+stepping\\s+(?P\\d+)\",re.IGNORECASE)\n chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,pkey)\n pnum=0\n while 1:\n try:\n proc=_winreg.EnumKey(chnd,pnum)\n except _winreg.error:\n break\n else:\n pnum+=1\n print proc\n info.append({\"Processor\":proc})\n phnd=_winreg.OpenKey(chnd,proc)\n pidx=0\n while True:\n try:\n name,value,vtpe=_winreg.EnumValue(phnd,pidx)\n except _winreg.error:\n break\n else:\n pidx=pidx+1\n info[-1][name]=value\n if name==\"Identifier\":\n srch=prgx.search(value)\n if srch:\n info[-1][\"Family\"]=int(srch.group(\"FML\"))\n info[-1][\"Model\"]=int(srch.group(\"MDL\"))\n info[-1][\"Stepping\"]=int(srch.group(\"STP\"))\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['VendorIdentifier']=='AuthenticAMD'\n\n def _is_Am486(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_Am5x86(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_AMDK5(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [0,1,2,3]\n\n def _is_AMDK6(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [6,7]\n\n def _is_AMDK6_2(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==8\n\n def _is_AMDK6_3(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==9\n\n def _is_Athlon(self):\n return self.is_AMD() and self.info[0]['Family']==6\n\n def _is_Athlon64(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==4\n\n def _is_Opteron(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==5\n\n # Intel\n\n def _is_Intel(self):\n return self.info[0]['VendorIdentifier']=='GenuineIntel'\n\n def _is_i386(self):\n return self.info[0]['Family']==3\n\n def _is_i486(self):\n return self.info[0]['Family']==4\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['Family']==6\n\n def _is_Pentium(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_PentiumMMX(self):\n return self.is_Intel() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==4\n\n def _is_PentiumPro(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model']==1\n\n def _is_PentiumII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [3,5,6]\n\n def _is_PentiumIII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [7,8,9,10,11]\n\n def _is_PentiumIV(self):\n return self.is_Intel() and self.info[0]['Family']==15\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_mmx(self):\n if self.is_Intel():\n return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \\\n or (self.info[0]['Family'] in [6,15])\n elif self.is_AMD():\n return self.info[0]['Family'] in [5,6,15]\n\n def _has_sse(self):\n if self.is_Intel():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [7,8,9,10,11]) \\\n or self.info[0]['Family']==15\n elif self.is_AMD():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [6,7,8,10]) \\\n or self.info[0]['Family']==15\n\n def _has_sse2(self):\n return self.info[0]['Family']==15\n\n def _has_3dnow(self):\n # XXX: does only AMD have 3dnow??\n return self.is_AMD() and self.info[0]['Family'] in [5,6,15]\n\n def _has_3dnowext(self):\n return self.is_AMD() and self.info[0]['Family'] in [6,15]\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\nelif sys.platform[:5] == 'sunos':\n cpuinfo = sunos_cpuinfo\nelif sys.platform[:5] == 'win32':\n cpuinfo = win32_cpuinfo\nelif sys.platform[:6] == 'cygwin':\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\ncpu = cpuinfo()\n\nif __name__ == \"__main__\":\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_':\n r = getattr(cpu,name[1:])()\n if r:\n if r!=1:\n print '%s=%s' %(name[1:],r),\n else:\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 180, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 206, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 8, "complexity": 4, "token_count": 50, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 231, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 255, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 258, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 304, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 333, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 337, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 342, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 345, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 370, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 419, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 421, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 435, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 444, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 446, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 456, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 458, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 460, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 462, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 464, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 466, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 471, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 473, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 484, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 529, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 532, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 535, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 538, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 542, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 546, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 554, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 557, "end_line": 559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 561, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 567, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 570, "end_line": 571, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 573, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 576, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 579, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 585, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 589, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 593, "end_line": 595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 597, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 601, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 606, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 609, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 612, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 619, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 632, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 636, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 180, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 206, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 3, "token_count": 41, "parameters": [ "self" ], "start_line": 218, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 229, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 256, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 277, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 302, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 331, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 335, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 338, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 368, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 417, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 419, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 429, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 433, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 444, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 446, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 456, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 458, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 460, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 462, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 464, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 467, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 471, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 482, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 533, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 536, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 548, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 555, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 565, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 568, "end_line": 569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 571, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 574, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 583, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 587, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 591, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 595, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 604, "end_line": 605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 607, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 610, "end_line": 615, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 617, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 634, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 8, "complexity": 4, "token_count": 50, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "nloc": 534, "complexity": 219, "token_count": 4879, "diff_parsed": { "added": [ " if self.is_Alpha():", " return 1" ], "deleted": [] } } ] }, { "hash": "b77d7f9af842bc84e40713b22b614c67a93623ce", "msg": "Added has_sse3 and gcc-3.4 flags for Opteron and Athlon 64 cpus.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-04T09:30:54+00:00", "author_timezone": 0, "committer_date": "2004-10-04T09:30:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "bb6b4f440d3f46f1644ef85663706c30802052a1" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 13, "lines": 13, "files": 2, "dmm_unit_size": 0.16666666666666666, "dmm_unit_complexity": 0.16666666666666666, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/cpuinfo.py", "new_path": "scipy_distutils/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -209,6 +209,9 @@ def _has_sse(self):\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n \n+ def _has_sse3(self):\n+ return re.match(r'.*?\\bsse3\\b',self.info[0]['flags']) is not None\n+\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n \n", "added_lines": 3, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpu']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n def _getNCPUs(self):\n return 1\n\n def _is_32bit(self):\n return not self.is_64bit()\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n import commands\n status,output = commands.getstatusoutput('uname -m')\n if not status:\n if not info: info.append({})\n info[-1]['uname_m'] = string.strip(output)\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n def _is_AthlonMP(self):\n return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n self.info[0]['model name']) is not None\n\n def _is_Athlon64(self):\n return re.match(r'.*?Athlon\\(tm\\) 64\\b',\n self.info[0]['model name']) is not None\n\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n\n def _is_Opteron(self):\n return re.match(r'.*?Opteron\\b',\n self.info[0]['model name']) is not None\n\n def _is_Hammer(self):\n return re.match(r'.*?Hammer\\b',\n self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium.*?II\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumPro(self):\n return re.match(r'.*?PentiumPro\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumMMX(self):\n return re.match(r'.*?Pentium.*?MMX\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium.*?III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium.*?(IV|4)\\b',\n self.info[0]['model name']) is not None\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['model name']) is not None\n\n def _is_XEON(self):\n return re.match(r'.*?XEON\\b',\n self.info[0]['model name']) is not None\n\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_sse3(self):\n return re.match(r'.*?\\bsse3\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n\n def _is_64bit(self):\n if self.is_Alpha():\n return 1\n if self.info[0].get('clflush size','')=='64':\n return 1\n if self.info[0]['uname_m']=='x86_64':\n return 1\n return 0\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def _getNCPUs(self):\n return int(self.info[0].get('NUM_PROCESSORS'))\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n status,output = commands.getstatusoutput('sysctl hw')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['sysctl_hw'] = d\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _getNCPUs(self):\n try: return int(self.info[0]['sysctl_hw']['hw.ncpu'])\n except: return 1\n\n def _is_Power_Macintosh(self):\n return self.info[0]['sysctl_hw']['hw.machine']=='Power Macintosh'\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nclass sunos_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('mach')\n if not status:\n if not info: info.append({})\n info[-1]['mach'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -i')\n if not status:\n if not info: info.append({})\n info[-1]['uname_i'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -X')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['uname_X'] = d\n status,output = commands.getstatusoutput('isainfo -b')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_b'] = string.strip(output)\n status,output = commands.getstatusoutput('isainfo -n')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_n'] = string.strip(output)\n status,output = commands.getstatusoutput('psrinfo -v 0')\n if not status:\n if not info: info.append({})\n for l in string.split(output,'\\n'):\n m = re.match(r'\\s*The (?P

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

[\\w\\d]+) processor operates at',l)\n if m:\n info[-1]['processor'] = m.group('p')\n break\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_32bit(self):\n return self.info[0]['isainfo_b']=='32'\n def _is_64bit(self):\n return self.info[0]['isainfo_b']=='64'\n\n def _is_i386(self):\n return self.info[0]['isainfo_n']=='i386'\n def _is_sparc(self):\n return self.info[0]['isainfo_n']=='sparc'\n def _is_sparcv9(self):\n return self.info[0]['isainfo_n']=='sparcv9'\n\n def _getNCPUs(self):\n try: return int(self.info[0]['uname_X']['NumCPU'])\n except: return 1\n\n def _is_sun4(self):\n return self.info[0]['arch']=='sun4'\n\n def _is_SUNW(self):\n return re.match(r'SUNW',self.info[0]['uname_i']) is not None\n def _is_sparcstation5(self):\n return re.match(r'.*SPARCstation-5',self.info[0]['uname_i']) is not None\n def _is_ultra1(self):\n return re.match(r'.*Ultra-1',self.info[0]['uname_i']) is not None\n def _is_ultra250(self):\n return re.match(r'.*Ultra-250',self.info[0]['uname_i']) is not None\n def _is_ultra2(self):\n return re.match(r'.*Ultra-2',self.info[0]['uname_i']) is not None\n def _is_ultra30(self):\n return re.match(r'.*Ultra-30',self.info[0]['uname_i']) is not None\n def _is_ultra4(self):\n return re.match(r'.*Ultra-4',self.info[0]['uname_i']) is not None\n def _is_ultra5_10(self):\n return re.match(r'.*Ultra-5_10',self.info[0]['uname_i']) is not None\n def _is_ultra5(self):\n return re.match(r'.*Ultra-5',self.info[0]['uname_i']) is not None\n def _is_ultra60(self):\n return re.match(r'.*Ultra-60',self.info[0]['uname_i']) is not None\n def _is_ultra80(self):\n return re.match(r'.*Ultra-80',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice(self):\n return re.match(r'.*Ultra-Enterprise',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice10k(self):\n return re.match(r'.*Ultra-Enterprise-10000',self.info[0]['uname_i']) is not None\n def _is_sunfire(self):\n return re.match(r'.*Sun-Fire',self.info[0]['uname_i']) is not None\n def _is_ultra(self):\n return re.match(r'.*Ultra',self.info[0]['uname_i']) is not None\n\n def _is_cpusparcv7(self):\n return self.info[0]['processor']=='sparcv7'\n def _is_cpusparcv8(self):\n return self.info[0]['processor']=='sparcv8'\n def _is_cpusparcv9(self):\n return self.info[0]['processor']=='sparcv9'\n\nclass win32_cpuinfo(cpuinfo_base):\n\n info = None\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n # XXX: what does the value of\n # HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\n # mean?\n\n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n #XXX: Bad style to use so long `try:...except:...`. Fix it!\n import _winreg\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n prgx = re.compile(r\"family\\s+(?P\\d+)\\s+model\\s+(?P\\d+)\"\\\n \"\\s+stepping\\s+(?P\\d+)\",re.IGNORECASE)\n chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,pkey)\n pnum=0\n while 1:\n try:\n proc=_winreg.EnumKey(chnd,pnum)\n except _winreg.error:\n break\n else:\n pnum+=1\n print proc\n info.append({\"Processor\":proc})\n phnd=_winreg.OpenKey(chnd,proc)\n pidx=0\n while True:\n try:\n name,value,vtpe=_winreg.EnumValue(phnd,pidx)\n except _winreg.error:\n break\n else:\n pidx=pidx+1\n info[-1][name]=value\n if name==\"Identifier\":\n srch=prgx.search(value)\n if srch:\n info[-1][\"Family\"]=int(srch.group(\"FML\"))\n info[-1][\"Model\"]=int(srch.group(\"MDL\"))\n info[-1][\"Stepping\"]=int(srch.group(\"STP\"))\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['VendorIdentifier']=='AuthenticAMD'\n\n def _is_Am486(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_Am5x86(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_AMDK5(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [0,1,2,3]\n\n def _is_AMDK6(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [6,7]\n\n def _is_AMDK6_2(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==8\n\n def _is_AMDK6_3(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==9\n\n def _is_Athlon(self):\n return self.is_AMD() and self.info[0]['Family']==6\n\n def _is_Athlon64(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==4\n\n def _is_Opteron(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==5\n\n # Intel\n\n def _is_Intel(self):\n return self.info[0]['VendorIdentifier']=='GenuineIntel'\n\n def _is_i386(self):\n return self.info[0]['Family']==3\n\n def _is_i486(self):\n return self.info[0]['Family']==4\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['Family']==6\n\n def _is_Pentium(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_PentiumMMX(self):\n return self.is_Intel() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==4\n\n def _is_PentiumPro(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model']==1\n\n def _is_PentiumII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [3,5,6]\n\n def _is_PentiumIII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [7,8,9,10,11]\n\n def _is_PentiumIV(self):\n return self.is_Intel() and self.info[0]['Family']==15\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_mmx(self):\n if self.is_Intel():\n return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \\\n or (self.info[0]['Family'] in [6,15])\n elif self.is_AMD():\n return self.info[0]['Family'] in [5,6,15]\n\n def _has_sse(self):\n if self.is_Intel():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [7,8,9,10,11]) \\\n or self.info[0]['Family']==15\n elif self.is_AMD():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [6,7,8,10]) \\\n or self.info[0]['Family']==15\n\n def _has_sse2(self):\n return self.info[0]['Family']==15\n\n def _has_3dnow(self):\n # XXX: does only AMD have 3dnow??\n return self.is_AMD() and self.info[0]['Family'] in [5,6,15]\n\n def _has_3dnowext(self):\n return self.is_AMD() and self.info[0]['Family'] in [6,15]\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\nelif sys.platform[:5] == 'sunos':\n cpuinfo = sunos_cpuinfo\nelif sys.platform[:5] == 'win32':\n cpuinfo = win32_cpuinfo\nelif sys.platform[:6] == 'cygwin':\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\ncpu = cpuinfo()\n\nif __name__ == \"__main__\":\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_':\n r = getattr(cpu,name[1:])()\n if r:\n if r!=1:\n print '%s=%s' %(name[1:],r),\n else:\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 180, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 206, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse3", "long_name": "_has_sse3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "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": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 218, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 8, "complexity": 4, "token_count": 50, "parameters": [ "self" ], "start_line": 221, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 234, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 258, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 264, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 282, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 285, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 307, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 336, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 345, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 348, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 373, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 427, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 429, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 441, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 445, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 447, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 449, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 451, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 453, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 455, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 457, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 459, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 461, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 463, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 465, "end_line": 466, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 467, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 476, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 487, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 532, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 535, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 538, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 545, "end_line": 547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 549, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 557, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 560, "end_line": 562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 564, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 570, "end_line": 571, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 573, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 576, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 579, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 585, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 588, "end_line": 590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 592, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 596, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 600, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 604, "end_line": 605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 609, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 612, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 615, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 622, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 632, "end_line": 633, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 635, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 639, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 50, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 21, "complexity": 9, "token_count": 154, "parameters": [ "self" ], "start_line": 57, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 106, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 129, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 180, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_XEON", "long_name": "_is_XEON( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 203, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 206, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 209, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 8, "complexity": 4, "token_count": 50, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 231, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 255, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 258, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 304, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 333, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 337, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 340, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 342, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 345, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 370, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 419, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 421, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 435, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 444, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 446, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 448, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 450, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 456, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 458, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 460, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 462, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 464, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 466, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 471, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 473, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 484, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 529, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 532, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 535, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 538, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 542, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 546, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 554, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 557, "end_line": 559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 561, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 567, "end_line": 568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 570, "end_line": 571, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 573, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 576, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 579, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 585, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 589, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 593, "end_line": 595, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 597, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 601, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 606, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 609, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 612, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 619, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 632, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 636, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_has_sse3", "long_name": "_has_sse3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 536, "complexity": 220, "token_count": 4906, "diff_parsed": { "added": [ " def _has_sse3(self):", " return re.match(r'.*?\\bsse3\\b',self.info[0]['flags']) is not None", "" ], "deleted": [] } }, { "old_path": "scipy_distutils/gnufcompiler.py", "new_path": "scipy_distutils/gnufcompiler.py", "filename": "gnufcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -151,10 +151,20 @@ def get_flags_arch(self):\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n+ if self.get_version() >= '3.4' and not march_flag:\n+ march_flag = 1\n+ if cpu.is_Opteron():\n+ opt.append('-march=opteron')\n+ elif cpu.is_Athlon64():\n+ opt.append('-march=athlon64')\n+ else:\n+ march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n+ if self.get_version() >= '3.4':\n+ if cpu.has_sse3(): opt.append('-msse3')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n", "added_lines": 10, "deleted_lines": 0, "source_code": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import exec_command, find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran (GCC) 3.3.3 (Debian 20040401)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n\n # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n\n #def get_linker_so(self):\n # # win32 linking should be handled by standard linker\n # # Darwin g77 cannot be used as a linker.\n # #if re.match(r'(darwin)', sys.platform):\n # # return\n # return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = []\n if sys.platform=='darwin':\n if os.path.realpath(sys.executable).startswith('/System'):\n # This is when Python is from Apple framework\n opt.extend([\"-Wl,-framework\",\"-Wl,Python\"])\n #else we are running in Fink python.\n opt.extend([\"-lcc_dynamic\",\"-bundle\"])\n else:\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = []\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = []\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if self.get_version() >= '3.4' and not march_flag:\n march_flag = 1\n if cpu.is_Opteron():\n opt.append('-march=opteron')\n elif cpu.is_Athlon64():\n opt.append('-march=athlon64')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if self.get_version() >= '3.4':\n if cpu.has_sse3(): opt.append('-msse3')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n #compiler = new_fcompiler(compiler='gnu')\n compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "source_code_before": "\nimport re\nimport os\nimport sys\n\nfrom cpuinfo import cpu\nfrom fcompiler import FCompiler\nfrom exec_command import exec_command, find_executable\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_pattern = r'GNU Fortran ((\\(GCC[^\\)]*(\\)\\)|\\)))|)\\s*'\\\n '(?P[^\\s*\\)]+)'\n\n # 'g77 --version' results\n # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)\n # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)\n # GNU Fortran (GCC) 3.3.3 (Debian 20040401)\n # GNU Fortran 0.5.25 20010319 (prerelease)\n # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)\n\n for fc_exe in map(find_executable,['g77','f77']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_f90' : None,\n 'compiler_fix' : None,\n 'linker_so' : [fc_exe],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n }\n module_dir_switch = None\n module_include_switch = None\n\n # Cygwin: f771: warning: -fPIC ignored for target (all code is position independent)\n if os.name != 'nt' and sys.platform!='cygwin':\n pic_flags = ['-fPIC']\n\n #def get_linker_so(self):\n # # win32 linking should be handled by standard linker\n # # Darwin g77 cannot be used as a linker.\n # #if re.match(r'(darwin)', sys.platform):\n # # return\n # return FCompiler.get_linker_so(self)\n\n def get_flags_linker_so(self):\n opt = []\n if sys.platform=='darwin':\n if os.path.realpath(sys.executable).startswith('/System'):\n # This is when Python is from Apple framework\n opt.extend([\"-Wl,-framework\",\"-Wl,Python\"])\n #else we are running in Fink python.\n opt.extend([\"-lcc_dynamic\",\"-bundle\"])\n else:\n opt.append(\"-shared\")\n if sys.platform[:5]=='sunos':\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work. 'man gcc' says:\n # \".. Instead of using -mimpure-text, you should compile all\n # source code with -fpic or -fPIC.\"\n opt.append('-mimpure-text')\n return opt\n\n def get_libgcc_dir(self):\n status, output = exec_command('%s -print-libgcc-file-name' \\\n % (self.compiler_f77[0]),use_tee=0) \n if not status:\n return os.path.dirname(output)\n return\n\n def get_library_dirs(self):\n opt = []\n if sys.platform[:5] != 'linux':\n d = self.get_libgcc_dir()\n if d:\n opt.append(d)\n return opt\n\n def get_libraries(self):\n opt = []\n d = self.get_libgcc_dir()\n if d is not None:\n for g2c in ['g2c-pic','g2c']:\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if os.path.isfile(os.path.join(d,f)):\n break\n else:\n g2c = 'g2c'\n if sys.platform=='win32':\n opt.extend(['gcc',g2c])\n else:\n opt.append(g2c)\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n opt = ['-O3','-funroll-loops']\n return opt\n\n def get_flags_arch(self):\n opt = []\n if sys.platform=='darwin':\n if os.name != 'posix':\n # this should presumably correspond to Apple\n if cpu.is_ppc():\n opt.append('-arch ppc')\n elif cpu.is_i386():\n opt.append('-arch i386')\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt.append('-mcpu='+a)\n opt.append('-mtune='+a)\n break \n return opt\n march_flag = 1\n # 0.5.25 corresponds to 2.95.x\n if self.get_version() == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n else:\n march_flag = 0\n # Note: gcc 3.2 on win32 has breakage with -march specified\n elif self.get_version() >= '3.1.1' \\\n and not sys.platform=='win32': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt.append('-march=k6')\n elif cpu.is_AthlonK6_2():\n opt.append('-march=k6-2')\n elif cpu.is_AthlonK6_3():\n opt.append('-march=k6-3')\n elif cpu.is_AthlonK7():\n opt.append('-march=athlon')\n elif cpu.is_AthlonMP():\n opt.append('-march=athlon-mp')\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt.append('-march=pentium4')\n elif cpu.is_PentiumIII():\n opt.append('-march=pentium3')\n elif cpu.is_PentiumII():\n opt.append('-march=pentium2')\n else:\n march_flag = 0\n if cpu.has_mmx(): opt.append('-mmmx') \n if self.get_version() > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt.append('-march=i686')\n elif cpu.is_i586():\n opt.append('-march=i586')\n elif cpu.is_i486():\n opt.append('-march=i486')\n elif cpu.is_i386():\n opt.append('-march=i386')\n if cpu.is_Intel():\n opt.extend(['-malign-double','-fomit-frame-pointer'])\n return opt\n\nif __name__ == '__main__':\n from scipy_distutils import log\n log.set_verbosity(2)\n from fcompiler import new_fcompiler\n #compiler = new_fcompiler(compiler='gnu')\n compiler = GnuFCompiler()\n compiler.customize()\n print compiler.get_version()\n", "methods": [ { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 11, "complexity": 4, "token_count": 80, "parameters": [ "self" ], "start_line": 49, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 69, "end_line": 74, "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 )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 38, "parameters": [ "self" ], "start_line": 76, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 96, "parameters": [ "self" ], "start_line": 84, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 100, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 73, "complexity": 37, "token_count": 469, "parameters": [ "self" ], "start_line": 107, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "gnufcompiler.py", "nloc": 11, "complexity": 4, "token_count": 80, "parameters": [ "self" ], "start_line": 49, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_libgcc_dir", "long_name": "get_libgcc_dir( self )", "filename": "gnufcompiler.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 69, "end_line": 74, "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 )", "filename": "gnufcompiler.py", "nloc": 7, "complexity": 3, "token_count": 38, "parameters": [ "self" ], "start_line": 76, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "gnufcompiler.py", "nloc": 15, "complexity": 5, "token_count": 96, "parameters": [ "self" ], "start_line": 84, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "gnufcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 100, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "gnufcompiler.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 63, "complexity": 31, "token_count": 401, "parameters": [ "self" ], "start_line": 107, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "gnufcompiler.py", "nloc": 73, "complexity": 37, "token_count": 469, "parameters": [ "self" ], "start_line": 107, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 } ], "nloc": 150, "complexity": 53, "token_count": 923, "diff_parsed": { "added": [ " if self.get_version() >= '3.4' and not march_flag:", " march_flag = 1", " if cpu.is_Opteron():", " opt.append('-march=opteron')", " elif cpu.is_Athlon64():", " opt.append('-march=athlon64')", " else:", " march_flag = 0", " if self.get_version() >= '3.4':", " if cpu.has_sse3(): opt.append('-msse3')" ], "deleted": [] } } ] }, { "hash": "be274e75b825690990419300f51475dd87256385", "msg": "Fixed bdist_rpm for scipy_core.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-04T15:21:02+00:00", "author_timezone": 0, "committer_date": "2004-10-04T15:21:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b77d7f9af842bc84e40713b22b614c67a93623ce" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 5, "lines": 6, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -46,7 +46,11 @@ def configuration(parent_package='',parent_path=None):\n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n- ext = Extension(dot_join(package,'_compiled_base'),sources)\n+ depends = ['_scipy_mapping.c','_scipy_number.c']\n+ depends = [os.path.join(local_path,x) for x in depends]\n+\n+ ext = Extension(dot_join(package,'_compiled_base'),sources,\n+ depends = depends)\n config['ext_modules'].append(ext)\n \n # display_test module\n", "added_lines": 5, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n depends = ['_scipy_mapping.c','_scipy_number.c']\n depends = [os.path.join(local_path,x) for x in depends]\n\n ext = Extension(dot_join(package,'_compiled_base'),sources,\n depends = depends)\n config['ext_modules'].append(ext)\n\n # display_test module\n sources = [os.path.join(local_path,'src','display_test.c')]\n x11 = get_info('x11')\n if x11:\n x11['define_macros'] = [('HAVE_X11',None)]\n ext = Extension(dot_join(package,'display_test'), sources, **x11)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n # display_test module\n sources = [os.path.join(local_path,'src','display_test.c')]\n x11 = get_info('x11')\n if x11:\n x11['define_macros'] = [('HAVE_X11',None)]\n ext = Extension(dot_join(package,'display_test'), sources, **x11)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 44, "complexity": 7, "token_count": 360, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 41, "complexity": 6, "token_count": 331, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 44, "complexity": 7, "token_count": 360, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 } ], "nloc": 59, "complexity": 7, "token_count": 421, "diff_parsed": { "added": [ " depends = ['_scipy_mapping.c','_scipy_number.c']", " depends = [os.path.join(local_path,x) for x in depends]", "", " ext = Extension(dot_join(package,'_compiled_base'),sources,", " depends = depends)" ], "deleted": [ " ext = Extension(dot_join(package,'_compiled_base'),sources)" ] } } ] }, { "hash": "e88796b408138f0dbe1da2eb0ef261d1d805b296", "msg": "Added documentation fixes and comment changes.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2004-10-05T13:58:47+00:00", "author_timezone": 0, "committer_date": "2004-10-05T13:58:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "be274e75b825690990419300f51475dd87256385" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 3, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumathmodule.c", "new_path": "scipy_base/fastumathmodule.c", "filename": "fastumathmodule.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -12,7 +12,9 @@\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n \n- All logical operations return UBYTE arrays.\n+ All logical operations return UBYTE arrays except for \n+ logical_and, logical_or, and logical_xor\n+ which return their type so that reduce works correctly on them....\n */\n \n #if defined _ISOC99_SOURCE || defined _XOPEN_SOURCE_EXTENDED \\\n", "added_lines": 3, "deleted_lines": 1, "source_code": "#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays except for \n logical_and, logical_or, and logical_xor\n which return their type so that reduce works correctly on them....\n*/\n\n#if defined _ISOC99_SOURCE || defined _XOPEN_SOURCE_EXTENDED \\\n || defined _BSD_SOURCE || defined _SVID_SOURCE\n#define HAVE_INVERSE_HYPERBOLIC 1\n#endif\n\nstatic PyObject *Array0d_FromDouble(double); \n/* Wrapper to include the correct version */\n\n/* Complex functions */\n\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 (xx < 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/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex\nc_sum_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real + b.real;\n r.imag = a.imag + b.imag;\n return r;\n}\n\nstatic Py_complex\nc_diff_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real - b.real;\n r.imag = a.imag - b.imag;\n return r;\n}\n\nstatic Py_complex\nc_neg_(Py_complex a)\n{\n Py_complex r;\n r.real = -a.real;\n r.imag = -a.imag;\n return r;\n}\n\nstatic Py_complex\nc_prod_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real*b.real - a.imag*b.imag;\n r.imag = a.real*b.imag + a.imag*b.real;\n return r;\n}\n\nstatic Py_complex\nc_pow_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n double vabs,len,at,phase;\n if (b.real == 0. && b.imag == 0.) {\n\tr.real = 1.;\n\tr.imag = 0.;\n }\n else if (a.real == 0. && a.imag == 0.) {\n\tif (b.imag != 0. || b.real < 0.)\n\t errno = EDOM;\n\tr.real = 0.;\n\tr.imag = 0.;\n }\n else {\n\tvabs = hypot(a.real,a.imag);\n\tlen = pow(vabs,b.real);\n\tat = atan2(a.imag, a.real);\n\tphase = at*b.real;\n\tif (b.imag != 0.0) {\n\t len /= exp(at*b.imag);\n\t phase += b.imag*log(vabs);\n\t}\n\tr.real = len*cos(phase);\n\tr.imag = len*sin(phase);\n }\n return r;\n}\n\n/* First, the C functions that do the real work */\n\nstatic Py_complex \nc_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n\t/* Using matlab's convention (x+0j is x):\n\t (0+0j)/0 -> nan+0j\n\t (0+xj)/0 -> nan+sign(x)*infj\n\t (x+0j)/0 -> sign(x)*inf+0j\n\t*/\n\tif (a.imag == 0.0) {r.imag = 0.0;}\n return r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex \nc_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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\n#ifdef PyArray_UNSIGNED_TYPES\n#include \"fastumath_unsigned.inc\"\n#else\n#include \"fastumath_nounsigned.inc\"\n#endif\n\nstatic PyObject *Array0d_FromDouble(double val){\n PyArrayObject *a;\n a = (PyArrayObject *)PyArray_FromDims(0,NULL,PyArray_DOUBLE);\n memcpy(a->data,(char *)(&val),a->descr->elsize);\n return (PyObject *)a;\n}\n\nstatic double pinf_init(void) {\n double mul = 1e10;\n double tmp = 0.0;\n double pinf;\n\n pinf = mul;\n for (;;) {\n\tpinf *= mul;\n\tif (pinf == tmp) break;\n\ttmp = pinf;\n }\n return pinf;\n}\n\nstatic double pzero_init(void) {\n double div = 1e10;\n double tmp = 0.0;\n double pinf;\n\n pinf = div;\n for (;;) {\n\tpinf /= div;\n\tif (pinf == tmp) break;\n\ttmp = pinf;\n }\n return pinf;\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(void) {\n PyObject *m, *d, *s, *f1;\n double pinf, pzero, nan;\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(\"2.3\");\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 pinf = pinf_init();\n PyDict_SetItemString(d, \"PINF\", s = PyFloat_FromDouble(pinf));\n Py_DECREF(s);\n PyDict_SetItemString(d, \"NINF\", s = PyFloat_FromDouble(-pinf));\n Py_DECREF(s);\n pzero = pzero_init();\n PyDict_SetItemString(d, \"PZERO\", s = PyFloat_FromDouble(pzero));\n Py_DECREF(s);\n PyDict_SetItemString(d, \"NZERO\", s = PyFloat_FromDouble(-pzero));\n Py_DECREF(s);\n nan = pinf / pinf;\n PyDict_SetItemString(d, \"NAN\", s = PyFloat_FromDouble(nan));\n Py_DECREF(s);\n\n f1 = PyDict_GetItemString(d, \"conjugate\"); /* Borrowed reference */\n\n /* Setup the array object's numerical structures */\n PyArray_SetNumericOps(d);\n\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 fastumath\");\n}\n\n", "source_code_before": "#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#if defined _ISOC99_SOURCE || defined _XOPEN_SOURCE_EXTENDED \\\n || defined _BSD_SOURCE || defined _SVID_SOURCE\n#define HAVE_INVERSE_HYPERBOLIC 1\n#endif\n\nstatic PyObject *Array0d_FromDouble(double); \n/* Wrapper to include the correct version */\n\n/* Complex functions */\n\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 (xx < 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/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex\nc_sum_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real + b.real;\n r.imag = a.imag + b.imag;\n return r;\n}\n\nstatic Py_complex\nc_diff_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real - b.real;\n r.imag = a.imag - b.imag;\n return r;\n}\n\nstatic Py_complex\nc_neg_(Py_complex a)\n{\n Py_complex r;\n r.real = -a.real;\n r.imag = -a.imag;\n return r;\n}\n\nstatic Py_complex\nc_prod_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n r.real = a.real*b.real - a.imag*b.imag;\n r.imag = a.real*b.imag + a.imag*b.real;\n return r;\n}\n\nstatic Py_complex\nc_pow_(Py_complex a, Py_complex b)\n{\n Py_complex r;\n double vabs,len,at,phase;\n if (b.real == 0. && b.imag == 0.) {\n\tr.real = 1.;\n\tr.imag = 0.;\n }\n else if (a.real == 0. && a.imag == 0.) {\n\tif (b.imag != 0. || b.real < 0.)\n\t errno = EDOM;\n\tr.real = 0.;\n\tr.imag = 0.;\n }\n else {\n\tvabs = hypot(a.real,a.imag);\n\tlen = pow(vabs,b.real);\n\tat = atan2(a.imag, a.real);\n\tphase = at*b.real;\n\tif (b.imag != 0.0) {\n\t len /= exp(at*b.imag);\n\t phase += b.imag*log(vabs);\n\t}\n\tr.real = len*cos(phase);\n\tr.imag = len*sin(phase);\n }\n return r;\n}\n\n/* First, the C functions that do the real work */\n\nstatic Py_complex \nc_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n\t/* Using matlab's convention (x+0j is x):\n\t (0+0j)/0 -> nan+0j\n\t (0+xj)/0 -> nan+sign(x)*infj\n\t (x+0j)/0 -> sign(x)*inf+0j\n\t*/\n\tif (a.imag == 0.0) {r.imag = 0.0;}\n return r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex \nc_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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 \nc_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\n#ifdef PyArray_UNSIGNED_TYPES\n#include \"fastumath_unsigned.inc\"\n#else\n#include \"fastumath_nounsigned.inc\"\n#endif\n\nstatic PyObject *Array0d_FromDouble(double val){\n PyArrayObject *a;\n a = (PyArrayObject *)PyArray_FromDims(0,NULL,PyArray_DOUBLE);\n memcpy(a->data,(char *)(&val),a->descr->elsize);\n return (PyObject *)a;\n}\n\nstatic double pinf_init(void) {\n double mul = 1e10;\n double tmp = 0.0;\n double pinf;\n\n pinf = mul;\n for (;;) {\n\tpinf *= mul;\n\tif (pinf == tmp) break;\n\ttmp = pinf;\n }\n return pinf;\n}\n\nstatic double pzero_init(void) {\n double div = 1e10;\n double tmp = 0.0;\n double pinf;\n\n pinf = div;\n for (;;) {\n\tpinf /= div;\n\tif (pinf == tmp) break;\n\ttmp = pinf;\n }\n return pinf;\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(void) {\n PyObject *m, *d, *s, *f1;\n double pinf, pzero, nan;\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(\"2.3\");\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 pinf = pinf_init();\n PyDict_SetItemString(d, \"PINF\", s = PyFloat_FromDouble(pinf));\n Py_DECREF(s);\n PyDict_SetItemString(d, \"NINF\", s = PyFloat_FromDouble(-pinf));\n Py_DECREF(s);\n pzero = pzero_init();\n PyDict_SetItemString(d, \"PZERO\", s = PyFloat_FromDouble(pzero));\n Py_DECREF(s);\n PyDict_SetItemString(d, \"NZERO\", s = PyFloat_FromDouble(-pzero));\n Py_DECREF(s);\n nan = pinf / pinf;\n PyDict_SetItemString(d, \"NAN\", s = PyFloat_FromDouble(nan));\n Py_DECREF(s);\n\n f1 = PyDict_GetItemString(d, \"conjugate\"); /* Borrowed reference */\n\n /* Setup the array object's numerical structures */\n PyArray_SetNumericOps(d);\n\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 fastumath\");\n}\n\n", "methods": [ { "name": "acosh", "long_name": "acosh( double x)", "filename": "fastumathmodule.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "x" ], "start_line": 32, "end_line": 35, "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": 37, "end_line": 50, "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": 52, "end_line": 55, "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": 63, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_sum_", "long_name": "c_sum_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "a", "b" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_diff_", "long_name": "c_diff_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "a", "b" ], "start_line": 114, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_neg_", "long_name": "c_neg_( Py_complex a)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 31, "parameters": [ "a" ], "start_line": 123, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_prod_", "long_name": "c_prod_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "a", "b" ], "start_line": 132, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_pow_", "long_name": "c_pow_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 28, "complexity": 8, "token_count": 203, "parameters": [ "a", "b" ], "start_line": 141, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "c_quot_fast", "long_name": "c_quot_fast( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 25, "complexity": 7, "token_count": 252, "parameters": [ "a", "b" ], "start_line": 173, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "c_quot_floor_fast", "long_name": "c_quot_floor_fast( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 8, "complexity": 1, "token_count": 42, "parameters": [ "a", "b" ], "start_line": 219, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 234, "end_line": 257, "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": 260, "end_line": 267, "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": 270, "end_line": 276, "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": 279, "end_line": 283, "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": 286, "end_line": 290, "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": 293, "end_line": 297, "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": 300, "end_line": 303, "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": 306, "end_line": 309, "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": 312, "end_line": 315, "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": 318, "end_line": 324, "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": 327, "end_line": 333, "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": 336, "end_line": 343, "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": 346, "end_line": 353, "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": 356, "end_line": 362, "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": 365, "end_line": 371, "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": 374, "end_line": 392, "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": 395, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "Array0d_FromDouble", "long_name": "Array0d_FromDouble( double val)", "filename": "fastumathmodule.c", "nloc": 6, "complexity": 1, "token_count": 55, "parameters": [ "val" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "pinf_init", "long_name": "pinf_init()", "filename": "fastumathmodule.c", "nloc": 12, "complexity": 3, "token_count": 50, "parameters": [], "start_line": 429, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "pzero_init", "long_name": "pzero_init()", "filename": "fastumathmodule.c", "nloc": 12, "complexity": 3, "token_count": 50, "parameters": [], "start_line": 443, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "initfastumath", "long_name": "initfastumath()", "filename": "fastumathmodule.c", "nloc": 34, "complexity": 2, "token_count": 270, "parameters": [], "start_line": 463, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 } ], "methods_before": [ { "name": "acosh", "long_name": "acosh( double x)", "filename": "fastumathmodule.c", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "x" ], "start_line": 30, "end_line": 33, "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": 35, "end_line": 48, "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": 50, "end_line": 53, "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": 61, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "c_sum_", "long_name": "c_sum_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "a", "b" ], "start_line": 103, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_diff_", "long_name": "c_diff_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 40, "parameters": [ "a", "b" ], "start_line": 112, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_neg_", "long_name": "c_neg_( Py_complex a)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 31, "parameters": [ "a" ], "start_line": 121, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_prod_", "long_name": "c_prod_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "a", "b" ], "start_line": 130, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "c_pow_", "long_name": "c_pow_( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 28, "complexity": 8, "token_count": 203, "parameters": [ "a", "b" ], "start_line": 139, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "c_quot_fast", "long_name": "c_quot_fast( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 25, "complexity": 7, "token_count": 252, "parameters": [ "a", "b" ], "start_line": 171, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 0 }, { "name": "c_quot_floor_fast", "long_name": "c_quot_floor_fast( Py_complex a , Py_complex b)", "filename": "fastumathmodule.c", "nloc": 8, "complexity": 1, "token_count": 42, "parameters": [ "a", "b" ], "start_line": 217, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 232, "end_line": 255, "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": 258, "end_line": 265, "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": 268, "end_line": 274, "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": 277, "end_line": 281, "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": 284, "end_line": 288, "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": 291, "end_line": 295, "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": 298, "end_line": 301, "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": 304, "end_line": 307, "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": 310, "end_line": 313, "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": 316, "end_line": 322, "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": 325, "end_line": 331, "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": 334, "end_line": 341, "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": 344, "end_line": 351, "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": 354, "end_line": 360, "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": 363, "end_line": 369, "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": 372, "end_line": 390, "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": 393, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "Array0d_FromDouble", "long_name": "Array0d_FromDouble( double val)", "filename": "fastumathmodule.c", "nloc": 6, "complexity": 1, "token_count": 55, "parameters": [ "val" ], "start_line": 420, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "pinf_init", "long_name": "pinf_init()", "filename": "fastumathmodule.c", "nloc": 12, "complexity": 3, "token_count": 50, "parameters": [], "start_line": 427, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "pzero_init", "long_name": "pzero_init()", "filename": "fastumathmodule.c", "nloc": 12, "complexity": 3, "token_count": 50, "parameters": [], "start_line": 441, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "initfastumath", "long_name": "initfastumath()", "filename": "fastumathmodule.c", "nloc": 34, "complexity": 2, "token_count": 270, "parameters": [], "start_line": 461, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 381, "complexity": 57, "token_count": 2450, "diff_parsed": { "added": [ " All logical operations return UBYTE arrays except for", " logical_and, logical_or, and logical_xor", " which return their type so that reduce works correctly on them...." ], "deleted": [ " All logical operations return UBYTE arrays." ] } } ] }, { "hash": "a942a40d9809f203e045b4f5772356707913bf3a", "msg": "Improved failure message on shape mismatch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-06T11:59:07+00:00", "author_timezone": 0, "committer_date": "2004-10-06T11:59:07+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e88796b408138f0dbe1da2eb0ef261d1d805b296" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 2, "insertions": 5, "lines": 7, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -667,8 +667,11 @@ def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n- assert alltrue(equal(shape(x),shape(y))),\\\n- msg + ' (shapes mismatch):\\n\\t' + err_msg\n+ cond = alltrue(equal(shape(x),shape(y)))\n+ if not cond:\n+ msg = msg + ' (shapes mismatch):\\n\\t'\\\n+ 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n+ assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n", "added_lines": 5, "deleted_lines": 2, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string,less\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\nDEBUG=0\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package='__main__'):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n cond = alltrue(equal(shape(x),shape(y)))\n if not cond:\n msg = msg + ' (shapes mismatch):\\n\\t'\\\n 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string,less\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\nDEBUG=0\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package='__main__'):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 146, "parameters": [ "level" ], "start_line": 21, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( reldir = '' , level = 1 )", "filename": "testing.py", "nloc": 11, "complexity": 3, "token_count": 97, "parameters": [ "reldir", "level" ], "start_line": 55, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 80, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 92, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 106, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 118, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , result = None )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 149, "parameters": [ "self", "result" ], "start_line": 135, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "write", "long_name": "write( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "message" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "writeln", "long_name": "writeln( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "message" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package = '__main__' )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "package" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 200, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 22, "complexity": 11, "token_count": 142, "parameters": [ "self", "clsobj", "level" ], "start_line": 206, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 36, "complexity": 8, "token_count": 331, "parameters": [ "self", "module", "level" ], "start_line": 229, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "_get_suite_list", "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", "filename": "testing.py", "nloc": 21, "complexity": 7, "token_count": 146, "parameters": [ "self", "test_module", "level", "module_name" ], "start_line": 271, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 294, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 19, "complexity": 6, "token_count": 166, "parameters": [ "self", "level", "verbosity" ], "start_line": 307, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 334, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 360, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 368, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 390, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 429, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 475, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 513, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 543, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 575, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 592, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 23, "complexity": 7, "token_count": 191, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 609, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 232, "parameters": [ "x", "y", "err_msg" ], "start_line": 641, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 26, "complexity": 6, "token_count": 251, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 665, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 693, "end_line": 712, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 715, "end_line": 724, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 726, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 146, "parameters": [ "level" ], "start_line": 21, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( reldir = '' , level = 1 )", "filename": "testing.py", "nloc": 11, "complexity": 3, "token_count": 97, "parameters": [ "reldir", "level" ], "start_line": 55, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 80, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 92, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 106, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 118, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , result = None )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 149, "parameters": [ "self", "result" ], "start_line": 135, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "write", "long_name": "write( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "message" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "writeln", "long_name": "writeln( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "message" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package = '__main__' )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "package" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 200, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 22, "complexity": 11, "token_count": 142, "parameters": [ "self", "clsobj", "level" ], "start_line": 206, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 36, "complexity": 8, "token_count": 331, "parameters": [ "self", "module", "level" ], "start_line": 229, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "_get_suite_list", "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", "filename": "testing.py", "nloc": 21, "complexity": 7, "token_count": 146, "parameters": [ "self", "test_module", "level", "module_name" ], "start_line": 271, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 294, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 19, "complexity": 6, "token_count": 166, "parameters": [ "self", "level", "verbosity" ], "start_line": 307, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 334, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 360, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 368, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 390, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 429, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 475, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 513, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 543, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 575, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 592, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 23, "complexity": 7, "token_count": 191, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 609, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 232, "parameters": [ "x", "y", "err_msg" ], "start_line": 641, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 665, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 690, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 712, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 723, "end_line": 733, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 26, "complexity": 6, "token_count": 251, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 665, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "nloc": 534, "complexity": 136, "token_count": 3979, "diff_parsed": { "added": [ " cond = alltrue(equal(shape(x),shape(y)))", " if not cond:", " msg = msg + ' (shapes mismatch):\\n\\t'\\", " 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))", " assert cond, msg + '\\n\\t' + err_msg" ], "deleted": [ " assert alltrue(equal(shape(x),shape(y))),\\", " msg + ' (shapes mismatch):\\n\\t' + err_msg" ] } } ] }, { "hash": "46fc1b2afbbc5c5c10fb9159345aca22074e4014", "msg": "Fixed issue 179.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-06T17:58:54+00:00", "author_timezone": 0, "committer_date": "2004-10-06T17:58:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a942a40d9809f203e045b4f5772356707913bf3a" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 4, "lines": 4, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/function_base.py", "new_path": "scipy_base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -241,6 +241,10 @@ def cumprod(m,axis=-1):\n def diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n+ if n==0:\n+ return x\n+ if n<0:\n+ raise ValueError,'Order must be non-negative but got ' + `n`\n x = _asarray1d(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n", "added_lines": 4, "deleted_lines": 0, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n sometrue, alltrue, reshape\nfrom type_check import ScalarType, isscalar, asarray\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin', 'alen', 'ptp','cumsum','take',\n 'copy', 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite',\n 'alter_numeric', 'restore_numeric','isaltered']\n\nalter_numeric = _compiled_base.alter_numeric\nrestore_numeric = _compiled_base.restore_numeric\n\ndef isaltered():\n val = str(type(array([1])))\n return 'scipy' in val\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n m = asarray(arr)\n if len(m.shape)==0:\n m = reshape(m,(1,))\n return m\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n\ndef take(a, indices, axis=0):\n \"\"\"Selects the elements in indices from array a along given axis.\n \"\"\"\n try:\n a = Numeric.take(a,indices,axis)\n except ValueError: # a is scalar\n pass\n return a\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 = _asarray1d(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 = _asarray1d(m)\n return minimum.reduce(m,axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\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 = _asarray1d(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 = _asarray1d(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 = _asarray1d(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 = _asarray1d(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 if n==0:\n return x\n if n<0:\n raise ValueError,'Order must be non-negative but got ' + `n`\n x = _asarray1d(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n sometrue, alltrue, reshape\nfrom type_check import ScalarType, isscalar, asarray\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin', 'alen', 'ptp','cumsum','take',\n 'copy', 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite',\n 'alter_numeric', 'restore_numeric','isaltered']\n\nalter_numeric = _compiled_base.alter_numeric\nrestore_numeric = _compiled_base.restore_numeric\n\ndef isaltered():\n val = str(type(array([1])))\n return 'scipy' in val\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\ndef _asarray1d(arr):\n \"\"\"Ensure 1d array for one array.\n \"\"\"\n m = asarray(arr)\n if len(m.shape)==0:\n m = reshape(m,(1,))\n return m\n\ndef copy(a):\n \"\"\"Return an array copy of the object.\n \"\"\"\n return array(a,copy=1)\n\ndef take(a, indices, axis=0):\n \"\"\"Selects the elements in indices from array a along given axis.\n \"\"\"\n try:\n a = Numeric.take(a,indices,axis)\n except ValueError: # a is scalar\n pass\n return a\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 = _asarray1d(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 = _asarray1d(m)\n return minimum.reduce(m,axis)\n\ndef alen(m):\n \"\"\"Returns the length of a Python object interpreted as an array\n \"\"\"\n return len(asarray(m))\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 = _asarray1d(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 = _asarray1d(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 = _asarray1d(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 = _asarray1d(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 = _asarray1d(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = _asarray1d(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Generalized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "methods": [ { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 22, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 28, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 36, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 55, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 88, "end_line": 93, "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": 95, "end_line": 101, "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": 103, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "arr" ], "start_line": 151, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "take", "long_name": "take( a , indices , axis = 0 )", "filename": "function_base.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "a", "indices", "axis" ], "start_line": 164, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "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": 174, "end_line": 182, "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": 184, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 201, "end_line": 209, "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": 211, "end_line": 219, "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": 221, "end_line": 229, "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": 231, "end_line": 239, "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": 15, "complexity": 4, "token_count": 130, "parameters": [ "x", "n", "axis" ], "start_line": 241, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 260, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 275, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 296, "end_line": 300, "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": 292, "end_line": 303, "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": 305, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 326, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 334, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 346, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 353, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 359, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 366, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 373, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 381, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 388, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 395, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 439, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 455, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 461, "end_line": 488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "methods_before": [ { "name": "isaltered", "long_name": "isaltered( )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [], "start_line": 22, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 28, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 36, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 48, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 55, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 88, "end_line": 93, "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": 95, "end_line": 101, "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": 103, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "_asarray1d", "long_name": "_asarray1d( arr )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "arr" ], "start_line": 151, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "copy", "long_name": "copy( a )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "a" ], "start_line": 159, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "take", "long_name": "take( a , indices , axis = 0 )", "filename": "function_base.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "a", "indices", "axis" ], "start_line": 164, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "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": 174, "end_line": 182, "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": 184, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "alen", "long_name": "alen( m )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "m" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 201, "end_line": 209, "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": 211, "end_line": 219, "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": 221, "end_line": 229, "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": 231, "end_line": 239, "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": 241, "end_line": 253, "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": 256, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 271, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 292, "end_line": 296, "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": 288, "end_line": 299, "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": 301, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 322, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 330, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 342, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 349, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 355, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 362, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 369, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 377, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 384, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 391, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 435, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 451, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 457, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 15, "complexity": 4, "token_count": 130, "parameters": [ "x", "n", "axis" ], "start_line": 241, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 318, "complexity": 91, "token_count": 2291, "diff_parsed": { "added": [ " if n==0:", " return x", " if n<0:", " raise ValueError,'Order must be non-negative but got ' + `n`" ], "deleted": [] } } ] }, { "hash": "68603ef3f6378c318c722e3bc44d581b1d9be894", "msg": "More changes to get rid of whrandom usage.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2004-10-06T23:03:34+00:00", "author_timezone": 0, "committer_date": "2004-10-06T23:03:34+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "46fc1b2afbbc5c5c10fb9159345aca22074e4014" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 17, "insertions": 17, "lines": 34, "files": 3, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -716,11 +716,11 @@ def rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n- import whrandom\n+ import random\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n- f[i] = whrandom.random()\n+ f[i] = random.random()\n return results\n \n def output_exception():\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string,less\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\nDEBUG=0\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package='__main__'):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n cond = alltrue(equal(shape(x),shape(y)))\n if not cond:\n msg = msg + ' (shapes mismatch):\\n\\t'\\\n 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import random\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = random.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string,less\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\nDEBUG=0\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package='__main__'):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n cond = alltrue(equal(shape(x),shape(y)))\n if not cond:\n msg = msg + ' (shapes mismatch):\\n\\t'\\\n 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 146, "parameters": [ "level" ], "start_line": 21, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( reldir = '' , level = 1 )", "filename": "testing.py", "nloc": 11, "complexity": 3, "token_count": 97, "parameters": [ "reldir", "level" ], "start_line": 55, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 80, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 92, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 106, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 118, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , result = None )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 149, "parameters": [ "self", "result" ], "start_line": 135, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "write", "long_name": "write( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "message" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "writeln", "long_name": "writeln( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "message" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package = '__main__' )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "package" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 200, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 22, "complexity": 11, "token_count": 142, "parameters": [ "self", "clsobj", "level" ], "start_line": 206, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 36, "complexity": 8, "token_count": 331, "parameters": [ "self", "module", "level" ], "start_line": 229, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "_get_suite_list", "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", "filename": "testing.py", "nloc": 21, "complexity": 7, "token_count": 146, "parameters": [ "self", "test_module", "level", "module_name" ], "start_line": 271, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 294, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 19, "complexity": 6, "token_count": 166, "parameters": [ "self", "level", "verbosity" ], "start_line": 307, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 334, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 360, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 368, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 390, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 429, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 475, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 513, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 543, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 575, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 592, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 23, "complexity": 7, "token_count": 191, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 609, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 232, "parameters": [ "x", "y", "err_msg" ], "start_line": 641, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 26, "complexity": 6, "token_count": 251, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 665, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 693, "end_line": 712, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 715, "end_line": 724, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 726, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 146, "parameters": [ "level" ], "start_line": 21, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( reldir = '' , level = 1 )", "filename": "testing.py", "nloc": 11, "complexity": 3, "token_count": 97, "parameters": [ "reldir", "level" ], "start_line": 55, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 80, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 92, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 106, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 111, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 118, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , result = None )", "filename": "testing.py", "nloc": 15, "complexity": 4, "token_count": 149, "parameters": [ "self", "result" ], "start_line": 135, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 153, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "write", "long_name": "write( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "message" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "writeln", "long_name": "writeln( self , message )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "message" ], "start_line": 157, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 166, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package = '__main__' )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "package" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 200, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 22, "complexity": 11, "token_count": 142, "parameters": [ "self", "clsobj", "level" ], "start_line": 206, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 36, "complexity": 8, "token_count": 331, "parameters": [ "self", "module", "level" ], "start_line": 229, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "_get_suite_list", "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", "filename": "testing.py", "nloc": 21, "complexity": 7, "token_count": 146, "parameters": [ "self", "test_module", "level", "module_name" ], "start_line": 271, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 294, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 19, "complexity": 6, "token_count": 166, "parameters": [ "self", "level", "verbosity" ], "start_line": 307, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 334, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 360, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 368, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 390, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 429, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 475, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 513, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 543, "end_line": 565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 575, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 592, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 23, "complexity": 7, "token_count": 191, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 609, "end_line": 637, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 232, "parameters": [ "x", "y", "err_msg" ], "start_line": 641, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 26, "complexity": 6, "token_count": 251, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 665, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 693, "end_line": 712, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 715, "end_line": 724, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 726, "end_line": 736, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 715, "end_line": 724, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "nloc": 534, "complexity": 136, "token_count": 3979, "diff_parsed": { "added": [ " import random", " f[i] = random.random()" ], "deleted": [ " import whrandom", " f[i] = whrandom.random()" ] } }, { "old_path": "weave/examples/dict_sort.py", "new_path": "weave/examples/dict_sort.py", "filename": "dict_sort.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -104,11 +104,11 @@ def sort_compare(a,n):\n \n def setup_dict(m):\n \" does insertion order matter?\"\n- import whrandom\n+ import random\n a = range(m)\n d = {}\n for i in range(m):\n- key = whrandom.choice(a)\n+ key = random.choice(a)\n a.remove(key)\n d[key]=key\n return d \n", "added_lines": 2, "deleted_lines": 2, "source_code": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) is dict)\n code = \"\"\"\n #line 24 \"dict_sort.py\" \n py::list keys = adict.keys();\n py::list items(keys.length());\n keys.sort(); \n PyObject* item = NULL;\n int N = keys.length();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GetItem(keys,i);\n item = PyDict_GetItem(adict,item);\n Py_XINCREF(item);\n PyList_SetItem(items,i,item); \n } \n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'])\n\ndef c_sort2(adict):\n assert(type(adict) is dict)\n code = \"\"\"\n #line 44 \"dict_sort.py\" \n py::list keys = adict.keys();\n py::list items(keys.len());\n keys.sort(); \n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c (Python API):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import random\n a = range(m)\n d = {}\n for i in range(m):\n key = random.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 3000\n sort_compare(a,n) \n", "source_code_before": "# Borrowed from Alex Martelli's sort from Python cookbook using inlines\n# 2x over fastest Python version -- again, maybe not worth the effort...\n# Then again, 2x is 2x...\n#\n# C:\\home\\eric\\wrk\\scipy\\weave\\examples>python dict_sort.py\n# Dict sort of 1000 items for 300 iterations:\n# speed in python: 0.250999927521\n# [0, 1, 2, 3, 4]\n# speed in c: 0.110000014305\n# speed up: 2.28\n# [0, 1, 2, 3, 4]\n# speed in c (scxx): 0.200000047684\n# speed up: 1.25\n# [0, 1, 2, 3, 4] \n\nimport sys\nsys.path.insert(0,'..')\nimport inline_tools\n\ndef c_sort(adict):\n assert(type(adict) is dict)\n code = \"\"\"\n #line 24 \"dict_sort.py\" \n py::list keys = adict.keys();\n py::list items(keys.length());\n keys.sort(); \n PyObject* item = NULL;\n int N = keys.length();\n for(int i = 0; i < N;i++)\n {\n item = PyList_GetItem(keys,i);\n item = PyDict_GetItem(adict,item);\n Py_XINCREF(item);\n PyList_SetItem(items,i,item); \n } \n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'])\n\ndef c_sort2(adict):\n assert(type(adict) is dict)\n code = \"\"\"\n #line 44 \"dict_sort.py\" \n py::list keys = adict.keys();\n py::list items(keys.len());\n keys.sort(); \n int N = keys.length();\n for(int i = 0; i < N;i++)\n items[i] = adict[keys[i]];\n return_val = items;\n \"\"\" \n return inline_tools.inline(code,['adict'],verbose=1)\n\n# (IMHO) the simplest approach:\ndef sortedDictValues1(adict):\n items = adict.items()\n items.sort()\n return [value for key, value in items]\n\n# an alternative implementation, which\n# happens to run a bit faster for large\n# dictionaries on my machine:\ndef sortedDictValues2(adict):\n keys = adict.keys()\n keys.sort()\n return [adict[key] for key in keys]\n\n# a further slight speed-up on my box\n# is to map a bound-method:\ndef sortedDictValues3(adict):\n keys = adict.keys()\n keys.sort()\n return map(adict.get, keys)\n\nimport time\n\ndef sort_compare(a,n):\n print 'Dict sort of %d items for %d iterations:'%(len(a),n)\n t1 = time.time()\n for i in range(n):\n b=sortedDictValues3(a)\n t2 = time.time()\n py = (t2-t1)\n print ' speed in python:', (t2 - t1)\n print b[:5]\n \n b=c_sort(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort(a)\n t2 = time.time()\n print ' speed in c (Python API):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\n b=c_sort2(a)\n t1 = time.time()\n for i in range(n):\n b=c_sort2(a)\n t2 = time.time()\n print ' speed in c (scxx):',(t2 - t1) \n print ' speed up: %3.2f' % (py/(t2-t1))\n print b[:5]\n\ndef setup_dict(m):\n \" does insertion order matter?\"\n import whrandom\n a = range(m)\n d = {}\n for i in range(m):\n key = whrandom.choice(a)\n a.remove(key)\n d[key]=key\n return d \nif __name__ == \"__main__\":\n m = 1000\n a = setup_dict(m)\n n = 3000\n sort_compare(a,n) \n", "methods": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 19, "complexity": 1, "token_count": 28, "parameters": [ "adict" ], "start_line": 20, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 13, "complexity": 1, "token_count": 32, "parameters": [ "adict" ], "start_line": 40, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 63, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 77, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "methods_before": [ { "name": "c_sort", "long_name": "c_sort( adict )", "filename": "dict_sort.py", "nloc": 19, "complexity": 1, "token_count": 28, "parameters": [ "adict" ], "start_line": 20, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "c_sort2", "long_name": "c_sort2( adict )", "filename": "dict_sort.py", "nloc": 13, "complexity": 1, "token_count": 32, "parameters": [ "adict" ], "start_line": 40, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "sortedDictValues1", "long_name": "sortedDictValues1( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 27, "parameters": [ "adict" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues2", "long_name": "sortedDictValues2( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "adict" ], "start_line": 63, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sortedDictValues3", "long_name": "sortedDictValues3( adict )", "filename": "dict_sort.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "adict" ], "start_line": 70, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sort_compare", "long_name": "sort_compare( a , n )", "filename": "dict_sort.py", "nloc": 25, "complexity": 4, "token_count": 187, "parameters": [ "a", "n" ], "start_line": 77, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup_dict", "long_name": "setup_dict( m )", "filename": "dict_sort.py", "nloc": 10, "complexity": 2, "token_count": 48, "parameters": [ "m" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "nloc": 88, "complexity": 13, "token_count": 422, "diff_parsed": { "added": [ " import random", " key = random.choice(a)" ], "deleted": [ " import whrandom", " key = whrandom.choice(a)" ] } }, { "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": "@@ -277,13 +277,13 @@ def check_1d_stride_12(self):\n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n- import whrandom\n+ import random\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+ beg = random.choice(choices)\n+ end = random.choice(choices)\n+ step = random.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n@@ -297,16 +297,16 @@ def check_2d_2(self):\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n- import whrandom\n+ import random\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+ beg = random.choice(choices)\n+ end = random.choice(choices)\n+ step = random.choice(choices) \n+ beg2 = random.choice(choices)\n+ end2 = random.choice(choices)\n+ step2 = random.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@@ -314,13 +314,13 @@ def check_2d_random(self):\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n- import whrandom\n+ import random\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+ idx.append(random.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", "added_lines": 13, "deleted_lines": 13, "source_code": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import size_check\nfrom weave.ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.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 random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.choice(choices) \n beg2 = random.choice(choices)\n end2 = random.choice(choices)\n step2 = random.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 random\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(random.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n\nif __name__ == \"__main__\":\n ScipyTest('weave.size_check').run()\n", "source_code_before": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import size_check\nfrom weave.ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n beg2 = whrandom.choice(choices)\n end2 = whrandom.choice(choices)\n step2 = whrandom.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(whrandom.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n\nif __name__ == \"__main__\":\n ScipyTest('weave.size_check').run()\n", "methods": [ { "name": "array_assert_equal", "long_name": "array_assert_equal( test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 17, "complexity": 3, "token_count": 120, "parameters": [ "test_string", "actual", "desired" ], "start_line": 17, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_scalar", "long_name": "check_x_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 49, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_scalar", "long_name": "check_y_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 53, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_short", "long_name": "check_x_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_short", "long_name": "check_y_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 61, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x1", "long_name": "check_x1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 84, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y1", "long_name": "check_y1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y", "long_name": "check_x_y( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y2", "long_name": "check_x_y2( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y3", "long_name": "check_x_y3( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y4", "long_name": "check_x_y4( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y5", "long_name": "check_x_y5( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y6", "long_name": "check_x_y6( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y7", "long_name": "check_x_y7( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 116, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_error2", "long_name": "check_error2( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 76, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 129, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 106, "parameters": [ "self", "x", "y", "desired" ], "start_line": 144, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val" ], "start_line": 162, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 166, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , ary , expr , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self", "ary", "expr", "desired" ], "start_line": 181, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , a , expr )", "filename": "test_size_check.py", "nloc": 9, "complexity": 3, "token_count": 59, "parameters": [ "self", "a", "expr" ], "start_line": 186, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generic_1d", "long_name": "generic_1d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self", "expr" ], "start_line": 196, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 199, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 202, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_1d_index", "long_name": "generic_1d_index( self , expr )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self", "expr" ], "start_line": 206, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1d_index_0", "long_name": "check_1d_index_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 211, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_1", "long_name": "check_1d_index_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_2", "long_name": "check_1d_index_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_3", "long_name": "check_1d_index_3( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_1d_index_calculated", "long_name": "check_1d_index_calculated( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 222, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_1", "long_name": "check_1d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 224, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_2", "long_name": "check_1d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_3", "long_name": "check_1d_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_4", "long_name": "check_1d_4( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 232, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_5", "long_name": "check_1d_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 234, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_6", "long_name": "check_1d_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 236, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_7", "long_name": "check_1d_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_8", "long_name": "check_1d_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 240, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_9", "long_name": "check_1d_9( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 242, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_10", "long_name": "check_1d_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 246, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_0", "long_name": "check_1d_stride_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 249, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_1", "long_name": "check_1d_stride_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 251, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_2", "long_name": "check_1d_stride_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_3", "long_name": "check_1d_stride_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 255, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_4", "long_name": "check_1d_stride_4( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 257, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_stride_5", "long_name": "check_1d_stride_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_6", "long_name": "check_1d_stride_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_7", "long_name": "check_1d_stride_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 265, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_8", "long_name": "check_1d_stride_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_9", "long_name": "check_1d_stride_9( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_10", "long_name": "check_1d_stride_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_11", "long_name": "check_1d_stride_11( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 273, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_12", "long_name": "check_1d_stride_12( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_random", "long_name": "check_1d_random( self )", "filename": "test_size_check.py", "nloc": 11, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 277, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 293, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_2", "long_name": "check_2d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_random", "long_name": "check_2d_random( self )", "filename": "test_size_check.py", "nloc": 15, "complexity": 3, "token_count": 120, "parameters": [ "self" ], "start_line": 297, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_3d_random", "long_name": "check_3d_random( self )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 314, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 330, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 335, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 340, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3d_0", "long_name": "check_3d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 345, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_error0", "long_name": "check_error0( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 350, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 364, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , desired , ** kw )", "filename": "test_size_check.py", "nloc": 20, "complexity": 6, "token_count": 117, "parameters": [ "self", "expr", "desired", "kw" ], "start_line": 379, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , expr , ** kw )", "filename": "test_size_check.py", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self", "expr", "kw" ], "start_line": 399, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_generic_1d", "long_name": "check_generic_1d( self )", "filename": "test_size_check.py", "nloc": 14, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 409, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 423, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_calculated_index", "long_name": "check_calculated_index( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 428, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_calculated_index2", "long_name": "check_calculated_index2( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 433, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 438, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 441, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "methods_before": [ { "name": "array_assert_equal", "long_name": "array_assert_equal( test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 17, "complexity": 3, "token_count": 120, "parameters": [ "test_string", "actual", "desired" ], "start_line": 17, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_scalar", "long_name": "check_x_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 49, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_scalar", "long_name": "check_y_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 53, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_short", "long_name": "check_x_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_short", "long_name": "check_y_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 61, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x1", "long_name": "check_x1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 84, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y1", "long_name": "check_y1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y", "long_name": "check_x_y( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y2", "long_name": "check_x_y2( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y3", "long_name": "check_x_y3( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y4", "long_name": "check_x_y4( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y5", "long_name": "check_x_y5( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y6", "long_name": "check_x_y6( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y7", "long_name": "check_x_y7( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 116, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_error2", "long_name": "check_error2( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 76, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 129, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 106, "parameters": [ "self", "x", "y", "desired" ], "start_line": 144, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val" ], "start_line": 162, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 166, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , ary , expr , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self", "ary", "expr", "desired" ], "start_line": 181, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , a , expr )", "filename": "test_size_check.py", "nloc": 9, "complexity": 3, "token_count": 59, "parameters": [ "self", "a", "expr" ], "start_line": 186, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generic_1d", "long_name": "generic_1d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self", "expr" ], "start_line": 196, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 199, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 202, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_1d_index", "long_name": "generic_1d_index( self , expr )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self", "expr" ], "start_line": 206, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1d_index_0", "long_name": "check_1d_index_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 211, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_1", "long_name": "check_1d_index_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_2", "long_name": "check_1d_index_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_3", "long_name": "check_1d_index_3( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_1d_index_calculated", "long_name": "check_1d_index_calculated( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 222, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_1", "long_name": "check_1d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 224, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_2", "long_name": "check_1d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_3", "long_name": "check_1d_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_4", "long_name": "check_1d_4( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 232, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_5", "long_name": "check_1d_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 234, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_6", "long_name": "check_1d_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 236, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_7", "long_name": "check_1d_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_8", "long_name": "check_1d_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 240, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_9", "long_name": "check_1d_9( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 242, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_10", "long_name": "check_1d_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 246, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_0", "long_name": "check_1d_stride_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 249, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_1", "long_name": "check_1d_stride_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 251, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_2", "long_name": "check_1d_stride_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_3", "long_name": "check_1d_stride_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 255, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_4", "long_name": "check_1d_stride_4( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 257, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_stride_5", "long_name": "check_1d_stride_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_6", "long_name": "check_1d_stride_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_7", "long_name": "check_1d_stride_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 265, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_8", "long_name": "check_1d_stride_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_9", "long_name": "check_1d_stride_9( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_10", "long_name": "check_1d_stride_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_11", "long_name": "check_1d_stride_11( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 273, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_12", "long_name": "check_1d_stride_12( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_random", "long_name": "check_1d_random( self )", "filename": "test_size_check.py", "nloc": 11, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 277, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 293, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_2", "long_name": "check_2d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_random", "long_name": "check_2d_random( self )", "filename": "test_size_check.py", "nloc": 15, "complexity": 3, "token_count": 120, "parameters": [ "self" ], "start_line": 297, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_3d_random", "long_name": "check_3d_random( self )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 314, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 330, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 335, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 340, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3d_0", "long_name": "check_3d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 345, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_error0", "long_name": "check_error0( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 350, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 364, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , desired , ** kw )", "filename": "test_size_check.py", "nloc": 20, "complexity": 6, "token_count": 117, "parameters": [ "self", "expr", "desired", "kw" ], "start_line": 379, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , expr , ** kw )", "filename": "test_size_check.py", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self", "expr", "kw" ], "start_line": 399, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_generic_1d", "long_name": "check_generic_1d( self )", "filename": "test_size_check.py", "nloc": 14, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 409, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 423, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_calculated_index", "long_name": "check_calculated_index( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 428, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_calculated_index2", "long_name": "check_calculated_index2( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 433, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 438, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 441, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "check_3d_random", "long_name": "check_3d_random( self )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 314, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_1d_random", "long_name": "check_1d_random( self )", "filename": "test_size_check.py", "nloc": 11, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 277, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_2d_random", "long_name": "check_2d_random( self )", "filename": "test_size_check.py", "nloc": 15, "complexity": 3, "token_count": 120, "parameters": [ "self" ], "start_line": 297, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 405, "complexity": 114, "token_count": 3031, "diff_parsed": { "added": [ " import random", " beg = random.choice(choices)", " end = random.choice(choices)", " step = random.choice(choices)", " import random", " beg = random.choice(choices)", " end = random.choice(choices)", " step = random.choice(choices)", " beg2 = random.choice(choices)", " end2 = random.choice(choices)", " step2 = random.choice(choices)", " import random", " idx.append(random.choice(choices))" ], "deleted": [ " import whrandom", " beg = whrandom.choice(choices)", " end = whrandom.choice(choices)", " step = whrandom.choice(choices)", " import whrandom", " beg = whrandom.choice(choices)", " end = whrandom.choice(choices)", " step = whrandom.choice(choices)", " beg2 = whrandom.choice(choices)", " end2 = whrandom.choice(choices)", " step2 = whrandom.choice(choices)", " import whrandom", " idx.append(whrandom.choice(choices))" ] } } ] }, { "hash": "3a8d4dcb68555a37ef31b2cdf0d09c50021be422", "msg": "Prepearing for the 0.3.2 release.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T11:02:08+00:00", "author_timezone": 0, "committer_date": "2004-10-07T11:02:08+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "68603ef3f6378c318c722e3bc44d581b1d9be894" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 5, "insertions": 5, "lines": 10, "files": 5, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/scipy_base_version.py", "new_path": "scipy_base/scipy_base_version.py", "filename": "scipy_base_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 1\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 1\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 2" ], "deleted": [ "micro = 1" ] } }, { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -308,7 +308,7 @@ def customize(self, dist=None):\n \n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n- if 0: # change to `if 1:` when making release.\n+ if 1: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 1: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 } ], "nloc": 650, "complexity": 176, "token_count": 4385, "diff_parsed": { "added": [ " if 1: # change to `if 1:` when making release." ], "deleted": [ " if 0: # change to `if 1:` when making release." ] } }, { "old_path": "scipy_distutils/scipy_distutils_version.py", "new_path": "scipy_distutils/scipy_distutils_version.py", "filename": "scipy_distutils_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 1\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 1\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 2" ], "deleted": [ "micro = 1" ] } }, { "old_path": "scipy_test/scipy_test_version.py", "new_path": "scipy_test/scipy_test_version.py", "filename": "scipy_test_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 1\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 1\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 2" ], "deleted": [ "micro = 1" ] } }, { "old_path": "weave/weave_version.py", "new_path": "weave/weave_version.py", "filename": "weave_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 1\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 1\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 2" ], "deleted": [ "micro = 1" ] } } ] }, { "hash": "dbc51126bb33edcd6455af1eab5b357753a6eb27", "msg": "Increased micro version number and undone 0.3.2 release.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T11:27:44+00:00", "author_timezone": 0, "committer_date": "2004-10-07T11:27:44+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3a8d4dcb68555a37ef31b2cdf0d09c50021be422" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 5, "insertions": 5, "lines": 10, "files": 5, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/scipy_base_version.py", "new_path": "scipy_base/scipy_base_version.py", "filename": "scipy_base_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 2\n+micro = 3\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 3" ], "deleted": [ "micro = 2" ] } }, { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -308,7 +308,7 @@ def customize(self, dist=None):\n \n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n- if 1: # change to `if 1:` when making release.\n+ if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 1: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 } ], "nloc": 650, "complexity": 176, "token_count": 4385, "diff_parsed": { "added": [ " if 0: # change to `if 1:` when making release." ], "deleted": [ " if 1: # change to `if 1:` when making release." ] } }, { "old_path": "scipy_distutils/scipy_distutils_version.py", "new_path": "scipy_distutils/scipy_distutils_version.py", "filename": "scipy_distutils_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 2\n+micro = 3\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 3" ], "deleted": [ "micro = 2" ] } }, { "old_path": "scipy_test/scipy_test_version.py", "new_path": "scipy_test/scipy_test_version.py", "filename": "scipy_test_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 2\n+micro = 3\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 3" ], "deleted": [ "micro = 2" ] } }, { "old_path": "weave/weave_version.py", "new_path": "weave/weave_version.py", "filename": "weave_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 2\n+micro = 3\n #release_level = 'alpha'\n release_level = ''\n try:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 18, "complexity": 0, "token_count": 72, "diff_parsed": { "added": [ "micro = 3" ], "deleted": [ "micro = 2" ] } } ] }, { "hash": "629c9a8a6f331d26dbadaaf4efb2e4e96b8a31e3", "msg": "Fixing 0.3.2 release branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T12:43:32+00:00", "author_timezone": 0, "committer_date": "2004-10-07T12:43:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "dbc51126bb33edcd6455af1eab5b357753a6eb27" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 29, "insertions": 57, "lines": 86, "files": 5, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/scipy_base_version.py", "new_path": "scipy_base/scipy_base_version.py", "filename": "scipy_base_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 3\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n@@ -8,13 +8,20 @@\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\n except ImportError,msg:\n- print msg\n cvs_minor = 0\n cvs_serial = 0\n \n-if release_level:\n- scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+if cvs_minor or cvs_serial:\n+ if release_level:\n+ scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ else:\n+ scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n- scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if release_level:\n+ scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ % (locals ())\n+ else:\n+ scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n", "added_lines": 14, "deleted_lines": 7, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n cvs_minor = 0\n cvs_serial = 0\n\nif cvs_minor or cvs_serial:\n if release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n if release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\n else:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 25, "complexity": 0, "token_count": 102, "diff_parsed": { "added": [ "micro = 2", "if cvs_minor or cvs_serial:", " if release_level:", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " else:", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " if release_level:", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " % (locals ())", " else:", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\", " % (locals ())" ], "deleted": [ "micro = 3", " print msg", "if release_level:", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " scipy_base_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -308,7 +308,7 @@ def customize(self, dist=None):\n \n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n- if 0: # change to `if 1:` when making release.\n+ if 1: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 1: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 } ], "nloc": 650, "complexity": 176, "token_count": 4385, "diff_parsed": { "added": [ " if 1: # change to `if 1:` when making release." ], "deleted": [ " if 0: # change to `if 1:` when making release." ] } }, { "old_path": "scipy_distutils/scipy_distutils_version.py", "new_path": "scipy_distutils/scipy_distutils_version.py", "filename": "scipy_distutils_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 3\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n@@ -8,13 +8,20 @@\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\n except ImportError,msg:\n- print msg\n cvs_minor = 0\n cvs_serial = 0\n \n-if release_level:\n- scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+if cvs_minor or cvs_serial:\n+ if release_level:\n+ scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ else:\n+ scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n- scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if release_level:\n+ scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ % (locals ())\n+ else:\n+ scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n", "added_lines": 14, "deleted_lines": 7, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n cvs_minor = 0\n cvs_serial = 0\n\nif cvs_minor or cvs_serial:\n if release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n if release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\n else:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 25, "complexity": 0, "token_count": 102, "diff_parsed": { "added": [ "micro = 2", "if cvs_minor or cvs_serial:", " if release_level:", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " else:", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " if release_level:", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " % (locals ())", " else:", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\", " % (locals ())" ], "deleted": [ "micro = 3", " print msg", "if release_level:", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " scipy_distutils_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "scipy_test/scipy_test_version.py", "new_path": "scipy_test/scipy_test_version.py", "filename": "scipy_test_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 3\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n@@ -8,13 +8,20 @@\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\n except ImportError,msg:\n- print msg\n cvs_minor = 0\n cvs_serial = 0\n \n-if release_level:\n- scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+if cvs_minor or cvs_serial:\n+ if release_level:\n+ scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ else:\n+ scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n- scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if release_level:\n+ scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ % (locals ())\n+ else:\n+ scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n", "added_lines": 14, "deleted_lines": 7, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n cvs_minor = 0\n cvs_serial = 0\n\nif cvs_minor or cvs_serial:\n if release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n if release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\n else:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 25, "complexity": 0, "token_count": 102, "diff_parsed": { "added": [ "micro = 2", "if cvs_minor or cvs_serial:", " if release_level:", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " else:", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " if release_level:", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " % (locals ())", " else:", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\", " % (locals ())" ], "deleted": [ "micro = 3", " print msg", "if release_level:", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " scipy_test_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } }, { "old_path": "weave/weave_version.py", "new_path": "weave/weave_version.py", "filename": "weave_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 3\n-micro = 3\n+micro = 2\n #release_level = 'alpha'\n release_level = ''\n try:\n@@ -8,13 +8,20 @@\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\n except ImportError,msg:\n- print msg\n cvs_minor = 0\n cvs_serial = 0\n \n-if release_level:\n- weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+if cvs_minor or cvs_serial:\n+ if release_level:\n+ weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ else:\n+ weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n- weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if release_level:\n+ weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ % (locals ())\n+ else:\n+ weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n", "added_lines": 14, "deleted_lines": 7, "source_code": "major = 0\nminor = 3\nmicro = 2\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n cvs_minor = 0\n cvs_serial = 0\n\nif cvs_minor or cvs_serial:\n if release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n if release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\n else:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", "source_code_before": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n print msg\n cvs_minor = 0\n cvs_serial = 0\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 25, "complexity": 0, "token_count": 102, "diff_parsed": { "added": [ "micro = 2", "if cvs_minor or cvs_serial:", " if release_level:", " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " else:", " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " if release_level:", " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " % (locals ())", " else:", " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", " % (locals ())" ], "deleted": [ "micro = 3", " print msg", "if release_level:", " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } } ] }, { "hash": "fd66cf94a14d8291fc5028b8e82eb086893dc21d", "msg": "Fixing 0.3.2 release branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T12:55:18+00:00", "author_timezone": 0, "committer_date": "2004-10-07T12:55:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "629c9a8a6f331d26dbadaaf4efb2e4e96b8a31e3" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 6, "insertions": 15, "lines": 21, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -49,13 +49,22 @@ def setup_package():\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n \n- if release_level:\n- scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if cvs_minor or cvs_serial:\n+ if release_level:\n+ scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ else:\n+ scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n- scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+ if release_level:\n+ scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ '_%(release_level)s'\\\n+ % (locals ())\n+ else:\n+ scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n \n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n", "added_lines": 15, "deleted_lines": 6, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n weave\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration(parent_path=local_path))\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n release_level = ''\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n if cvs_minor or cvs_serial:\n if release_level:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n if release_level:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n % (locals ())\n else:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n weave\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration(parent_path=local_path))\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n release_level = ''\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n if release_level:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 53, "complexity": 14, "token_count": 360, "parameters": [], "start_line": 23, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 44, "complexity": 11, "token_count": 326, "parameters": [], "start_line": 23, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 53, "complexity": 14, "token_count": 360, "parameters": [], "start_line": 23, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 } ], "nloc": 72, "complexity": 14, "token_count": 405, "diff_parsed": { "added": [ " if cvs_minor or cvs_serial:", " if release_level:", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " else:", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " if release_level:", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(release_level)s'\\", " % (locals ())", " else:", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " % (locals ())" ], "deleted": [ " if release_level:", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", " scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())" ] } } ] }, { "hash": "1638e8adc9d4c2350f4e3e1028c10d6a8072939f", "msg": "Improve resource detection when prefix is given in env. variable.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T20:55:02+00:00", "author_timezone": 0, "committer_date": "2004-10-07T20:55:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fd66cf94a14d8291fc5028b8e82eb086893dc21d" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 8, "insertions": 11, "lines": 19, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.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": "@@ -356,7 +356,16 @@ def get_paths(self, section, key):\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n- dirs = d.split(os.pathsep) + dirs\n+ ds = d.split(os.pathsep)\n+ ds2 = []\n+ for d in ds:\n+ if os.path.isdir(d):\n+ ds2.append(d)\n+ for dd in ['include','lib']:\n+ d1 = os.path.join(d,dd)\n+ if os.path.isdir(d1):\n+ ds2.append(d1)\n+ dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n@@ -634,16 +643,10 @@ def calc_info(self):\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n- atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n- lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n- if atlas:\n- atlas_1 = atlas\n- print self.__class__\n- if atlas is None:\n- atlas = atlas_1\n+ break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n", "added_lines": 11, "deleted_lines": 8, "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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n ds = d.split(os.pathsep)\n ds2 = []\n for d in ds:\n if os.path.isdir(d):\n ds2.append(d)\n for dd in ['include','lib']:\n d1 = os.path.join(d,dd)\n if os.path.isdir(d1):\n ds2.append(d1)\n dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n dirs = d.split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 377, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 380, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 393, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 420, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 445, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 512, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 519, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 548, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 556, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 640, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 682, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 708, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 816, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 811, "end_line": 865, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 67, "complexity": 18, "token_count": 431, "parameters": [ "self" ], "start_line": 870, "end_line": 944, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 75, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 949, "end_line": 1002, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1011, "end_line": 1023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1031, "end_line": 1036, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1038, "end_line": 1073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1079, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1084, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1110, "end_line": 1131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1133, "end_line": 1161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1171, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1178, "end_line": 1198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1204, "end_line": 1209, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1211, "end_line": 1233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1245, "end_line": 1248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1249, "end_line": 1252, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1254, "end_line": 1307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1376, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1404, "end_line": 1420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1422, "end_line": 1430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 26, "complexity": 11, "token_count": 276, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 368, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 371, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 374, "end_line": 375, "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": 377, "end_line": 382, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 384, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 397, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 407, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 411, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 433, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 436, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 503, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 510, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 539, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 547, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 27, "complexity": 8, "token_count": 176, "parameters": [ "self" ], "start_line": 631, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 679, "end_line": 691, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 698, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 705, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 813, "end_line": 822, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 808, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 67, "complexity": 18, "token_count": 431, "parameters": [ "self" ], "start_line": 867, "end_line": 941, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 75, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 946, "end_line": 999, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1008, "end_line": 1020, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1028, "end_line": 1033, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1035, "end_line": 1070, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1076, "end_line": 1079, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1081, "end_line": 1100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1107, "end_line": 1128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1130, "end_line": 1158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1168, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1175, "end_line": 1195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1201, "end_line": 1206, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1208, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1242, "end_line": 1245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1246, "end_line": 1249, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1251, "end_line": 1304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1373, "end_line": 1397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1401, "end_line": 1417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1419, "end_line": 1427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 640, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 } ], "nloc": 1266, "complexity": 263, "token_count": 6995, "diff_parsed": { "added": [ " ds = d.split(os.pathsep)", " ds2 = []", " for d in ds:", " if os.path.isdir(d):", " ds2.append(d)", " for dd in ['include','lib']:", " d1 = os.path.join(d,dd)", " if os.path.isdir(d1):", " ds2.append(d1)", " dirs = ds2 + dirs", " break" ], "deleted": [ " dirs = d.split(os.pathsep) + dirs", " atlas_1 = None", " lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]", " if atlas:", " atlas_1 = atlas", " print self.__class__", " if atlas is None:", " atlas = atlas_1" ] } } ] }, { "hash": "f25ec90c77c0631e5bf29aac1ef37ae39e60ebd9", "msg": "Merge from v0_3_2 branch.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-07T21:06:43+00:00", "author_timezone": 0, "committer_date": "2004-10-07T21:06:43+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": true, "parents": [ "dbc51126bb33edcd6455af1eab5b357753a6eb27", "1638e8adc9d4c2350f4e3e1028c10d6a8072939f" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 8, "insertions": 11, "lines": 19, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null }, { "hash": "f42b743431beed95b0b354e091133b66aecd50f0", "msg": "Fixed from_template so it doesn't lowercase automatically", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2004-10-12T16:36:26+00:00", "author_timezone": 0, "committer_date": "2004-10-12T16:36:26+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f25ec90c77c0631e5bf29aac1ef37ae39e60ebd9" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 18, "insertions": 8, "lines": 26, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/from_template.py", "new_path": "scipy_distutils/from_template.py", "filename": "from_template.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -40,9 +40,10 @@\n # These don't work with Python2.3 : maximum recursion limit exceeded.\n #subroutine_exp = re.compile(r'subroutine (?:\\s|.)*?end subroutine.*')\n #function_exp = re.compile(r'function (?:\\s|.)*?end function.*')\n-reg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")\n+#reg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")\n \n def parse_structure(astr):\n+ astr = astr.lower()\n spanlist = []\n # subroutines\n ind = 0\n@@ -86,7 +87,7 @@ def parse_structure(astr):\n \n def conv(astr):\n b = astr.split(',')\n- return ','.join([x.strip().lower() for x in b])\n+ return ','.join([x.strip() for x in b])\n \n def unique_key(adict):\n # this obtains a unique key given a dictionary\n@@ -129,7 +130,7 @@ def expand_sub(substr,extra=''):\n _names.update(_special_names)\n numsubs = None\n for rep in reps:\n- name = rep[0].strip().lower()\n+ name = rep[0].strip()\n thelist = conv(rep[1])\n _names[name] = thelist\n \n@@ -172,20 +173,9 @@ def get_line_header(str,beg):\n ind = ind - 1\n char = str[ind]\n return ''.join(extra)\n-\n-maxre = re.compile(r\"max[(](.+),(.+)[)]\")\n-minre = re.compile(r\"min[(](.+),(.+)[)]\")\n-\n-def fix_capitals(astr):\n- # Need to convert max(x,x) to MAX(x,x)\n- # and min(x,x) to MIN(x,x)\n- astr = maxre.sub(r\"MAX(\\g<1>,\\g<2>)\",astr)\n- astr = minre.sub(r\"MIN(\\g<1>,\\g<2>)\",astr)\n- return astr\n- \n \n def process_str(allstr):\n- newstr = allstr.lower()\n+ newstr = allstr\n writestr = _head\n \n struct = parse_structure(newstr)\n@@ -194,13 +184,13 @@ def process_str(allstr):\n \n oldend = 0\n for sub in struct:\n- writestr += fix_capitals(newstr[oldend:sub[0]])\n+ writestr += newstr[oldend:sub[0]]\n expanded = expand_sub(newstr[sub[0]:sub[1]],get_line_header(newstr,sub[0]))\n- writestr += fix_capitals(expanded)\n+ writestr += expanded\n oldend = sub[1]\n \n \n- writestr += fix_capitals(newstr[oldend:])\n+ writestr += newstr[oldend:]\n return writestr\n \n \n", "added_lines": 8, "deleted_lines": 18, "source_code": "#!/usr/bin/python\n\n# takes templated file .xxx.src and produces .xxx file where .xxx is .pyf .f90 or .f\n# using the following template rules\n\n# <...> is the template All blocks in a source file with names that\n# contain '<..>' will be replicated according to the\n# rules in '<..>'.\n\n# The number of comma-separeted words in '<..>' will determine the number of\n# replicates.\n \n# '<..>' may have two different forms, named and short. For example,\n\n#named:\n# where anywhere inside a block '

' will be replaced with\n# 'd', 's', 'z', and 'c' for each replicate of the block.\n\n# <_c> is already defined: <_c=s,d,c,z>\n# <_t> is already defined: <_t=real,double precision,complex,double complex>\n\n#short:\n# , a short form of the named, useful when no

appears inside \n# a block.\n\n# Note that all <..> forms in a block must have the same number of\n# comma-separated entries. \n\n__all__ = ['process_str']\n\nimport string,os,sys\nif sys.version[:3]>='2.3':\n import re\nelse:\n import pre as re\n False = 0\n True = 1\n\ncomment_block_exp = re.compile(r'/\\*.*?\\*/',re.DOTALL)\n# These don't work with Python2.3 : maximum recursion limit exceeded.\n#subroutine_exp = re.compile(r'subroutine (?:\\s|.)*?end subroutine.*')\n#function_exp = re.compile(r'function (?:\\s|.)*?end function.*')\n#reg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")\n\ndef parse_structure(astr):\n astr = astr.lower()\n spanlist = []\n # subroutines\n ind = 0\n while 1:\n start = astr.find(\"subroutine\", ind)\n if start == -1:\n break\n fini1 = astr.find(\"end subroutine\",start)\n fini2 = astr.find(\"\\n\",fini1)\n spanlist.append((start, fini2))\n ind = fini2\n\n # functions\n ind = 0\n while 1:\n start = astr.find(\"function\", ind)\n if start == -1:\n break\n pre = astr.rfind(\"\\n\", ind, start)\n presave = start\n # look for \"$\" in previous lines\n while '$' in astr[pre:presave]:\n presave = pre\n pre = astr.rfind(\"\\n\", ind, pre-1)\n \n fini1 = astr.find(\"end function\",start)\n fini2 = astr.find(\"\\n\",fini1)\n spanlist.append((pre+1, fini2))\n ind = fini2\n\n spanlist.sort()\n return spanlist\n\n# return n copies of substr with template replacement\n_special_names = {'_c':'s,d,c,z',\n '_t':'real,double precision,complex,double complex'\n }\ntemplate_re = re.compile(r\"<([\\w]*)>\")\nnamed_re = re.compile(r\"<([\\w]*)=([, \\w]*)>\")\nlist_re = re.compile(r\"<([\\w ]+(,\\s*[\\w]+)+)>\")\n\ndef conv(astr):\n b = astr.split(',')\n return ','.join([x.strip() for x in b])\n\ndef unique_key(adict):\n # this obtains a unique key given a dictionary\n # currently it works by appending together n of the letters of the\n # current keys and increasing n until a unique key is found\n # -- not particularly quick\n allkeys = adict.keys()\n done = False\n n = 1\n while not done:\n newkey = \"\".join([x[:n] for x in allkeys])\n if newkey in allkeys:\n n += 1\n else:\n done = True\n return newkey\n\ndef listrepl(match):\n global _names\n thelist = conv(match.group(1))\n name = None\n for key in _names.keys(): # see if list is already in dictionary\n if _names[key] == thelist:\n name = key\n if name is None: # this list is not in the dictionary yet\n name = \"%s\" % unique_key(_names)\n _names[name] = thelist\n return \"<%s>\" % name\n\ndef namerepl(match):\n global _names, _thissub\n name = match.group(1)\n return _names[name][_thissub]\n\ndef expand_sub(substr,extra=''):\n global _names, _thissub\n # find all named replacements\n reps = named_re.findall(substr)\n _names = {}\n _names.update(_special_names)\n numsubs = None\n for rep in reps:\n name = rep[0].strip()\n thelist = conv(rep[1])\n _names[name] = thelist\n\n substr = named_re.sub(r\"<\\1>\",substr) # get rid of definition templates\n substr = list_re.sub(listrepl, substr) # convert all lists to named templates\n # newnames are constructed as needed\n\n # make lists out of string entries in name dictionary\n for name in _names.keys():\n entry = _names[name]\n entrylist = entry.split(',')\n _names[name] = entrylist\n num = len(entrylist)\n if numsubs is None:\n numsubs = num\n elif (numsubs != num):\n raise ValueError, \"Mismatch in number to replace\"\n\n # now replace all keys for each of the lists\n mystr = ''\n for k in range(numsubs):\n _thissub = k\n mystr += template_re.sub(namerepl, substr)\n mystr += \"\\n\\n\" + extra\n return mystr\n\n_head = \\\n\"\"\"C This file was autogenerated from a template DO NOT EDIT!!!!\nC Changes should be made to the original source (.src) file\nC\n\n\"\"\"\n\ndef get_line_header(str,beg):\n extra = []\n ind = beg-1\n char = str[ind]\n while (ind > 0) and (char != '\\n'):\n extra.insert(0,char)\n ind = ind - 1\n char = str[ind]\n return ''.join(extra)\n \ndef process_str(allstr):\n newstr = allstr\n writestr = _head\n\n struct = parse_structure(newstr)\n # return a (sorted) list of tuples for each function or subroutine\n # each tuple is the start and end of a subroutine or function to be expanded\n \n oldend = 0\n for sub in struct:\n writestr += newstr[oldend:sub[0]]\n expanded = expand_sub(newstr[sub[0]:sub[1]],get_line_header(newstr,sub[0]))\n writestr += expanded\n oldend = sub[1]\n\n\n writestr += newstr[oldend:]\n return writestr\n\n\nif __name__ == \"__main__\":\n\n try:\n file = sys.argv[1]\n except IndexError:\n fid = sys.stdin\n outfile = sys.stdout\n else:\n fid = open(file,'r')\n (base, ext) = os.path.splitext(file)\n newname = base\n outfile = open(newname,'w')\n\n allstr = fid.read()\n writestr = process_str(allstr)\n outfile.write(writestr)\n", "source_code_before": "#!/usr/bin/python\n\n# takes templated file .xxx.src and produces .xxx file where .xxx is .pyf .f90 or .f\n# using the following template rules\n\n# <...> is the template All blocks in a source file with names that\n# contain '<..>' will be replicated according to the\n# rules in '<..>'.\n\n# The number of comma-separeted words in '<..>' will determine the number of\n# replicates.\n \n# '<..>' may have two different forms, named and short. For example,\n\n#named:\n# where anywhere inside a block '

' will be replaced with\n# 'd', 's', 'z', and 'c' for each replicate of the block.\n\n# <_c> is already defined: <_c=s,d,c,z>\n# <_t> is already defined: <_t=real,double precision,complex,double complex>\n\n#short:\n# , a short form of the named, useful when no

appears inside \n# a block.\n\n# Note that all <..> forms in a block must have the same number of\n# comma-separated entries. \n\n__all__ = ['process_str']\n\nimport string,os,sys\nif sys.version[:3]>='2.3':\n import re\nelse:\n import pre as re\n False = 0\n True = 1\n\ncomment_block_exp = re.compile(r'/\\*.*?\\*/',re.DOTALL)\n# These don't work with Python2.3 : maximum recursion limit exceeded.\n#subroutine_exp = re.compile(r'subroutine (?:\\s|.)*?end subroutine.*')\n#function_exp = re.compile(r'function (?:\\s|.)*?end function.*')\nreg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")\n\ndef parse_structure(astr):\n spanlist = []\n # subroutines\n ind = 0\n while 1:\n start = astr.find(\"subroutine\", ind)\n if start == -1:\n break\n fini1 = astr.find(\"end subroutine\",start)\n fini2 = astr.find(\"\\n\",fini1)\n spanlist.append((start, fini2))\n ind = fini2\n\n # functions\n ind = 0\n while 1:\n start = astr.find(\"function\", ind)\n if start == -1:\n break\n pre = astr.rfind(\"\\n\", ind, start)\n presave = start\n # look for \"$\" in previous lines\n while '$' in astr[pre:presave]:\n presave = pre\n pre = astr.rfind(\"\\n\", ind, pre-1)\n \n fini1 = astr.find(\"end function\",start)\n fini2 = astr.find(\"\\n\",fini1)\n spanlist.append((pre+1, fini2))\n ind = fini2\n\n spanlist.sort()\n return spanlist\n\n# return n copies of substr with template replacement\n_special_names = {'_c':'s,d,c,z',\n '_t':'real,double precision,complex,double complex'\n }\ntemplate_re = re.compile(r\"<([\\w]*)>\")\nnamed_re = re.compile(r\"<([\\w]*)=([, \\w]*)>\")\nlist_re = re.compile(r\"<([\\w ]+(,\\s*[\\w]+)+)>\")\n\ndef conv(astr):\n b = astr.split(',')\n return ','.join([x.strip().lower() for x in b])\n\ndef unique_key(adict):\n # this obtains a unique key given a dictionary\n # currently it works by appending together n of the letters of the\n # current keys and increasing n until a unique key is found\n # -- not particularly quick\n allkeys = adict.keys()\n done = False\n n = 1\n while not done:\n newkey = \"\".join([x[:n] for x in allkeys])\n if newkey in allkeys:\n n += 1\n else:\n done = True\n return newkey\n\ndef listrepl(match):\n global _names\n thelist = conv(match.group(1))\n name = None\n for key in _names.keys(): # see if list is already in dictionary\n if _names[key] == thelist:\n name = key\n if name is None: # this list is not in the dictionary yet\n name = \"%s\" % unique_key(_names)\n _names[name] = thelist\n return \"<%s>\" % name\n\ndef namerepl(match):\n global _names, _thissub\n name = match.group(1)\n return _names[name][_thissub]\n\ndef expand_sub(substr,extra=''):\n global _names, _thissub\n # find all named replacements\n reps = named_re.findall(substr)\n _names = {}\n _names.update(_special_names)\n numsubs = None\n for rep in reps:\n name = rep[0].strip().lower()\n thelist = conv(rep[1])\n _names[name] = thelist\n\n substr = named_re.sub(r\"<\\1>\",substr) # get rid of definition templates\n substr = list_re.sub(listrepl, substr) # convert all lists to named templates\n # newnames are constructed as needed\n\n # make lists out of string entries in name dictionary\n for name in _names.keys():\n entry = _names[name]\n entrylist = entry.split(',')\n _names[name] = entrylist\n num = len(entrylist)\n if numsubs is None:\n numsubs = num\n elif (numsubs != num):\n raise ValueError, \"Mismatch in number to replace\"\n\n # now replace all keys for each of the lists\n mystr = ''\n for k in range(numsubs):\n _thissub = k\n mystr += template_re.sub(namerepl, substr)\n mystr += \"\\n\\n\" + extra\n return mystr\n\n_head = \\\n\"\"\"C This file was autogenerated from a template DO NOT EDIT!!!!\nC Changes should be made to the original source (.src) file\nC\n\n\"\"\"\n\ndef get_line_header(str,beg):\n extra = []\n ind = beg-1\n char = str[ind]\n while (ind > 0) and (char != '\\n'):\n extra.insert(0,char)\n ind = ind - 1\n char = str[ind]\n return ''.join(extra)\n\nmaxre = re.compile(r\"max[(](.+),(.+)[)]\")\nminre = re.compile(r\"min[(](.+),(.+)[)]\")\n\ndef fix_capitals(astr):\n # Need to convert max(x,x) to MAX(x,x)\n # and min(x,x) to MIN(x,x)\n astr = maxre.sub(r\"MAX(\\g<1>,\\g<2>)\",astr)\n astr = minre.sub(r\"MIN(\\g<1>,\\g<2>)\",astr)\n return astr\n \n \ndef process_str(allstr):\n newstr = allstr.lower()\n writestr = _head\n\n struct = parse_structure(newstr)\n # return a (sorted) list of tuples for each function or subroutine\n # each tuple is the start and end of a subroutine or function to be expanded\n \n oldend = 0\n for sub in struct:\n writestr += fix_capitals(newstr[oldend:sub[0]])\n expanded = expand_sub(newstr[sub[0]:sub[1]],get_line_header(newstr,sub[0]))\n writestr += fix_capitals(expanded)\n oldend = sub[1]\n\n\n writestr += fix_capitals(newstr[oldend:])\n return writestr\n\n\nif __name__ == \"__main__\":\n\n try:\n file = sys.argv[1]\n except IndexError:\n fid = sys.stdin\n outfile = sys.stdout\n else:\n fid = open(file,'r')\n (base, ext) = os.path.splitext(file)\n newname = base\n outfile = open(newname,'w')\n\n allstr = fid.read()\n writestr = process_str(allstr)\n outfile.write(writestr)\n", "methods": [ { "name": "parse_structure", "long_name": "parse_structure( astr )", "filename": "from_template.py", "nloc": 28, "complexity": 6, "token_count": 179, "parameters": [ "astr" ], "start_line": 45, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "conv", "long_name": "conv( astr )", "filename": "from_template.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "astr" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "unique_key", "long_name": "unique_key( adict )", "filename": "from_template.py", "nloc": 11, "complexity": 4, "token_count": 55, "parameters": [ "adict" ], "start_line": 92, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "listrepl", "long_name": "listrepl( match )", "filename": "from_template.py", "nloc": 11, "complexity": 4, "token_count": 64, "parameters": [ "match" ], "start_line": 108, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "namerepl", "long_name": "namerepl( match )", "filename": "from_template.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "match" ], "start_line": 120, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "expand_sub", "long_name": "expand_sub( substr , extra = '' )", "filename": "from_template.py", "nloc": 27, "complexity": 6, "token_count": 170, "parameters": [ "substr", "extra" ], "start_line": 125, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "get_line_header", "long_name": "get_line_header( str , beg )", "filename": "from_template.py", "nloc": 9, "complexity": 3, "token_count": 61, "parameters": [ "str", "beg" ], "start_line": 167, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "process_str", "long_name": "process_str( allstr )", "filename": "from_template.py", "nloc": 12, "complexity": 2, "token_count": 81, "parameters": [ "allstr" ], "start_line": 177, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "methods_before": [ { "name": "parse_structure", "long_name": "parse_structure( astr )", "filename": "from_template.py", "nloc": 27, "complexity": 6, "token_count": 172, "parameters": [ "astr" ], "start_line": 45, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "conv", "long_name": "conv( astr )", "filename": "from_template.py", "nloc": 3, "complexity": 2, "token_count": 34, "parameters": [ "astr" ], "start_line": 87, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "unique_key", "long_name": "unique_key( adict )", "filename": "from_template.py", "nloc": 11, "complexity": 4, "token_count": 55, "parameters": [ "adict" ], "start_line": 91, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "listrepl", "long_name": "listrepl( match )", "filename": "from_template.py", "nloc": 11, "complexity": 4, "token_count": 64, "parameters": [ "match" ], "start_line": 107, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "namerepl", "long_name": "namerepl( match )", "filename": "from_template.py", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "match" ], "start_line": 119, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "expand_sub", "long_name": "expand_sub( substr , extra = '' )", "filename": "from_template.py", "nloc": 27, "complexity": 6, "token_count": 174, "parameters": [ "substr", "extra" ], "start_line": 124, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "get_line_header", "long_name": "get_line_header( str , beg )", "filename": "from_template.py", "nloc": 9, "complexity": 3, "token_count": 61, "parameters": [ "str", "beg" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "fix_capitals", "long_name": "fix_capitals( astr )", "filename": "from_template.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "astr" ], "start_line": 179, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "process_str", "long_name": "process_str( allstr )", "filename": "from_template.py", "nloc": 12, "complexity": 2, "token_count": 94, "parameters": [ "allstr" ], "start_line": 187, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "parse_structure", "long_name": "parse_structure( astr )", "filename": "from_template.py", "nloc": 28, "complexity": 6, "token_count": 179, "parameters": [ "astr" ], "start_line": 45, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "conv", "long_name": "conv( astr )", "filename": "from_template.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "astr" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "process_str", "long_name": "process_str( allstr )", "filename": "from_template.py", "nloc": 12, "complexity": 2, "token_count": 81, "parameters": [ "allstr" ], "start_line": 177, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "expand_sub", "long_name": "expand_sub( substr , extra = '' )", "filename": "from_template.py", "nloc": 27, "complexity": 6, "token_count": 170, "parameters": [ "substr", "extra" ], "start_line": 125, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 }, { "name": "fix_capitals", "long_name": "fix_capitals( astr )", "filename": "from_template.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "astr" ], "start_line": 179, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 140, "complexity": 28, "token_count": 846, "diff_parsed": { "added": [ "#reg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")", " astr = astr.lower()", " return ','.join([x.strip() for x in b])", " name = rep[0].strip()", " newstr = allstr", " writestr += newstr[oldend:sub[0]]", " writestr += expanded", " writestr += newstr[oldend:]" ], "deleted": [ "reg = re.compile(r\"\\ssubroutine\\s(.+)\\(.*\\)\")", " return ','.join([x.strip().lower() for x in b])", " name = rep[0].strip().lower()", "", "maxre = re.compile(r\"max[(](.+),(.+)[)]\")", "minre = re.compile(r\"min[(](.+),(.+)[)]\")", "", "def fix_capitals(astr):", " # Need to convert max(x,x) to MAX(x,x)", " # and min(x,x) to MIN(x,x)", " astr = maxre.sub(r\"MAX(\\g<1>,\\g<2>)\",astr)", " astr = minre.sub(r\"MIN(\\g<1>,\\g<2>)\",astr)", " return astr", "", " newstr = allstr.lower()", " writestr += fix_capitals(newstr[oldend:sub[0]])", " writestr += fix_capitals(expanded)", " writestr += fix_capitals(newstr[oldend:])" ] } } ] }, { "hash": "8a844dd8e0bbb5168884d5ea9f6e37fc6275104a", "msg": "removed \"file changed\" print statement", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2004-10-13T06:31:29+00:00", "author_timezone": 0, "committer_date": "2004-10-13T06:31:29+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f42b743431beed95b0b354e091133b66aecd50f0" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 3, "insertions": 2, "lines": 5, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -206,13 +206,13 @@ def arg_specs(self):\n return all_arg_specs\n \n def build_information(self):\n- info = [self.customize] + self._build_information + \\\n+ info = self._build_information + [self.customize] + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n- i.set_compiler(self.compiler)\n+ i.set_compiler(self.compiler\n return info\n \n def get_headers(self):\n@@ -357,7 +357,6 @@ def generate_module(module_string, module_file):\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n- print 'file changed'\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n", "added_lines": 2, "deleted_lines": 3, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = self._build_information + [self.customize] + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n print 'file changed'\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 56, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 13, "complexity": 4, "token_count": 73, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 365, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 402, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 438, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 366, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 403, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 439, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 56, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 328, "complexity": 78, "token_count": 2127, "diff_parsed": { "added": [ " info = self._build_information + [self.customize] + \\", " i.set_compiler(self.compiler" ], "deleted": [ " info = [self.customize] + self._build_information + \\", " i.set_compiler(self.compiler)", " print 'file changed'" ] } } ] }, { "hash": "2c408050c127c8155b36ac61e0e3d0e095dd1f1e", "msg": "BUG: Add missing right parenthesis.", "author": { "name": "prabhu", "email": "prabhu@localhost" }, "committer": { "name": "prabhu", "email": "prabhu@localhost" }, "author_date": "2004-10-13T07:41:34+00:00", "author_timezone": 0, "committer_date": "2004-10-13T07:41:34+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8a844dd8e0bbb5168884d5ea9f6e37fc6275104a" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -212,7 +212,7 @@ def build_information(self):\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n- i.set_compiler(self.compiler\n+ i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = self._build_information + [self.customize] + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = self._build_information + [self.customize] + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 13, "complexity": 4, "token_count": 73, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 365, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 402, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 438, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 56, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 13, "complexity": 4, "token_count": 73, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 365, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 402, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 431, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 438, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 328, "complexity": 78, "token_count": 2128, "diff_parsed": { "added": [ " i.set_compiler(self.compiler)" ], "deleted": [ " i.set_compiler(self.compiler" ] } } ] }, { "hash": "99f4811d4fae485fd1b5be8a8d6410c5cb21071a", "msg": "Fixed undefined symbol error in importing atlas_version ext. module when using 3.2.1_pre3.3.6 atlas libraries.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-15T12:00:09+00:00", "author_timezone": 0, "committer_date": "2004-10-15T12:00:09+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2c408050c127c8155b36ac61e0e3d0e095dd1f1e" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 2, "lines": 2, "files": 1, "dmm_unit_size": 0.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": "@@ -903,6 +903,8 @@ def calc_info(self):\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n+\t\tif atlas_version=='3.2.1_pre3.3.6':\n+\t\t atlas_info['define_macros'].append(('NO_ATLAS_INFO',4))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n", "added_lines": 2, "deleted_lines": 0, "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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n ds = d.split(os.pathsep)\n ds2 = []\n for d in ds:\n if os.path.isdir(d):\n ds2.append(d)\n for dd in ['include','lib']:\n d1 = os.path.join(d,dd)\n if os.path.isdir(d1):\n ds2.append(d1)\n dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n\t\tif atlas_version=='3.2.1_pre3.3.6':\n\t\t atlas_info['define_macros'].append(('NO_ATLAS_INFO',4))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n ds = d.split(os.pathsep)\n ds2 = []\n for d in ds:\n if os.path.isdir(d):\n ds2.append(d)\n for dd in ['include','lib']:\n d1 = os.path.join(d,dd)\n if os.path.isdir(d1):\n ds2.append(d1)\n dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 377, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 380, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 393, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 420, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 445, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 512, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 519, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 548, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 556, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 640, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 682, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 708, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 816, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 811, "end_line": 865, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 69, "complexity": 19, "token_count": 449, "parameters": [ "self" ], "start_line": 870, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 951, "end_line": 1004, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1013, "end_line": 1025, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1033, "end_line": 1038, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1040, "end_line": 1075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1081, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1086, "end_line": 1105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1112, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1135, "end_line": 1163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1173, "end_line": 1178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1180, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1206, "end_line": 1211, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1213, "end_line": 1235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1247, "end_line": 1250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1251, "end_line": 1254, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1256, "end_line": 1309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1378, "end_line": 1402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1406, "end_line": 1422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1424, "end_line": 1432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 377, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 380, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 393, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 420, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 445, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 512, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 519, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 548, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 556, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 640, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 682, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 708, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 816, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 811, "end_line": 865, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 67, "complexity": 18, "token_count": 431, "parameters": [ "self" ], "start_line": 870, "end_line": 944, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 75, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 949, "end_line": 1002, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1011, "end_line": 1023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1031, "end_line": 1036, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1038, "end_line": 1073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1079, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1084, "end_line": 1103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1110, "end_line": 1131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1133, "end_line": 1161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1171, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1178, "end_line": 1198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1204, "end_line": 1209, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1211, "end_line": 1233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1245, "end_line": 1248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1249, "end_line": 1252, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1254, "end_line": 1307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1376, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1404, "end_line": 1420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1422, "end_line": 1430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 69, "complexity": 19, "token_count": 449, "parameters": [ "self" ], "start_line": 870, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 } ], "nloc": 1268, "complexity": 264, "token_count": 7013, "diff_parsed": { "added": [ "\t\tif atlas_version=='3.2.1_pre3.3.6':", "\t\t atlas_info['define_macros'].append(('NO_ATLAS_INFO',4))" ], "deleted": [] } } ] }, { "hash": "01ac8b980da771f89f273229bf089d977fc2ae78", "msg": "Minor fix.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-28T20:25:22+00:00", "author_timezone": 0, "committer_date": "2004-10-28T20:25:22+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "99f4811d4fae485fd1b5be8a8d6410c5cb21071a" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_src.py", "new_path": "scipy_distutils/command/build_src.py", "filename": "build_src.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -263,7 +263,7 @@ def f2py_sources(self, sources, extension):\n ' more:'+`f2py_sources`\n source = f2py_sources[0]\n target_file = f2py_targets[source]\n- target_dir = os.path.dirname(target_file)\n+ target_dir = os.path.dirname(target_file) or '.'\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file,'newer')) \\\n and not skip_f2py:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Build swig, f2py, weave, sources.\n\"\"\"\n\nimport os\nimport re\n\nfrom distutils.cmd import Command\nfrom distutils.command import build_ext, build_py\nfrom distutils.util import convert_path\nfrom distutils.dep_util import newer_group, newer\n\nfrom scipy_distutils import log\nfrom scipy_distutils.misc_util import fortran_ext_match, all_strings\nfrom scipy_distutils.from_template import process_str\n\nclass build_src(build_ext.build_ext):\n\n description = \"build sources from SWIG, F2PY files or a function\"\n\n user_options = [\n ('build-src=', 'd', \"directory to \\\"build\\\" sources to\"),\n ('f2pyflags=', None, \"additonal flags to f2py\"),\n ('swigflags=', None, \"additional flags to swig\"),\n ('force', 'f', \"forcibly build everything (ignore file timestamps)\"),\n ('inplace', 'i',\n \"ignore build-lib and put compiled extensions into the source \" +\n \"directory alongside your pure Python modules\"),\n ]\n\n boolean_options = ['force','inplace']\n\n help_options = []\n\n def initialize_options(self):\n self.extensions = None\n self.package = None\n self.py_modules = None\n self.build_src = None\n self.build_lib = None\n self.build_base = None\n self.force = None\n self.inplace = None\n self.package_dir = None\n self.f2pyflags = None\n self.swigflags = None\n return\n\n def finalize_options(self):\n self.set_undefined_options('build',\n ('build_base', 'build_base'),\n ('build_lib', 'build_lib'),\n ('force', 'force'))\n if self.package is None:\n self.package = self.distribution.ext_package\n self.extensions = self.distribution.ext_modules\n self.libraries = self.distribution.libraries or []\n self.py_modules = self.distribution.py_modules\n if self.build_src is None:\n self.build_src = os.path.join(self.build_base, 'src')\n if self.inplace is None:\n build_ext = self.get_finalized_command('build_ext')\n self.inplace = build_ext.inplace\n\n # py_modules is used in build_py.find_package_modules\n self.py_modules = {}\n\n if self.f2pyflags is None:\n self.f2pyflags = []\n else:\n self.f2pyflags = self.f2pyflags.split() # XXX spaces??\n\n if self.swigflags is None:\n self.swigflags = []\n else:\n self.swigflags = self.swigflags.split() # XXX spaces??\n return\n\n def run(self):\n if not (self.extensions or self.libraries):\n return\n self.build_sources()\n return\n\n def build_sources(self):\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n\n for libname_info in self.libraries:\n self.build_library_sources(*libname_info)\n\n return\n\n def build_library_sources(self, lib_name, build_info):\n sources = list(build_info.get('sources',[]))\n\n if not sources:\n return\n\n log.info('building library \"%s\" sources' % (lib_name))\n\n sources = self.generate_sources(sources, (lib_name, build_info))\n\n build_info['sources'] = sources\n return\n\n def build_extension_sources(self, ext):\n sources = list(ext.sources)\n\n log.info('building extension \"%s\" sources' % (ext.name))\n\n fullname = self.get_ext_fullname(ext.name)\n\n modpath = fullname.split('.')\n package = '.'.join(modpath[0:-1])\n\n if self.inplace:\n build_py = self.get_finalized_command('build_py')\n self.ext_target_dir = build_py.get_package_dir(package)\n\n sources = self.generate_sources(sources, ext)\n\n sources = self.template_sources(sources, ext)\n \n sources = self.swig_sources(sources, ext)\n\n sources = self.f2py_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules.has_key(package):\n self.py_modules[package] = []\n modules = []\n for f in py_files:\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n self.py_modules[package] += modules\n\n ext.sources = sources\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if type(source) is type(''):\n new_sources.append(source)\n else:\n func_sources.append(source)\n if not func_sources:\n return new_sources\n if self.inplace:\n build_dir = self.ext_target_dir\n else:\n if type(extension) is type(()):\n name = extension[0]\n else:\n name = extension.name\n build_dir = os.path.join(*([self.build_src]\\\n +name.split('.')[:-1]))\n self.mkpath(build_dir)\n for func in func_sources:\n source = func(extension, build_dir)\n if type(source) is type([]):\n [log.info(\" adding '%s' to sources.\" % (s)) for s in source]\n new_sources.extend(source)\n else:\n log.info(\" adding '%s' to sources.\" % (source))\n new_sources.append(source)\n return new_sources\n\n def filter_py_files(self, sources):\n new_sources = []\n py_files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext=='.py': \n py_files.append(source)\n else:\n new_sources.append(source)\n return new_sources, py_files\n\n def template_sources(self, sources, extension):\n new_sources = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.src': # Template file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n self.mkpath(target_dir)\n target_file = os.path.join(target_dir,os.path.basename(base))\n if (self.force or newer(source, target_file)):\n fid = open(source)\n outstr = process_str(fid.read())\n fid.close()\n fid = open(target_file,'w')\n fid.write(outstr)\n fid.close()\n new_sources.append(target_file)\n else:\n new_sources.append(source)\n return new_sources \n \n def f2py_sources(self, sources, extension):\n new_sources = []\n f2py_sources = []\n f_sources = []\n f2py_targets = {}\n target_dirs = []\n ext_name = extension.name.split('.')[-1]\n skip_f2py = 0\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyf': # F2PY interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n if os.path.isfile(source):\n name = get_f2py_modulename(source)\n assert name==ext_name,'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name`\n target_file = os.path.join(target_dir,name+'module.c')\n else:\n log.debug(' source %s does not exist: skipping f2py\\'ing.' \\\n % (source))\n name = ext_name\n skip_f2py = 1\n target_file = os.path.join(target_dir,name+'module.c')\n if not os.path.isfile(target_file):\n log.debug(' target %s does not exist:\\n '\\\n 'Assuming %smodule.c was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = os.path.join(target_dir,name+'module.c')\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.debug(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n new_sources.append(target_file)\n elif fortran_ext_match(ext):\n f_sources.append(source)\n else:\n new_sources.append(source)\n\n if not (f2py_sources or f_sources):\n return new_sources\n\n map(self.mkpath, target_dirs)\n\n f2py_options = extension.f2py_options + self.f2pyflags\n if f2py_sources:\n assert len(f2py_sources)==1,\\\n 'only one .pyf file is allowed per extension module but got'\\\n ' more:'+`f2py_sources`\n source = f2py_sources[0]\n target_file = f2py_targets[source]\n target_dir = os.path.dirname(target_file) or '.'\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file,'newer')) \\\n and not skip_f2py:\n log.info(\"f2py: %s\" % (source))\n import f2py2e\n f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])\n else:\n log.debug(\" skipping '%s' f2py interface (up-to-date)\" % (source))\n else:\n #XXX TODO: --inplace support for sdist command\n if type(extension) is type(()): name = extension[0]\n else: name = extension.name\n target_dir = os.path.join(*([self.build_src]\\\n +name.split('.')[:-1]))\n target_file = os.path.join(target_dir,ext_name + 'module.c')\n new_sources.append(target_file)\n depends = f_sources + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')) \\\n and not skip_f2py:\n import f2py2e\n log.info(\"f2py:> %s\" % (target_file))\n self.mkpath(target_dir)\n f2py2e.run_main(f2py_options + ['--lower',\n '--build-dir',target_dir]+\\\n ['-m',ext_name]+f_sources)\n else:\n log.debug(\" skipping f2py fortran files for '%s' (up-to-date)\"\\\n % (target_file))\n\n assert os.path.isfile(target_file),`target_file`+' missing'\n\n target_c = os.path.join(self.build_src,'fortranobject.c')\n target_h = os.path.join(self.build_src,'fortranobject.h')\n log.info(\" adding '%s' to sources.\" % (target_c))\n new_sources.append(target_c)\n if self.build_src not in extension.include_dirs:\n log.info(\" adding '%s' to include_dirs.\" \\\n % (self.build_src))\n extension.include_dirs.append(self.build_src)\n\n if not skip_f2py:\n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n source_c = os.path.join(d,'src','fortranobject.c')\n source_h = os.path.join(d,'src','fortranobject.h')\n if newer(source_c,target_c) or newer(source_h,target_h):\n self.mkpath(os.path.dirname(target_c))\n self.copy_file(source_c,target_c)\n self.copy_file(source_h,target_h)\n else:\n assert os.path.isfile(target_c),`target_c` + ' missing'\n assert os.path.isfile(target_h),`target_h` + ' missing'\n \n for name_ext in ['-f2pywrappers.f','-f2pywrappers2.f90']:\n filename = os.path.join(target_dir,ext_name + name_ext)\n if os.path.isfile(filename):\n log.info(\" adding '%s' to sources.\" % (filename))\n f_sources.append(filename)\n\n return new_sources + f_sources\n\n def swig_sources(self, sources, extension):\n # Assuming SWIG 1.3.14 or later. See compatibility note in\n # http://www.swig.org/Doc1.3/Python.html#Python_nn6\n\n new_sources = []\n swig_sources = []\n swig_targets = {}\n target_dirs = []\n py_files = [] # swig generated .py files\n target_ext = '.c'\n typ = None\n is_cpp = 0\n skip_swig = 0\n ext_name = extension.name.split('.')[-1]\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.i': # SWIG interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n py_target_dir = self.ext_target_dir\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n py_target_dir = target_dir\n if os.path.isfile(source):\n name = get_swig_modulename(source)\n assert name==ext_name[1:],'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name[1:]`\n if typ is None:\n typ = get_swig_target(source)\n is_cpp = typ=='c++'\n if is_cpp:\n target_ext = '.cpp'\n else:\n assert typ == get_swig_target(source),`typ`\n target_file = os.path.join(target_dir,'%s_wrap%s' \\\n % (name, target_ext))\n else:\n log.debug(' source %s does not exist: skipping swig\\'ing.' \\\n % (source))\n name = ext_name[1:]\n skip_swig = 1\n target_file = _find_swig_target(target_dir, name)\n if not os.path.isfile(target_file):\n log.debug(' target %s does not exist:\\n '\\\n 'Assuming %s_wrap.{c,cpp} was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = _find_swig_target(target_dir, name)\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.debug(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n new_sources.append(target_file)\n py_files.append(os.path.join(py_target_dir, name+'.py'))\n swig_sources.append(source)\n swig_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not swig_sources:\n return new_sources\n\n if skip_swig:\n return new_sources + py_files\n\n map(self.mkpath, target_dirs)\n swig = self.find_swig()\n swig_cmd = [swig, \"-python\"]\n if is_cpp:\n swig_cmd.append('-c++')\n for d in extension.include_dirs:\n swig_cmd.append('-I'+d)\n for source in swig_sources:\n target = swig_targets[source]\n depends = [source] + extension.depends\n if self.force or newer_group(depends, target, 'newer'):\n log.info(\"%s: %s\" % (os.path.basename(swig) \\\n + (is_cpp and '++' or ''), source))\n self.spawn(swig_cmd + self.swigflags \\\n + [\"-o\", target, '-outdir', py_target_dir, source])\n else:\n log.debug(\" skipping '%s' swig interface (up-to-date)\" \\\n % (source))\n\n return new_sources + py_files\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n subpath = path[len(d):]\n assert not os.path.isabs(subpath),`subpath`\n return os.path.join(prefix,subpath)\n return os.path.join(prefix, path)\n\n#### SWIG related auxiliary functions ####\n_swig_module_name_match = re.compile(r'\\s*%module\\s*(?P[\\w_]+)',\n re.I).match\n_has_c_header = re.compile(r'-[*]-\\s*c\\s*-[*]-',re.I).search\n_has_cpp_header = re.compile(r'-[*]-\\s*c[+][+]\\s*-[*]-',re.I).search\n\ndef get_swig_target(source):\n f = open(source,'r')\n result = 'c'\n line = f.readline()\n if _has_cpp_header(line):\n result = 'c++'\n if _has_c_header(line):\n result = 'c'\n f.close()\n return result\n\ndef get_swig_modulename(source):\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _swig_module_name_match(line)\n if m:\n name = m.group('name')\n break\n f.close()\n return name\n\ndef _find_swig_target(target_dir,name):\n for ext in ['.cpp','.c']:\n target = os.path.join(target_dir,'%s_wrap%s' % (name, ext))\n if os.path.isfile(target):\n break\n return target\n\n#### F2PY related auxiliary functions ####\n\n_f2py_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n_f2py_user_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\n\ndef get_f2py_modulename(source):\n name = None\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _f2py_module_name_match(line)\n if m:\n if _f2py_user_module_name_match(line): # skip *__user__* names\n continue\n name = m.group('name')\n break\n f.close()\n return name\n\n##########################################\n", "source_code_before": "\"\"\" Build swig, f2py, weave, sources.\n\"\"\"\n\nimport os\nimport re\n\nfrom distutils.cmd import Command\nfrom distutils.command import build_ext, build_py\nfrom distutils.util import convert_path\nfrom distutils.dep_util import newer_group, newer\n\nfrom scipy_distutils import log\nfrom scipy_distutils.misc_util import fortran_ext_match, all_strings\nfrom scipy_distutils.from_template import process_str\n\nclass build_src(build_ext.build_ext):\n\n description = \"build sources from SWIG, F2PY files or a function\"\n\n user_options = [\n ('build-src=', 'd', \"directory to \\\"build\\\" sources to\"),\n ('f2pyflags=', None, \"additonal flags to f2py\"),\n ('swigflags=', None, \"additional flags to swig\"),\n ('force', 'f', \"forcibly build everything (ignore file timestamps)\"),\n ('inplace', 'i',\n \"ignore build-lib and put compiled extensions into the source \" +\n \"directory alongside your pure Python modules\"),\n ]\n\n boolean_options = ['force','inplace']\n\n help_options = []\n\n def initialize_options(self):\n self.extensions = None\n self.package = None\n self.py_modules = None\n self.build_src = None\n self.build_lib = None\n self.build_base = None\n self.force = None\n self.inplace = None\n self.package_dir = None\n self.f2pyflags = None\n self.swigflags = None\n return\n\n def finalize_options(self):\n self.set_undefined_options('build',\n ('build_base', 'build_base'),\n ('build_lib', 'build_lib'),\n ('force', 'force'))\n if self.package is None:\n self.package = self.distribution.ext_package\n self.extensions = self.distribution.ext_modules\n self.libraries = self.distribution.libraries or []\n self.py_modules = self.distribution.py_modules\n if self.build_src is None:\n self.build_src = os.path.join(self.build_base, 'src')\n if self.inplace is None:\n build_ext = self.get_finalized_command('build_ext')\n self.inplace = build_ext.inplace\n\n # py_modules is used in build_py.find_package_modules\n self.py_modules = {}\n\n if self.f2pyflags is None:\n self.f2pyflags = []\n else:\n self.f2pyflags = self.f2pyflags.split() # XXX spaces??\n\n if self.swigflags is None:\n self.swigflags = []\n else:\n self.swigflags = self.swigflags.split() # XXX spaces??\n return\n\n def run(self):\n if not (self.extensions or self.libraries):\n return\n self.build_sources()\n return\n\n def build_sources(self):\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n\n for libname_info in self.libraries:\n self.build_library_sources(*libname_info)\n\n return\n\n def build_library_sources(self, lib_name, build_info):\n sources = list(build_info.get('sources',[]))\n\n if not sources:\n return\n\n log.info('building library \"%s\" sources' % (lib_name))\n\n sources = self.generate_sources(sources, (lib_name, build_info))\n\n build_info['sources'] = sources\n return\n\n def build_extension_sources(self, ext):\n sources = list(ext.sources)\n\n log.info('building extension \"%s\" sources' % (ext.name))\n\n fullname = self.get_ext_fullname(ext.name)\n\n modpath = fullname.split('.')\n package = '.'.join(modpath[0:-1])\n\n if self.inplace:\n build_py = self.get_finalized_command('build_py')\n self.ext_target_dir = build_py.get_package_dir(package)\n\n sources = self.generate_sources(sources, ext)\n\n sources = self.template_sources(sources, ext)\n \n sources = self.swig_sources(sources, ext)\n\n sources = self.f2py_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules.has_key(package):\n self.py_modules[package] = []\n modules = []\n for f in py_files:\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n self.py_modules[package] += modules\n\n ext.sources = sources\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if type(source) is type(''):\n new_sources.append(source)\n else:\n func_sources.append(source)\n if not func_sources:\n return new_sources\n if self.inplace:\n build_dir = self.ext_target_dir\n else:\n if type(extension) is type(()):\n name = extension[0]\n else:\n name = extension.name\n build_dir = os.path.join(*([self.build_src]\\\n +name.split('.')[:-1]))\n self.mkpath(build_dir)\n for func in func_sources:\n source = func(extension, build_dir)\n if type(source) is type([]):\n [log.info(\" adding '%s' to sources.\" % (s)) for s in source]\n new_sources.extend(source)\n else:\n log.info(\" adding '%s' to sources.\" % (source))\n new_sources.append(source)\n return new_sources\n\n def filter_py_files(self, sources):\n new_sources = []\n py_files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext=='.py': \n py_files.append(source)\n else:\n new_sources.append(source)\n return new_sources, py_files\n\n def template_sources(self, sources, extension):\n new_sources = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.src': # Template file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n self.mkpath(target_dir)\n target_file = os.path.join(target_dir,os.path.basename(base))\n if (self.force or newer(source, target_file)):\n fid = open(source)\n outstr = process_str(fid.read())\n fid.close()\n fid = open(target_file,'w')\n fid.write(outstr)\n fid.close()\n new_sources.append(target_file)\n else:\n new_sources.append(source)\n return new_sources \n \n def f2py_sources(self, sources, extension):\n new_sources = []\n f2py_sources = []\n f_sources = []\n f2py_targets = {}\n target_dirs = []\n ext_name = extension.name.split('.')[-1]\n skip_f2py = 0\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyf': # F2PY interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n if os.path.isfile(source):\n name = get_f2py_modulename(source)\n assert name==ext_name,'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name`\n target_file = os.path.join(target_dir,name+'module.c')\n else:\n log.debug(' source %s does not exist: skipping f2py\\'ing.' \\\n % (source))\n name = ext_name\n skip_f2py = 1\n target_file = os.path.join(target_dir,name+'module.c')\n if not os.path.isfile(target_file):\n log.debug(' target %s does not exist:\\n '\\\n 'Assuming %smodule.c was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = os.path.join(target_dir,name+'module.c')\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.debug(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n new_sources.append(target_file)\n elif fortran_ext_match(ext):\n f_sources.append(source)\n else:\n new_sources.append(source)\n\n if not (f2py_sources or f_sources):\n return new_sources\n\n map(self.mkpath, target_dirs)\n\n f2py_options = extension.f2py_options + self.f2pyflags\n if f2py_sources:\n assert len(f2py_sources)==1,\\\n 'only one .pyf file is allowed per extension module but got'\\\n ' more:'+`f2py_sources`\n source = f2py_sources[0]\n target_file = f2py_targets[source]\n target_dir = os.path.dirname(target_file)\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file,'newer')) \\\n and not skip_f2py:\n log.info(\"f2py: %s\" % (source))\n import f2py2e\n f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])\n else:\n log.debug(\" skipping '%s' f2py interface (up-to-date)\" % (source))\n else:\n #XXX TODO: --inplace support for sdist command\n if type(extension) is type(()): name = extension[0]\n else: name = extension.name\n target_dir = os.path.join(*([self.build_src]\\\n +name.split('.')[:-1]))\n target_file = os.path.join(target_dir,ext_name + 'module.c')\n new_sources.append(target_file)\n depends = f_sources + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')) \\\n and not skip_f2py:\n import f2py2e\n log.info(\"f2py:> %s\" % (target_file))\n self.mkpath(target_dir)\n f2py2e.run_main(f2py_options + ['--lower',\n '--build-dir',target_dir]+\\\n ['-m',ext_name]+f_sources)\n else:\n log.debug(\" skipping f2py fortran files for '%s' (up-to-date)\"\\\n % (target_file))\n\n assert os.path.isfile(target_file),`target_file`+' missing'\n\n target_c = os.path.join(self.build_src,'fortranobject.c')\n target_h = os.path.join(self.build_src,'fortranobject.h')\n log.info(\" adding '%s' to sources.\" % (target_c))\n new_sources.append(target_c)\n if self.build_src not in extension.include_dirs:\n log.info(\" adding '%s' to include_dirs.\" \\\n % (self.build_src))\n extension.include_dirs.append(self.build_src)\n\n if not skip_f2py:\n import f2py2e\n d = os.path.dirname(f2py2e.__file__)\n source_c = os.path.join(d,'src','fortranobject.c')\n source_h = os.path.join(d,'src','fortranobject.h')\n if newer(source_c,target_c) or newer(source_h,target_h):\n self.mkpath(os.path.dirname(target_c))\n self.copy_file(source_c,target_c)\n self.copy_file(source_h,target_h)\n else:\n assert os.path.isfile(target_c),`target_c` + ' missing'\n assert os.path.isfile(target_h),`target_h` + ' missing'\n \n for name_ext in ['-f2pywrappers.f','-f2pywrappers2.f90']:\n filename = os.path.join(target_dir,ext_name + name_ext)\n if os.path.isfile(filename):\n log.info(\" adding '%s' to sources.\" % (filename))\n f_sources.append(filename)\n\n return new_sources + f_sources\n\n def swig_sources(self, sources, extension):\n # Assuming SWIG 1.3.14 or later. See compatibility note in\n # http://www.swig.org/Doc1.3/Python.html#Python_nn6\n\n new_sources = []\n swig_sources = []\n swig_targets = {}\n target_dirs = []\n py_files = [] # swig generated .py files\n target_ext = '.c'\n typ = None\n is_cpp = 0\n skip_swig = 0\n ext_name = extension.name.split('.')[-1]\n\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.i': # SWIG interface file\n if self.inplace:\n target_dir = os.path.dirname(base)\n py_target_dir = self.ext_target_dir\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n py_target_dir = target_dir\n if os.path.isfile(source):\n name = get_swig_modulename(source)\n assert name==ext_name[1:],'mismatch of extension names: '\\\n +source+' provides'\\\n ' '+`name`+' but expected '+`ext_name[1:]`\n if typ is None:\n typ = get_swig_target(source)\n is_cpp = typ=='c++'\n if is_cpp:\n target_ext = '.cpp'\n else:\n assert typ == get_swig_target(source),`typ`\n target_file = os.path.join(target_dir,'%s_wrap%s' \\\n % (name, target_ext))\n else:\n log.debug(' source %s does not exist: skipping swig\\'ing.' \\\n % (source))\n name = ext_name[1:]\n skip_swig = 1\n target_file = _find_swig_target(target_dir, name)\n if not os.path.isfile(target_file):\n log.debug(' target %s does not exist:\\n '\\\n 'Assuming %s_wrap.{c,cpp} was generated with '\\\n '\"build_src --inplace\" command.' \\\n % (target_file, name))\n target_dir = os.path.dirname(base)\n target_file = _find_swig_target(target_dir, name)\n assert os.path.isfile(target_file),`target_file`+' missing'\n log.debug(' Yes! Using %s as up-to-date target.' \\\n % (target_file))\n target_dirs.append(target_dir)\n new_sources.append(target_file)\n py_files.append(os.path.join(py_target_dir, name+'.py'))\n swig_sources.append(source)\n swig_targets[source] = new_sources[-1]\n else:\n new_sources.append(source)\n\n if not swig_sources:\n return new_sources\n\n if skip_swig:\n return new_sources + py_files\n\n map(self.mkpath, target_dirs)\n swig = self.find_swig()\n swig_cmd = [swig, \"-python\"]\n if is_cpp:\n swig_cmd.append('-c++')\n for d in extension.include_dirs:\n swig_cmd.append('-I'+d)\n for source in swig_sources:\n target = swig_targets[source]\n depends = [source] + extension.depends\n if self.force or newer_group(depends, target, 'newer'):\n log.info(\"%s: %s\" % (os.path.basename(swig) \\\n + (is_cpp and '++' or ''), source))\n self.spawn(swig_cmd + self.swigflags \\\n + [\"-o\", target, '-outdir', py_target_dir, source])\n else:\n log.debug(\" skipping '%s' swig interface (up-to-date)\" \\\n % (source))\n\n return new_sources + py_files\n\ndef appendpath(prefix,path):\n if os.path.isabs(path):\n absprefix = os.path.abspath(prefix)\n d = os.path.commonprefix([absprefix,path])\n subpath = path[len(d):]\n assert not os.path.isabs(subpath),`subpath`\n return os.path.join(prefix,subpath)\n return os.path.join(prefix, path)\n\n#### SWIG related auxiliary functions ####\n_swig_module_name_match = re.compile(r'\\s*%module\\s*(?P[\\w_]+)',\n re.I).match\n_has_c_header = re.compile(r'-[*]-\\s*c\\s*-[*]-',re.I).search\n_has_cpp_header = re.compile(r'-[*]-\\s*c[+][+]\\s*-[*]-',re.I).search\n\ndef get_swig_target(source):\n f = open(source,'r')\n result = 'c'\n line = f.readline()\n if _has_cpp_header(line):\n result = 'c++'\n if _has_c_header(line):\n result = 'c'\n f.close()\n return result\n\ndef get_swig_modulename(source):\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _swig_module_name_match(line)\n if m:\n name = m.group('name')\n break\n f.close()\n return name\n\ndef _find_swig_target(target_dir,name):\n for ext in ['.cpp','.c']:\n target = os.path.join(target_dir,'%s_wrap%s' % (name, ext))\n if os.path.isfile(target):\n break\n return target\n\n#### F2PY related auxiliary functions ####\n\n_f2py_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',\n re.I).match\n_f2py_user_module_name_match = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\n\ndef get_f2py_modulename(source):\n name = None\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = _f2py_module_name_match(line)\n if m:\n if _f2py_user_module_name_match(line): # skip *__user__* names\n continue\n name = m.group('name')\n break\n f.close()\n return name\n\n##########################################\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_src.py", "nloc": 13, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 34, "end_line": 46, "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_src.py", "nloc": 25, "complexity": 7, "token_count": 179, "parameters": [ "self" ], "start_line": 48, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_src.py", "nloc": 5, "complexity": 3, "token_count": 24, "parameters": [ "self" ], "start_line": 78, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_sources", "long_name": "build_sources( self )", "filename": "build_src.py", "nloc": 7, "complexity": 3, "token_count": 41, "parameters": [ "self" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "build_library_sources", "long_name": "build_library_sources( self , lib_name , build_info )", "filename": "build_src.py", "nloc": 8, "complexity": 2, "token_count": 59, "parameters": [ "self", "lib_name", "build_info" ], "start_line": 95, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_extension_sources", "long_name": "build_extension_sources( self , ext )", "filename": "build_src.py", "nloc": 23, "complexity": 4, "token_count": 207, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 29, "complexity": 9, "token_count": 193, "parameters": [ "self", "sources", "extension" ], "start_line": 143, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "filter_py_files", "long_name": "filter_py_files( self , sources )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "self", "sources" ], "start_line": 173, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "template_sources", "long_name": "template_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 22, "complexity": 6, "token_count": 166, "parameters": [ "self", "sources", "extension" ], "start_line": 184, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 110, "complexity": 24, "token_count": 874, "parameters": [ "self", "sources", "extension" ], "start_line": 207, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 80, "complexity": 17, "token_count": 539, "parameters": [ "self", "sources", "extension" ], "start_line": 328, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 88, "top_nesting_level": 1 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "build_src.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "prefix", "path" ], "start_line": 417, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_swig_target", "long_name": "get_swig_target( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 48, "parameters": [ "source" ], "start_line": 432, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_swig_modulename", "long_name": "get_swig_modulename( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "source" ], "start_line": 443, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "_find_swig_target", "long_name": "_find_swig_target( target_dir , name )", "filename": "build_src.py", "nloc": 6, "complexity": 3, "token_count": 47, "parameters": [ "target_dir", "name" ], "start_line": 454, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "get_f2py_modulename", "long_name": "get_f2py_modulename( source )", "filename": "build_src.py", "nloc": 13, "complexity": 4, "token_count": 65, "parameters": [ "source" ], "start_line": 468, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_src.py", "nloc": 13, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 34, "end_line": 46, "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_src.py", "nloc": 25, "complexity": 7, "token_count": 179, "parameters": [ "self" ], "start_line": 48, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_src.py", "nloc": 5, "complexity": 3, "token_count": 24, "parameters": [ "self" ], "start_line": 78, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_sources", "long_name": "build_sources( self )", "filename": "build_src.py", "nloc": 7, "complexity": 3, "token_count": 41, "parameters": [ "self" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "build_library_sources", "long_name": "build_library_sources( self , lib_name , build_info )", "filename": "build_src.py", "nloc": 8, "complexity": 2, "token_count": 59, "parameters": [ "self", "lib_name", "build_info" ], "start_line": 95, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_extension_sources", "long_name": "build_extension_sources( self , ext )", "filename": "build_src.py", "nloc": 23, "complexity": 4, "token_count": 207, "parameters": [ "self", "ext" ], "start_line": 108, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 29, "complexity": 9, "token_count": 193, "parameters": [ "self", "sources", "extension" ], "start_line": 143, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "filter_py_files", "long_name": "filter_py_files( self , sources )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "self", "sources" ], "start_line": 173, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "template_sources", "long_name": "template_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 22, "complexity": 6, "token_count": 166, "parameters": [ "self", "sources", "extension" ], "start_line": 184, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 110, "complexity": 23, "token_count": 872, "parameters": [ "self", "sources", "extension" ], "start_line": 207, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 1 }, { "name": "swig_sources", "long_name": "swig_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 80, "complexity": 17, "token_count": 539, "parameters": [ "self", "sources", "extension" ], "start_line": 328, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 88, "top_nesting_level": 1 }, { "name": "appendpath", "long_name": "appendpath( prefix , path )", "filename": "build_src.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "prefix", "path" ], "start_line": 417, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_swig_target", "long_name": "get_swig_target( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 48, "parameters": [ "source" ], "start_line": 432, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_swig_modulename", "long_name": "get_swig_modulename( source )", "filename": "build_src.py", "nloc": 10, "complexity": 3, "token_count": 57, "parameters": [ "source" ], "start_line": 443, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "_find_swig_target", "long_name": "_find_swig_target( target_dir , name )", "filename": "build_src.py", "nloc": 6, "complexity": 3, "token_count": 47, "parameters": [ "target_dir", "name" ], "start_line": 454, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "get_f2py_modulename", "long_name": "get_f2py_modulename( source )", "filename": "build_src.py", "nloc": 13, "complexity": 4, "token_count": 65, "parameters": [ "source" ], "start_line": 468, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , extension )", "filename": "build_src.py", "nloc": 110, "complexity": 24, "token_count": 874, "parameters": [ "self", "sources", "extension" ], "start_line": 207, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 120, "top_nesting_level": 1 } ], "nloc": 411, "complexity": 94, "token_count": 2916, "diff_parsed": { "added": [ " target_dir = os.path.dirname(target_file) or '.'" ], "deleted": [ " target_dir = os.path.dirname(target_file)" ] } } ] }, { "hash": "e5b148d33a0e3a03036e036a6cd2bcfa13bc2d7a", "msg": "Fixing setup.py build_ext -O..", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-29T15:40:27+00:00", "author_timezone": 0, "committer_date": "2004-10-29T15:40:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "01ac8b980da771f89f273229bf089d977fc2ae78" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 2, "insertions": 6, "lines": 8, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/fcompiler.py", "new_path": "scipy_distutils/fcompiler.py", "filename": "fcompiler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -573,8 +573,12 @@ def link(self, target_desc, objects,\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n- ld_args = (objects + self.objects +\n- lib_opts + o_args)\n+ \n+ if type(self.objects) is type(''):\n+ ld_args = objects + [self.objects]\n+ else:\n+ ld_args = objects + self.objects\n+ ld_args = ld_args + lib_opts + o_args\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n", "added_lines": 6, "deleted_lines": 2, "source_code": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n \n if type(self.objects) is type(''):\n ld_args = objects + [self.objects]\n else:\n ld_args = objects + self.objects\n ld_args = ld_args + lib_opts + o_args\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "source_code_before": "\"\"\"scipy_distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the Scipy_distutils Fortran compiler abstraction model.\n\n\"\"\"\n\nimport re\nimport os\nimport sys\nimport atexit\nfrom types import StringType, NoneType, ListType, TupleType\nfrom glob import glob\n\nfrom distutils.version import StrictVersion\nfrom scipy_distutils.ccompiler import CCompiler, gen_lib_options\n# distutils.ccompiler provides the following functions:\n# gen_preprocess_options(macros, include_dirs)\n# gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.core import Command\nfrom distutils.util import split_quoted\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.sysconfig import get_config_var\nfrom distutils.spawn import _nt_quote_args \n\n\nfrom scipy_distutils.command.config_compiler import config_fc\n\nimport log\nfrom misc_util import compiler_to_string, cyg2win32\nfrom exec_command import find_executable, exec_command\n\nclass FCompiler(CCompiler):\n \"\"\" Abstract base class to define the interface that must be implemented\n by real Fortran compiler classes.\n\n Methods that subclasses may redefine:\n\n get_version_cmd(), get_linker_so(), get_version()\n get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()\n get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),\n get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),\n get_flags_arch_f90(), get_flags_debug_f90(),\n get_flags_fix(), get_flags_linker_so(), get_flags_version()\n\n DON'T call these methods (except get_version) after\n constructing a compiler instance or inside any other method.\n All methods, except get_version_cmd() and get_flags_version(), may\n call get_version() method.\n\n After constructing a compiler instance, always call customize(dist=None)\n method that finalizes compiler construction and makes the following\n attributes available:\n compiler_f77\n compiler_f90\n compiler_fix\n linker_so\n archiver\n ranlib\n libraries\n library_dirs\n \"\"\"\n # CCompiler defines the following attributes:\n # compiler_type\n # src_extensions\n # obj_extension\n # static_lib_extension\n # shared_lib_extension\n # static_lib_format\n # shared_lib_format\n # exe_extension\n # language_map ### REDEFINED\n # language_order ### REDEFINED\n # and the following public methods:\n # set_executables(**args)\n # set_executable(key,value)\n # define_macro(name, value=None)\n # undefine_macro(name)\n # add_include_dir(dir)\n # set_include_dirs(dirs)\n # add_library(libname)\n # set_libraries(libnames)\n # add_library_dir(dir)\n # set_library_dirs(dirs)\n # add_runtime_library_dir(dir)\n # set_runtime_library_dirs(dirs)\n # add_link_object(object)\n # set_link_objects(objects)\n #\n # detect_language(sources) ### USABLE\n #\n # preprocess(source,output_file=None,macros=None,include_dirs=None,\n # extra_preargs=None,extra_postargs=None)\n # compile(sources, output_dir=None, macros=None,\n # include_dirs=None, debug=0, extra_preargs=None,\n # extra_postargs=None, depends=None)\n # create_static_lib(objects,output_libname,output_dir=None,debug=0,target_lang=None):\n # link(target_desc, objects, output_filename, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None,\n # build_temp=None, target_lang=None)\n # link_shared_lib(objects, output_libname, output_dir=None,\n # libraries=None, library_dirs=None, runtime_library_dirs=None,\n # export_symbols=None, debug=0, extra_preargs=None,\n # extra_postargs=None, build_temp=None, target_lang=None)\n # link_shared_object(objects,output_filename,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # export_symbols=None,debug=0,extra_preargs=None,\n # extra_postargs=None,build_temp=None,target_lang=None)\n # link_executable(objects,output_progname,output_dir=None,\n # libraries=None,library_dirs=None,runtime_library_dirs=None,\n # debug=0,extra_preargs=None,extra_postargs=None,target_lang=None)\n #\n # library_dir_option(dir)\n # runtime_library_dir_option(dir)\n # library_option(lib)\n # has_function(funcname,includes=None,include_dirs=None,\n # libraries=None,library_dirs=None)\n # find_library_file(dirs, lib, debug=0)\n #\n # object_filenames(source_filenames, strip_dir=0, output_dir='')\n # shared_object_filename(basename, strip_dir=0, output_dir='')\n # executable_filenamee(basename, strip_dir=0, output_dir='')\n # library_filename(libname, lib_type='static',strip_dir=0, output_dir=''):\n #\n # announce(msg, level=1)\n # debug_print(msg)\n # warn(msg)\n # execute(func, args, msg=None, level=1)\n # spawn(cmd)\n # move_file(src,dst)\n # mkpath(name, mode=0777)\n #\n\n language_map = {'.f':'f77',\n '.for':'f77',\n '.F':'f77', # XXX: needs preprocessor\n '.ftn':'f77',\n '.f77':'f77',\n '.f90':'f90',\n '.F90':'f90', # XXX: needs preprocessor\n '.f95':'f90',\n }\n language_order = ['f90','f77']\n\n version_pattern = None\n\n executables = {\n 'version_cmd' : [\"f77\",\"-v\"],\n 'compiler_f77' : [\"f77\"],\n 'compiler_f90' : [\"f90\"],\n 'compiler_fix' : [\"f90\",\"-fixed\"],\n 'linker_so' : [\"f90\",\"-shared\"],\n #'linker_exe' : [\"f90\"], # XXX do we need it??\n 'archiver' : [\"ar\",\"-cr\"],\n 'ranlib' : None,\n }\n\n compile_switch = \"-c\"\n object_switch = \"-o \" # Ending space matters! It will be stripped\n # but if it is missing then object_switch\n # will be prefixed to object file name by\n # string concatenation.\n library_switch = \"-o \" # Ditto!\n\n # Switch to specify where module files are created and searched\n # for USE statement. Normally it is a string and also here ending\n # space matters. See above.\n module_dir_switch = None\n\n # Switch to specify where module files are searched for USE statement.\n module_include_switch = '-I' \n\n pic_flags = [] # Flags to create position-independent code\n\n src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90']\n obj_extension = \".o\"\n shared_lib_extension = get_config_var('SO') # or .dll\n static_lib_extension = \".a\" # or .lib\n static_lib_format = \"lib%s%s\" # or %s%s\n shared_lib_format = \"%s%s\"\n exe_extension = \"\"\n\n ######################################################################\n ## Methods that subclasses may redefine. But don't call these methods!\n ## They are private to FCompiler class and may return unexpected\n ## results if used elsewhere. So, you have been warned..\n\n def get_version_cmd(self):\n \"\"\" Compiler command to print out version information. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n cmd = self.executables['version_cmd']\n if cmd is not None:\n cmd = cmd[0]\n if cmd==f77:\n cmd = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if cmd==f90:\n cmd = self.compiler_f90[0]\n return cmd\n\n def get_linker_so(self):\n \"\"\" Linker command to build shared libraries. \"\"\"\n f77 = self.executables['compiler_f77']\n if f77 is not None:\n f77 = f77[0]\n ln = self.executables['linker_so']\n if ln is not None:\n ln = ln[0]\n if ln==f77:\n ln = self.compiler_f77[0]\n else:\n f90 = self.executables['compiler_f90']\n if f90 is not None:\n f90 = f90[0]\n if ln==f90:\n ln = self.compiler_f90[0]\n return ln\n\n def get_flags(self):\n \"\"\" List of flags common to all compiler types. \"\"\"\n return [] + self.pic_flags\n def get_flags_version(self):\n \"\"\" List of compiler flags to print out version information. \"\"\"\n if self.executables['version_cmd']:\n return self.executables['version_cmd'][1:]\n return []\n def get_flags_f77(self):\n \"\"\" List of Fortran 77 specific flags. \"\"\"\n if self.executables['compiler_f77']:\n return self.executables['compiler_f77'][1:]\n return []\n def get_flags_f90(self):\n \"\"\" List of Fortran 90 specific flags. \"\"\"\n if self.executables['compiler_f90']:\n return self.executables['compiler_f90'][1:]\n return []\n def get_flags_free(self):\n \"\"\" List of Fortran 90 free format specific flags. \"\"\"\n return []\n def get_flags_fix(self):\n \"\"\" List of Fortran 90 fixed format specific flags. \"\"\"\n if self.executables['compiler_fix']:\n return self.executables['compiler_fix'][1:]\n return []\n def get_flags_linker_so(self):\n \"\"\" List of linker flags to build a shared library. \"\"\"\n if self.executables['linker_so']:\n return self.executables['linker_so'][1:]\n return []\n def get_flags_ar(self):\n \"\"\" List of archiver flags. \"\"\"\n if self.executables['archiver']:\n return self.executables['archiver'][1:]\n return []\n def get_flags_opt(self):\n \"\"\" List of architecture independent compiler flags. \"\"\"\n return []\n def get_flags_arch(self):\n \"\"\" List of architecture dependent compiler flags. \"\"\"\n return []\n def get_flags_debug(self):\n \"\"\" List of compiler flags to compile with debugging information. \"\"\"\n return []\n get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt\n get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch\n get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug\n\n def get_libraries(self):\n \"\"\" List of compiler libraries. \"\"\"\n return self.libraries[:]\n def get_library_dirs(self):\n \"\"\" List of compiler library directories. \"\"\"\n return self.library_dirs[:]\n\n ############################################################\n\n ## Public methods:\n\n def customize(self, dist=None):\n \"\"\" Customize Fortran compiler.\n\n This method gets Fortran compiler specific information from\n (i) class definition, (ii) environment, (iii) distutils config\n files, and (iv) command line.\n\n This method should be always called after constructing a\n compiler instance. But not in __init__ because Distribution\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n if dist is None:\n # These hooks are for testing only!\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n conf = dist.get_option_dict('config_fc')\n noopt = conf.get('noopt',[None,0])[1]\n if 0: # change to `if 1:` when making release.\n # Don't use architecture dependent compiler flags:\n noarch = 1\n else:\n noarch = conf.get('noarch',[None,noopt])[1]\n debug = conf.get('debug',[None,0])[1]\n\n f77 = self.__get_cmd('compiler_f77','F77',(conf,'f77exec'))\n f90 = self.__get_cmd('compiler_f90','F90',(conf,'f90exec'))\n # Temporarily setting f77,f90 compilers so that\n # version_cmd can use their executables.\n if f77:\n self.set_executables(compiler_f77=[f77])\n if f90:\n self.set_executables(compiler_f90=[f90])\n\n # Must set version_cmd before others as self.get_flags*\n # methods may call self.get_version.\n vers_cmd = self.__get_cmd(self.get_version_cmd)\n if vers_cmd:\n vflags = self.__get_flags(self.get_flags_version)\n self.set_executables(version_cmd=[vers_cmd]+vflags)\n\n if f77:\n f77flags = self.__get_flags(self.get_flags_f77,'F77FLAGS',\n (conf,'f77flags'))\n if f90:\n f90flags = self.__get_flags(self.get_flags_f90,'F90FLAGS',\n (conf,'f90flags'))\n freeflags = self.__get_flags(self.get_flags_free,'FREEFLAGS',\n (conf,'freeflags'))\n # XXX Assuming that free format is default for f90 compiler.\n fix = self.__get_cmd('compiler_fix','F90',(conf,'f90exec'))\n if fix:\n fixflags = self.__get_flags(self.get_flags_fix) + f90flags\n\n oflags,aflags,dflags = [],[],[]\n if not noopt:\n oflags = self.__get_flags(self.get_flags_opt,'FOPT',(conf,'opt'))\n if f77 and self.get_flags_opt is not self.get_flags_opt_f77:\n f77flags += self.__get_flags(self.get_flags_opt_f77)\n if f90 and self.get_flags_opt is not self.get_flags_opt_f90:\n f90flags += self.__get_flags(self.get_flags_opt_f90)\n if fix and self.get_flags_opt is not self.get_flags_opt_f90:\n fixflags += self.__get_flags(self.get_flags_opt_f90)\n if not noarch:\n aflags = self.__get_flags(self.get_flags_arch,'FARCH',\n (conf,'arch'))\n if f77 and self.get_flags_arch is not self.get_flags_arch_f77:\n f77flags += self.__get_flags(self.get_flags_arch_f77)\n if f90 and self.get_flags_arch is not self.get_flags_arch_f90:\n f90flags += self.__get_flags(self.get_flags_arch_f90)\n if fix and self.get_flags_arch is not self.get_flags_arch_f90:\n fixflags += self.__get_flags(self.get_flags_arch_f90)\n if debug:\n dflags = self.__get_flags(self.get_flags_debug,'FDEBUG')\n if f77 and self.get_flags_debug is not self.get_flags_debug_f77:\n f77flags += self.__get_flags(self.get_flags_debug_f77)\n if f90 and self.get_flags_debug is not self.get_flags_debug_f90:\n f90flags += self.__get_flags(self.get_flags_debug_f90)\n if fix and self.get_flags_debug is not self.get_flags_debug_f90:\n fixflags += self.__get_flags(self.get_flags_debug_f90)\n\n fflags = self.__get_flags(self.get_flags,'FFLAGS') \\\n + dflags + oflags + aflags\n\n if f77:\n self.set_executables(compiler_f77=[f77]+f77flags+fflags)\n if f90:\n self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags)\n if fix:\n self.set_executables(compiler_fix=[fix]+fixflags+fflags)\n\n #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS\n linker_so = self.__get_cmd(self.get_linker_so,'LDSHARED')\n if linker_so:\n linker_so_flags = self.__get_flags(self.get_flags_linker_so,'LDFLAGS')\n self.set_executables(linker_so=[linker_so]+linker_so_flags)\n\n ar = self.__get_cmd('archiver','AR')\n if ar:\n arflags = self.__get_flags(self.get_flags_ar,'ARFLAGS')\n self.set_executables(archiver=[ar]+arflags)\n\n ranlib = self.__get_cmd('ranlib','RANLIB')\n if ranlib:\n self.set_executables(ranlib=[ranlib])\n\n self.set_library_dirs(self.get_library_dirs())\n self.set_libraries(self.get_libraries())\n\n verbose = conf.get('verbose',[None,0])[1]\n if verbose:\n self.dump_properties()\n return\n\n def dump_properties(self):\n \"\"\" Print out the attributes of a compiler instance. \"\"\"\n props = []\n for key in self.executables.keys() + \\\n ['version','libraries','library_dirs',\n 'object_switch','compile_switch']:\n if hasattr(self,key):\n v = getattr(self,key)\n props.append((key, None, '= '+`v`))\n props.sort()\n\n pretty_printer = FancyGetopt(props)\n for l in pretty_printer.generate_help(\"%s instance properties:\" \\\n % (self.__class__.__name__)):\n if l[:4]==' --':\n l = ' ' + l[4:]\n print l\n return\n\n ###################\n\n def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):\n \"\"\"Compile 'src' to product 'obj'.\"\"\"\n if is_f_file(src) and not has_f90_header(src):\n flavor = ':f77'\n compiler = self.compiler_f77\n elif is_free_format(src):\n flavor = ':f90'\n compiler = self.compiler_f90\n if compiler is None:\n raise DistutilsExecError, 'f90 not supported by '\\\n +self.__class__.__name__\n else:\n flavor = ':fix'\n compiler = self.compiler_fix\n if compiler is None:\n raise DistutilsExecError, 'f90 (fixed) not supported by '\\\n +self.__class__.__name__\n if self.object_switch[-1]==' ':\n o_args = [self.object_switch.strip(),obj]\n else:\n o_args = [self.object_switch.strip()+obj]\n\n assert self.compile_switch.strip()\n s_args = [self.compile_switch, src]\n\n if os.name == 'nt':\n compiler = _nt_quote_args(compiler)\n command = compiler + cc_args + s_args + o_args + extra_postargs\n\n display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,\n src)\n try:\n self.spawn(command,display=display)\n except DistutilsExecError, msg:\n raise CompileError, msg\n\n return\n\n def module_options(self, module_dirs, module_build_dir):\n options = []\n if self.module_dir_switch is not None:\n if self.module_dir_switch[-1]==' ':\n options.extend([self.module_dir_switch.strip(),module_build_dir])\n else:\n options.append(self.module_dir_switch.strip()+module_build_dir)\n else:\n print 'XXX: module_build_dir=%r option ignored' % (module_build_dir)\n print 'XXX: Fix module_dir_switch for ',self.__class__.__name__\n if self.module_include_switch is not None:\n for d in [module_build_dir]+module_dirs:\n options.append('%s%s' % (self.module_include_switch, d))\n else:\n print 'XXX: module_dirs=%r option ignored' % (module_dirs)\n print 'XXX: Fix module_include_switch for ',self.__class__.__name__\n return options\n\n def library_option(self, lib):\n return \"-l\" + lib\n def library_dir_option(self, dir):\n return \"-L\" + dir\n\n# def _get_cc_args(self, pp_opts, debug, extra_preargs):\n# return []\n\n if sys.version[:3]<'2.3':\n def _get_cc_args(self, pp_opts, debug, before):\n # works for unixccompiler, emxccompiler, cygwinccompiler\n cc_args = pp_opts + ['-c']\n if debug:\n cc_args[:0] = ['-g']\n if before:\n cc_args[:0] = before\n return cc_args\n\n def compile(self, sources, output_dir=None, macros=None,\n include_dirs=None, debug=0, extra_preargs=None,\n extra_postargs=None, depends=None):\n if output_dir is None: output_dir = self.output_dir\n if macros is None: macros = self.macros\n elif type(macros) is ListType: macros = macros + (self.macros or [])\n if include_dirs is None: include_dirs = self.include_dirs\n elif type(include_dirs) in (ListType, TupleType):\n include_dirs = list(include_dirs) + (self.include_dirs or [])\n if extra_preargs is None: extra_preargs=[]\n\n display = []\n for fc in ['f77','f90','fix']:\n fcomp = getattr(self,'compiler_'+fc)\n if fcomp is None:\n continue\n display.append(\"%s(%s) options: '%s'\" \\\n % (os.path.basename(fcomp[0]),\n fc,\n ' '.join(fcomp[1:])))\n display = '\\n'.join(display)\n log.info(display)\n \n from distutils.sysconfig import python_build\n objects = self.object_filenames(sources,strip_dir=python_build,\n output_dir=output_dir)\n from distutils.ccompiler import gen_preprocess_options\n pp_opts = gen_preprocess_options(macros, include_dirs)\n build = {}\n for i in range(len(sources)):\n src,obj = sources[i],objects[i]\n ext = os.path.splitext(src)[1]\n self.mkpath(os.path.dirname(obj))\n build[obj] = src, ext\n cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)\n\n display = \"compile options: '%s'\" % (' '.join(cc_args))\n if extra_postargs:\n display += \"\\nextra options: '%s'\" % (' '.join(extra_postargs))\n log.info(display)\n\n objects_to_build = build.keys()\n for obj in objects:\n if obj in objects_to_build:\n src, ext = build[obj]\n if self.compiler_type=='absoft':\n obj = cyg2win32(obj)\n src = cyg2win32(src)\n self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)\n return objects\n def detect_language(self, sources):\n return\n\n def link(self, target_desc, objects,\n output_filename, output_dir=None, libraries=None,\n library_dirs=None, runtime_library_dirs=None,\n export_symbols=None, debug=0, extra_preargs=None,\n extra_postargs=None, build_temp=None, target_lang=None):\n objects, output_dir = self._fix_object_args(objects, output_dir)\n libraries, library_dirs, runtime_library_dirs = \\\n self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)\n\n lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,\n libraries)\n if type(output_dir) not in (StringType, NoneType):\n raise TypeError, \"'output_dir' must be a string or None\"\n if output_dir is not None:\n output_filename = os.path.join(output_dir, output_filename)\n\n if self._need_link(objects, output_filename):\n if self.library_switch[-1]==' ':\n o_args = [self.library_switch.strip(),output_filename]\n else:\n o_args = [self.library_switch.strip()+output_filename]\n ld_args = (objects + self.objects +\n lib_opts + o_args)\n if debug:\n ld_args[:0] = ['-g']\n if extra_preargs:\n ld_args[:0] = extra_preargs\n if extra_postargs:\n ld_args.extend(extra_postargs)\n self.mkpath(os.path.dirname(output_filename))\n if target_desc == CCompiler.EXECUTABLE:\n raise NotImplementedError,self.__class__.__name__+'.linker_exe attribute'\n else:\n linker = self.linker_so[:]\n if os.name == 'nt':\n linker = _nt_quote_args(linker)\n command = linker + ld_args\n try:\n self.spawn(command)\n except DistutilsExecError, msg:\n raise LinkError, msg\n else:\n log.debug(\"skipping %s (up-to-date)\", output_filename)\n return\n\n ############################################################\n\n ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif type(command) is type(''):\n var = self.executables[command]\n if var is not None:\n var = var[0]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n return var\n\n def __get_flags(self, command, envvar=None, confvar=None):\n if command is None:\n var = []\n elif type(command) is type(''):\n var = self.executables[command][1:]\n else:\n var = command()\n if envvar is not None:\n var = os.environ.get(envvar, var)\n if confvar is not None:\n var = confvar[0].get(confvar[1], [None,var])[1]\n if type(var) is type(''):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\n##############################################################################\n\nfcompiler_class = {'gnu':('gnufcompiler','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'pg':('pgfcompiler','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoftfcompiler','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mipsfcompiler','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sunfcompiler','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intelfcompiler','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intelfcompiler','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intelfcompiler','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intelfcompiler','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nagfcompiler','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaqfcompiler','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaqfcompiler','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vastfcompiler','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpuxfcompiler','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('laheyfcompiler','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibmfcompiler','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('fcompiler','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele')),\n ('darwin.*',('nag','absoft','ibm','gnu')),\n ('sunos.*',('forte','gnu','sun')),\n ('irix.*',('mips','gnu')),\n ('aix.*',('ibm','gnu')),\n # OS mappings\n ('posix',('gnu',)),\n ('nt',('gnu',)),\n ('mac',('gnu',)),\n )\n\ndef _find_existing_fcompiler(compilers, osname=None, platform=None):\n for compiler in compilers:\n v = None\n try:\n c = new_fcompiler(plat=platform, compiler=compiler)\n c.customize()\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is not None:\n return compiler\n return\n\ndef get_default_fcompiler(osname=None, platform=None):\n \"\"\" Determine the default Fortran compiler to use for the given platform. \"\"\"\n if osname is None:\n osname = os.name\n if platform is None:\n platform = sys.platform\n matching_compilers = []\n for pattern, compiler in _default_compilers:\n if re.match(pattern, platform) is not None or \\\n re.match(pattern, osname) is not None:\n if type(compiler) is type(()):\n matching_compilers.extend(list(compiler))\n else:\n matching_compilers.append(compiler)\n if not matching_compilers:\n matching_compilers.append('gnu')\n compiler = _find_existing_fcompiler(matching_compilers,\n osname=osname,\n platform=platform)\n if compiler is not None:\n return compiler\n return matching_compilers[0]\n\ndef new_fcompiler(plat=None,\n compiler=None,\n verbose=0,\n dry_run=0,\n force=0):\n \"\"\" Generate an instance of some FCompiler subclass for the supplied\n platform/compiler combination.\n \"\"\"\n if plat is None:\n plat = os.name\n try:\n if compiler is None:\n compiler = get_default_fcompiler(plat)\n (module_name, class_name, long_description) = fcompiler_class[compiler]\n except KeyError:\n msg = \"don't know how to compile Fortran code on platform '%s'\" % plat\n if compiler is not None:\n msg = msg + \" with '%s' compiler.\" % compiler\n msg = msg + \" Supported compilers are: %s)\" \\\n % (','.join(fcompiler_class.keys()))\n raise DistutilsPlatformError, msg\n\n try:\n module_name = 'scipy_distutils.'+module_name\n __import__ (module_name)\n module = sys.modules[module_name]\n klass = vars(module)[class_name]\n except ImportError:\n raise DistutilsModuleError, \\\n \"can't compile Fortran code: unable to load module '%s'\" % \\\n module_name\n except KeyError:\n raise DistutilsModuleError, \\\n (\"can't compile Fortran code: unable to find class '%s' \" +\n \"in module '%s'\") % (class_name, module_name)\n compiler = klass(None, dry_run, force)\n log.debug('new_fcompiler returns %s' % (klass))\n return compiler\n\ndef show_fcompilers(dist = None):\n \"\"\" Print list of available compilers (used by the \"--help-fcompiler\"\n option to \"config_fc\").\n \"\"\"\n if dist is None:\n from dist import Distribution\n dist = Distribution()\n dist.script_name = os.path.basename(sys.argv[0])\n dist.script_args = ['config_fc'] + sys.argv[1:]\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n\n compilers = []\n compilers_na = []\n compilers_ni = []\n for compiler in fcompiler_class.keys():\n v = 'N/A'\n try:\n c = new_fcompiler(compiler=compiler)\n c.customize(dist)\n v = c.get_version()\n except DistutilsModuleError:\n pass\n except Exception, msg:\n log.warn(msg)\n if v is None:\n compilers_na.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n elif v=='N/A':\n compilers_ni.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2]))\n else:\n compilers.append((\"fcompiler=\"+compiler, None,\n fcompiler_class[compiler][2] + ' (%s)' % v))\n compilers.sort()\n compilers_na.sort()\n pretty_printer = FancyGetopt(compilers)\n pretty_printer.print_help(\"List of available Fortran compilers:\")\n pretty_printer = FancyGetopt(compilers_na)\n pretty_printer.print_help(\"List of unavailable Fortran compilers:\")\n if compilers_ni:\n pretty_printer = FancyGetopt(compilers_ni)\n pretty_printer.print_help(\"List of unimplemented Fortran compilers:\")\n print \"For compiler details, run 'config_fc --verbose' setup command.\"\n\ndef dummy_fortran_file():\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n def rm_file(name=dummy_name,log_threshold=log._global_log.threshold):\n save_th = log._global_log.threshold\n log.set_threshold(log_threshold)\n try: os.remove(name+'.f'); log.debug('removed '+name+'.f')\n except OSError: pass\n try: os.remove(name+'.o'); log.debug('removed '+name+'.o')\n except OSError: pass\n log.set_threshold(save_th)\n atexit.register(rm_file)\n return dummy_name\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_has_fix_header = re.compile(r'-[*]-\\s*fix\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*]\\s*[^\\s\\d\\t]',re.I).match\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15 # the number of non-comment lines to scan for hints\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if (line[0]!='\\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\ndef has_f90_header(src):\n f = open(src,'r')\n line = f.readline()\n f.close()\n return _has_f90_header(line) or _has_fix_header(line)\nif __name__ == '__main__':\n show_fcompilers()\n", "methods": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 45, "complexity": 12, "token_count": 331, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 608, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 623, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 694, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 709, "end_line": 730, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 732, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 771, "end_line": 815, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 823, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 817, "end_line": 832, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 839, "end_line": 860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 862, "end_line": 866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_version_cmd", "long_name": "get_version_cmd( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 191, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 6, "token_count": 96, "parameters": [ "self" ], "start_line": 209, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_flags", "long_name": "get_flags( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_version", "long_name": "get_flags_version( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f77", "long_name": "get_flags_f77( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 235, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_f90", "long_name": "get_flags_f90( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 240, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_free", "long_name": "get_flags_free( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 245, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_fix", "long_name": "get_flags_fix( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_linker_so", "long_name": "get_flags_linker_so( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_ar", "long_name": "get_flags_ar( self )", "filename": "fcompiler.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_flags_opt", "long_name": "get_flags_opt( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 263, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_arch", "long_name": "get_flags_arch( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_flags_debug", "long_name": "get_flags_debug( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 269, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 276, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 279, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "customize", "long_name": "customize( self , dist = None )", "filename": "fcompiler.py", "nloc": 89, "complexity": 37, "token_count": 827, "parameters": [ "self", "dist" ], "start_line": 287, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 119, "top_nesting_level": 1 }, { "name": "dump_properties", "long_name": "dump_properties( self )", "filename": "fcompiler.py", "nloc": 16, "complexity": 5, "token_count": 117, "parameters": [ "self" ], "start_line": 407, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_compile", "long_name": "_compile( self , obj , src , ext , cc_args , extra_postargs , pp_opts )", "filename": "fcompiler.py", "nloc": 32, "complexity": 9, "token_count": 217, "parameters": [ "self", "obj", "src", "ext", "cc_args", "extra_postargs", "pp_opts" ], "start_line": 428, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "module_options", "long_name": "module_options( self , module_dirs , module_build_dir )", "filename": "fcompiler.py", "nloc": 17, "complexity": 5, "token_count": 129, "parameters": [ "self", "module_dirs", "module_build_dir" ], "start_line": 466, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "library_option", "long_name": "library_option( self , lib )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "lib" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dir_option", "long_name": "library_dir_option( self , dir )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "dir" ], "start_line": 486, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_get_cc_args", "long_name": "_get_cc_args( self , pp_opts , debug , before )", "filename": "fcompiler.py", "nloc": 7, "complexity": 3, "token_count": 42, "parameters": [ "self", "pp_opts", "debug", "before" ], "start_line": 493, "end_line": 500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 2 }, { "name": "compile", "long_name": "compile( self , sources , output_dir = None , macros = None , include_dirs = None , debug = 0 , extra_preargs = None , extra_postargs = None , depends = None )", "filename": "fcompiler.py", "nloc": 46, "complexity": 16, "token_count": 405, "parameters": [ "self", "sources", "output_dir", "macros", "include_dirs", "debug", "extra_preargs", "extra_postargs", "depends" ], "start_line": 502, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 2 }, { "name": "detect_language", "long_name": "detect_language( self , sources )", "filename": "fcompiler.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "sources" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 42, "complexity": 11, "token_count": 306, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "__get_cmd", "long_name": "__get_cmd( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 110, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 604, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "__get_flags", "long_name": "__get_flags( self , command , envvar = None , confvar = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 6, "token_count": 120, "parameters": [ "self", "command", "envvar", "confvar" ], "start_line": 619, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "_find_existing_fcompiler", "long_name": "_find_existing_fcompiler( compilers , osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 14, "complexity": 5, "token_count": 71, "parameters": [ "compilers", "osname", "platform" ], "start_line": 690, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_default_fcompiler", "long_name": "get_default_fcompiler( osname = None , platform = None )", "filename": "fcompiler.py", "nloc": 21, "complexity": 9, "token_count": 135, "parameters": [ "osname", "platform" ], "start_line": 705, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "new_fcompiler", "long_name": "new_fcompiler( plat = None , compiler = None , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "fcompiler.py", "nloc": 34, "complexity": 7, "token_count": 182, "parameters": [ "plat", "compiler", "verbose", "dry_run", "force" ], "start_line": 728, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "show_fcompilers", "long_name": "show_fcompilers( dist = None )", "filename": "fcompiler.py", "nloc": 41, "complexity": 8, "token_count": 261, "parameters": [ "dist" ], "start_line": 767, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 }, { "name": "dummy_fortran_file.rm_file", "long_name": "dummy_fortran_file.rm_file( name = dummy_name , log_threshold = log . _global_log . threshold )", "filename": "fcompiler.py", "nloc": 8, "complexity": 3, "token_count": 84, "parameters": [ "name", "log_threshold" ], "start_line": 819, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "dummy_fortran_file", "long_name": "dummy_fortran_file( )", "filename": "fcompiler.py", "nloc": 9, "complexity": 1, "token_count": 46, "parameters": [], "start_line": 813, "end_line": 828, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "fcompiler.py", "nloc": 19, "complexity": 9, "token_count": 114, "parameters": [ "file" ], "start_line": 835, "end_line": 856, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "has_f90_header", "long_name": "has_f90_header( src )", "filename": "fcompiler.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "src" ], "start_line": 858, "end_line": 862, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir = None , libraries = None , library_dirs = None , runtime_library_dirs = None , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "fcompiler.py", "nloc": 45, "complexity": 12, "token_count": 331, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 555, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 1 } ], "nloc": 653, "complexity": 177, "token_count": 4410, "diff_parsed": { "added": [ "", " if type(self.objects) is type(''):", " ld_args = objects + [self.objects]", " else:", " ld_args = objects + self.objects", " ld_args = ld_args + lib_opts + o_args" ], "deleted": [ " ld_args = (objects + self.objects +", " lib_opts + o_args)" ] } } ] }, { "hash": "40eb4c06fbb8264ddf06928105d7c1344f5663f3", "msg": "Introduced asfarray.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-10-31T13:47:22+00:00", "author_timezone": 0, "committer_date": "2004-10-31T13:47:22+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e5b148d33a0e3a03036e036a6cd2bcfa13bc2d7a" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 1, "insertions": 9, "lines": 10, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/type_check.py", "new_path": "scipy_base/type_check.py", "filename": "type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -7,7 +7,8 @@\n __all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n- 'typename','cast','common_type','typecodes', 'asarray']\n+ 'typename','cast','common_type','typecodes', 'asarray',\n+ 'asfarray']\n \n def asarray(a, typecode=None, savespace=None):\n \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.\n@@ -24,6 +25,13 @@ def asarray(a, typecode=None, savespace=None):\n return r\n return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)\n \n+def asfarray(a, typecode=None, savespace=None):\n+ \"\"\"asfarray(a,typecode=None, savespace=0) returns a as a NumPy float array.\"\"\"\n+ a = asarray(a,typecode,savespace)\n+ if typecode is None and a.typecode() not in 'CFfd':\n+ return a.astype('d')\n+ return a\n+\n ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n \n typecodes = Numeric.typecodes\n", "added_lines": 9, "deleted_lines": 1, "source_code": "\nimport types\nimport Numeric\nfrom fastumath import isinf, isnan, isfinite\nfrom Numeric import ArrayType, array, multiarray\n\n__all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','cast','common_type','typecodes', 'asarray',\n 'asfarray']\n\ndef asarray(a, typecode=None, savespace=None):\n \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.\n Unlike array(), no copy is performed if a is already an array.\n \"\"\"\n if type(a) is ArrayType:\n if typecode is None or typecode == a.typecode():\n if savespace is None or a.spacesaver()==savespace:\n return a\n else:\n r = a.astype(typecode)\n if not (savespace is None or a.spacesaver()==savespace):\n r.savespace(savespace)\n return r\n return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)\n\ndef asfarray(a, typecode=None, savespace=None):\n \"\"\"asfarray(a,typecode=None, savespace=0) returns a as a NumPy float array.\"\"\"\n a = asarray(a,typecode,savespace)\n if typecode is None and a.typecode() not in 'CFfd':\n return a.astype('d')\n return a\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\ntypecodes = Numeric.typecodes\ntypecodes['AllInteger'] = '1silbwu'\n\ntry:\n Char = Numeric.Character\nexcept AttributeError:\n Char = 'c'\n\ntoChar = lambda x: asarray(x).astype(Char)\ntoInt8 = lambda x: asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\ntoUInt8 = lambda x: asarray(x).astype(Numeric.UnsignedInt8)\n_unsigned = 0\nif hasattr(Numeric,'UnsignedInt16'):\n toUInt16 = lambda x: asarray(x).astype(Numeric.UnsignedInt16)\n toUInt32 = lambda x: asarray(x).astype(Numeric.UnsignedInt32)\n _unsigned = 1\n \ntoInt16 = lambda x: asarray(x).astype(Numeric.Int16)\ntoInt32 = lambda x: asarray(x).astype(Numeric.Int32)\ntoInt = lambda x: asarray(x).astype(Numeric.Int)\ntoFloat32 = lambda x: asarray(x).astype(Numeric.Float32)\ntoFloat64 = lambda x: asarray(x).astype(Numeric.Float64)\ntoComplex32 = lambda x: asarray(x).astype(Numeric.Complex32)\ntoComplex64 = lambda x: asarray(x).astype(Numeric.Complex64)\n\n# This is for pre Numeric 21.x compatiblity. Adding it is harmless.\nif not hasattr(Numeric,'Character'):\n Numeric.Character = 'c'\n \ncast = {Numeric.Character: toChar,\n Numeric.UnsignedInt8: toUInt8,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\nif _unsigned:\n cast[Numeric.UnsignedInt16] = toUInt16\n cast[Numeric.UnsignedInt32] = toUInt32\n \n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef iscomplexobj(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef isrealobj(x):\n return not asarray(x).typecode() in ['F', 'D']\n\n#-----------------------------------------------------------------------------\n\n##def isnan(val):\n## # fast, but apparently not portable (according to notes by Tim Peters)\n## #return val != val\n## # very slow -- should really use cephes methods or *something* different\n## import ieee_754\n## vals = ravel(val)\n## if array_iscomplex(vals):\n## r = array(map(ieee_754.isnan,real(vals))) \n## i = array(map(ieee_754.isnan,imag(vals)))\n## results = Numeric.logical_or(r,i)\n## else: \n## results = array(map(ieee_754.isnan,vals))\n## if isscalar(val):\n## results = results[0]\n## return results\n\ndef isposinf(val):\n return isinf(val) & (val > 0)\n \ndef isneginf(val):\n return isinf(val) & (val < 0)\n \n##def isinf(val):\n## return Numeric.logical_or(isposinf(val),isneginf(val))\n\n##def isfinite(val):\n## vals = asarray(val)\n## if iscomplexobj(vals):\n## r = isfinite(real(vals))\n## i = isfinite(imag(vals))\n## results = Numeric.logical_and(r,i)\n## else: \n## fin = Numeric.logical_not(isinf(val))\n## an = Numeric.logical_not(isnan(val))\n## results = Numeric.logical_and(fin,an)\n## return results \n\ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,limits.double_min, 0., limits.double_max))\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=1e-13):\n a = asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'w' : 'unsigned short',\n 'i' : 'integer',\n 'u' : 'unsigned integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", "source_code_before": "\nimport types\nimport Numeric\nfrom fastumath import isinf, isnan, isfinite\nfrom Numeric import ArrayType, array, multiarray\n\n__all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','cast','common_type','typecodes', 'asarray']\n\ndef asarray(a, typecode=None, savespace=None):\n \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.\n Unlike array(), no copy is performed if a is already an array.\n \"\"\"\n if type(a) is ArrayType:\n if typecode is None or typecode == a.typecode():\n if savespace is None or a.spacesaver()==savespace:\n return a\n else:\n r = a.astype(typecode)\n if not (savespace is None or a.spacesaver()==savespace):\n r.savespace(savespace)\n return r\n return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\ntypecodes = Numeric.typecodes\ntypecodes['AllInteger'] = '1silbwu'\n\ntry:\n Char = Numeric.Character\nexcept AttributeError:\n Char = 'c'\n\ntoChar = lambda x: asarray(x).astype(Char)\ntoInt8 = lambda x: asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\ntoUInt8 = lambda x: asarray(x).astype(Numeric.UnsignedInt8)\n_unsigned = 0\nif hasattr(Numeric,'UnsignedInt16'):\n toUInt16 = lambda x: asarray(x).astype(Numeric.UnsignedInt16)\n toUInt32 = lambda x: asarray(x).astype(Numeric.UnsignedInt32)\n _unsigned = 1\n \ntoInt16 = lambda x: asarray(x).astype(Numeric.Int16)\ntoInt32 = lambda x: asarray(x).astype(Numeric.Int32)\ntoInt = lambda x: asarray(x).astype(Numeric.Int)\ntoFloat32 = lambda x: asarray(x).astype(Numeric.Float32)\ntoFloat64 = lambda x: asarray(x).astype(Numeric.Float64)\ntoComplex32 = lambda x: asarray(x).astype(Numeric.Complex32)\ntoComplex64 = lambda x: asarray(x).astype(Numeric.Complex64)\n\n# This is for pre Numeric 21.x compatiblity. Adding it is harmless.\nif not hasattr(Numeric,'Character'):\n Numeric.Character = 'c'\n \ncast = {Numeric.Character: toChar,\n Numeric.UnsignedInt8: toUInt8,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\nif _unsigned:\n cast[Numeric.UnsignedInt16] = toUInt16\n cast[Numeric.UnsignedInt32] = toUInt32\n \n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef iscomplexobj(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef isrealobj(x):\n return not asarray(x).typecode() in ['F', 'D']\n\n#-----------------------------------------------------------------------------\n\n##def isnan(val):\n## # fast, but apparently not portable (according to notes by Tim Peters)\n## #return val != val\n## # very slow -- should really use cephes methods or *something* different\n## import ieee_754\n## vals = ravel(val)\n## if array_iscomplex(vals):\n## r = array(map(ieee_754.isnan,real(vals))) \n## i = array(map(ieee_754.isnan,imag(vals)))\n## results = Numeric.logical_or(r,i)\n## else: \n## results = array(map(ieee_754.isnan,vals))\n## if isscalar(val):\n## results = results[0]\n## return results\n\ndef isposinf(val):\n return isinf(val) & (val > 0)\n \ndef isneginf(val):\n return isinf(val) & (val < 0)\n \n##def isinf(val):\n## return Numeric.logical_or(isposinf(val),isneginf(val))\n\n##def isfinite(val):\n## vals = asarray(val)\n## if iscomplexobj(vals):\n## r = isfinite(real(vals))\n## i = isfinite(imag(vals))\n## results = Numeric.logical_and(r,i)\n## else: \n## fin = Numeric.logical_not(isinf(val))\n## an = Numeric.logical_not(isnan(val))\n## results = Numeric.logical_and(fin,an)\n## return results \n\ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,limits.double_min, 0., limits.double_max))\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=1e-13):\n a = asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'w' : 'unsigned short',\n 'i' : 'integer',\n 'u' : 'unsigned integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", "methods": [ { "name": "asarray", "long_name": "asarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 11, "complexity": 9, "token_count": 103, "parameters": [ "a", "typecode", "savespace" ], "start_line": 13, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "asfarray", "long_name": "asfarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 47, "parameters": [ "a", "typecode", "savespace" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "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": 82, "end_line": 85, "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": 87, "end_line": 92, "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": 94, "end_line": 99, "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": 101, "end_line": 102, "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": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "x" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 134, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 117, "parameters": [ "x" ], "start_line": 152, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 1e - 13 )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 52, "parameters": [ "a", "tol" ], "start_line": 177, "end_line": 181, "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": 201, "end_line": 204, "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": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "asarray", "long_name": "asarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 11, "complexity": 9, "token_count": 103, "parameters": [ "a", "typecode", "savespace" ], "start_line": 12, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "isscalar", "long_name": "isscalar( num )", "filename": "type_check.py", "nloc": 4, "complexity": 3, "token_count": 37, "parameters": [ "num" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "real", "long_name": "real( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "val" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "imag", "long_name": "imag( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "val" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iscomplex", "long_name": "iscomplex( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isreal", "long_name": "isreal( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "x" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 117, "parameters": [ "x" ], "start_line": 144, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 1e - 13 )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 52, "parameters": [ "a", "tol" ], "start_line": 169, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "typename", "long_name": "typename( char )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "char" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "common_type", "long_name": "common_type( * arrays )", "filename": "type_check.py", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "arrays" ], "start_line": 204, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "asfarray", "long_name": "asfarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 47, "parameters": [ "a", "typecode", "savespace" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 144, "complexity": 34, "token_count": 1181, "diff_parsed": { "added": [ " 'typename','cast','common_type','typecodes', 'asarray',", " 'asfarray']", "def asfarray(a, typecode=None, savespace=None):", " \"\"\"asfarray(a,typecode=None, savespace=0) returns a as a NumPy float array.\"\"\"", " a = asarray(a,typecode,savespace)", " if typecode is None and a.typecode() not in 'CFfd':", " return a.astype('d')", " return a", "" ], "deleted": [ " 'typename','cast','common_type','typecodes', 'asarray']" ] } } ] }, { "hash": "7fad517ca39ee524c5d50756ae80ee1624884aa5", "msg": "Fixed atlas,lapack names for freebsd.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-11-02T00:36:00+00:00", "author_timezone": 0, "committer_date": "2004-11-02T00:36:00+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "40eb4c06fbb8264ddf06928105d7c1344f5663f3" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 3, "insertions": 11, "lines": 14, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -543,6 +543,13 @@ class atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n+ if sys.platform[:7]=='freebsd':\n+ _lib_atlas = ['atlas_r']\n+ _lib_lapack = ['alapack_r']\n+ else:\n+ _lib_atlas = ['atlas']\n+ _lib_lapack = ['lapack']\n+\n notfounderror = AtlasNotFoundError\n \n def get_paths(self, section, key):\n@@ -557,8 +564,8 @@ def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n- self._lib_names + ['atlas'])\n- lapack_libs = self.get_libs('lapack_libs',['lapack'])\n+ self._lib_names + self._lib_atlas)\n+ lapack_libs = self.get_libs('lapack_libs',self._lib_lapack)\n atlas = None\n lapack = None\n atlas_1 = None\n@@ -641,7 +648,7 @@ def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n- self._lib_names + ['atlas'])\n+ self._lib_names + self._lib_atlas)\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n@@ -661,6 +668,7 @@ def calc_info(self):\n self.set_info(**info)\n return\n \n+\n class atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n \n", "added_lines": 11, "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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n ds = d.split(os.pathsep)\n ds2 = []\n for d in ds:\n if os.path.isdir(d):\n ds2.append(d)\n for dd in ['include','lib']:\n d1 = os.path.join(d,dd)\n if os.path.isdir(d1):\n ds2.append(d1)\n dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n if sys.platform[:7]=='freebsd':\n _lib_atlas = ['atlas_r']\n _lib_lapack = ['alapack_r']\n else:\n _lib_atlas = ['atlas']\n _lib_lapack = ['lapack']\n\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + self._lib_atlas)\n lapack_libs = self.get_libs('lapack_libs',self._lib_lapack)\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + self._lib_atlas)\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n\t\tif atlas_version=='3.2.1_pre3.3.6':\n\t\t atlas_info['define_macros'].append(('NO_ATLAS_INFO',4))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\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\n atlas_info\n atlas_threads_info\n atlas_blas_info\n atlas_blas_threads_info\n lapack_atlas_info\n blas_info\n lapack_info\n blas_opt_info # usage recommended\n lapack_opt_info # usage recommended\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n numpy_info\n numarray_info\n boost_python_info\n agg2_info\n wx_info\n gdk_pixbuf_xlib_2_info\n gdk_pixbuf_2_info\n gdk_x11_2_info\n gtkp_x11_2_info\n gtkp_2_info\n xft_info\n freetype2_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', 'blas_src', etc. For a complete list of allowed names,\n see the definition of get_info() function below.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\n Several *_info classes specify an environment variable to specify\n the locations of software. When setting the corresponding environment\n variable to 'None' then the software will be ignored, even when it\n is available in system.\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\n__revision__ = '$Id$'\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = ['.']\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib',\n '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/sw/include']\n default_src_dirs = ['.','/usr/local/src', '/opt/src','/sw/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name,notfound_action=0):\n \"\"\"\n notfound_action:\n 0 - do nothing\n 1 - display warning message\n 2 - raise error\n \"\"\"\n cl = {'atlas':atlas_info, # use lapack_opt or blas_opt instead\n 'atlas_threads':atlas_threads_info, # ditto\n 'atlas_blas':atlas_blas_info,\n 'atlas_blas_threads':atlas_blas_threads_info,\n 'lapack_atlas':lapack_atlas_info, # use lapack_opt instead\n 'lapack_atlas_threads':lapack_atlas_threads_info, # ditto\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info, # use blas_opt instead\n 'lapack':lapack_info, # use lapack_opt instead\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n 'numpy':numpy_info,\n 'numarray':numarray_info,\n 'lapack_opt':lapack_opt_info,\n 'blas_opt':blas_opt_info,\n 'boost_python':boost_python_info,\n 'agg2':agg2_info,\n 'wx':wx_info,\n 'gdk_pixbuf_xlib_2':gdk_pixbuf_xlib_2_info,\n 'gdk-pixbuf-xlib-2.0':gdk_pixbuf_xlib_2_info,\n 'gdk_pixbuf_2':gdk_pixbuf_2_info,\n 'gdk-pixbuf-2.0':gdk_pixbuf_2_info,\n 'gdk':gdk_info,\n 'gdk_2':gdk_2_info,\n 'gdk-2.0':gdk_2_info,\n 'gdk_x11_2':gdk_x11_2_info,\n 'gdk-x11-2.0':gdk_x11_2_info,\n 'gtkp_x11_2':gtkp_x11_2_info,\n 'gtk+-x11-2.0':gtkp_x11_2_info,\n 'gtkp_2':gtkp_2_info,\n 'gtk+-2.0':gtkp_2_info,\n 'xft':xft_info,\n 'freetype2':freetype2_info,\n }.get(name.lower(),system_info)\n return cl().get_info(notfound_action)\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n notfounderror = NotFoundError\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n try:\n __file__\n except NameError:\n __file__ = sys.argv[0]\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self,notfound_action=0):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if notfound_action:\n if not self.has_info():\n if notfound_action==1:\n warnings.warn(self.notfounderror.__doc__)\n elif notfound_action==2:\n raise self.notfounderror,self.notfounderror.__doc__\n else:\n raise ValueError,`notfound_action`\n\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n \n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n \n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if self.dir_env_var and os.environ.has_key(self.dir_env_var):\n d = os.environ[self.dir_env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' % (self.dir_env_var)\n return []\n if os.path.isfile(d):\n dirs = [os.path.dirname(d)] + dirs\n l = getattr(self,'_lib_names',[])\n if len(l)==1:\n b = os.path.basename(d)\n b = os.path.splitext(b)[0]\n if b[:3]=='lib':\n print 'Replacing _lib_names[0]==%r with %r' \\\n % (self._lib_names[0], b[3:])\n self._lib_names[0] = b[3:]\n else:\n ds = d.split(os.pathsep)\n ds2 = []\n for d in ds:\n if os.path.isdir(d):\n ds2.append(d)\n for dd in ['include','lib']:\n d1 = os.path.join(d,dd)\n if os.path.isdir(d1):\n ds2.append(d1)\n dirs = ds2 + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n if sys.platform=='cygwin':\n exts.append('.dll.a')\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n notfounderror = FFTWNotFoundError\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n notfounderror = DJBFFTNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n notfounderror = AtlasNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse','3dnow','sse2'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n atlas_1 = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n lapack_atlas = self.check_libs(d,['lapack_atlas'],[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas:\n atlas_1 = atlas\n print self.__class__\n if atlas is None:\n atlas = atlas_1\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n elif 'lapack_atlas' in atlas['libraries']:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITH_LAPACK_ATLAS',None)])\n self.set_info(**info)\n return\n else:\n dict_append(info,**atlas)\n dict_append(info,define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n else:\n info['language'] = 'f77'\n\n self.set_info(**info)\n\nclass atlas_blas_info(atlas_info):\n _lib_names = ['f77blas','cblas']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n atlas = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n info['language'] = 'c'\n\n dict_append(info,**atlas)\n\n self.set_info(**info)\n return\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_atlas_info(atlas_info):\n _lib_names = ['lapack_atlas'] + atlas_info._lib_names\n\nclass lapack_atlas_threads_info(atlas_threads_info):\n _lib_names = ['lapack_atlas'] + atlas_threads_info._lib_names\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n _lib_names = ['lapack']\n notfounderror = LapackNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', self._lib_names)\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 info['language'] = 'f77'\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n notfounderror = LapackSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\natlas_version_c_text = r'''\n/* This file is generated from scipy_distutils/system_info.py */\n#ifdef __CPLUSPLUS__\nextern \"C\" {\n#endif\n#include \"Python.h\"\nstatic PyMethodDef module_methods[] = { {NULL,NULL} };\nDL_EXPORT(void) initatlas_version(void) {\n void ATL_buildinfo(void);\n ATL_buildinfo();\n Py_InitModule(\"atlas_version\", module_methods);\n}\n#ifdef __CPLUSCPLUS__\n}\n#endif\n'''\n\ndef get_atlas_version(**config):\n from core import Extension, setup\n from misc_util import get_build_temp\n import log\n magic = hex(hash(`config`))\n def atlas_version_c(extension, build_dir,magic=magic):\n source = os.path.join(build_dir,'atlas_version_%s.c' % (magic))\n if os.path.isfile(source):\n from distutils.dep_util import newer\n if newer(source,__file__):\n return source\n f = open(source,'w')\n f.write(atlas_version_c_text)\n f.close()\n return source\n ext = Extension('atlas_version',\n sources=[atlas_version_c],\n **config)\n extra_args = ['--build-lib',get_build_temp()]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n return None\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n build_ext = dist.get_command_obj('build_ext')\n target = os.path.join(build_ext.build_lib,'atlas_version'+so_ext)\n from exec_command import exec_command,get_pythonexe\n cmd = [get_pythonexe(),'-c',\n '\"import imp;imp.load_dynamic(\\\\\"atlas_version\\\\\",\\\\\"%s\\\\\")\"'\\\n % (os.path.basename(target))]\n s,o = exec_command(cmd,execute_in=os.path.dirname(target),use_tee=0)\n atlas_version = None\n if not s:\n m = re.match(r'ATLAS version (?P\\d+[.]\\d+[.]\\d+)',o)\n if m:\n atlas_version = m.group('version')\n if atlas_version is None:\n if re.search(r'undefined symbol: ATL_buildinfo',o,re.M):\n atlas_version = '3.2.1_pre3.3.6'\n else:\n print 'Command:',' '.join(cmd)\n print 'Status:',s\n print 'Output:',o\n return atlas_version\n\n\nclass lapack_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas')\n #atlas_info = {} ## uncomment for testing\n atlas_version = None\n need_lapack = 0\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n\t\tif atlas_version=='3.2.1_pre3.3.6':\n\t\t atlas_info['define_macros'].append(('NO_ATLAS_INFO',4))\n l = atlas_info.get('define_macros',[])\n if ('ATLAS_WITH_LAPACK_ATLAS',None) in l \\\n or ('ATLAS_WITHOUT_LAPACK',None) in l:\n need_lapack = 1\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n need_lapack = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_lapack:\n lapack_info = get_info('lapack')\n #lapack_info = {} ## uncomment for testing\n if lapack_info:\n dict_append(info,**lapack_info)\n else:\n warnings.warn(LapackNotFoundError.__doc__)\n lapack_src_info = get_info('lapack_src')\n if not lapack_src_info:\n warnings.warn(LapackSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('flapack_src',lapack_src_info)])\n\n if need_blas:\n blas_info = get_info('blas')\n #blas_info = {} ## uncomment for testing\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_opt_info(system_info):\n \n def calc_info(self):\n\n if sys.platform=='darwin' and not os.environ.get('ATLAS',None):\n args = []\n link_args = []\n if os.path.exists('/System/Library/Frameworks/Accelerate.framework/'):\n args.extend(['-faltivec','-framework','Accelerate'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec','-framework','vecLib'])\n link_args.extend(['-Wl,-framework','-Wl,vecLib'])\n if args:\n self.set_info(extra_compile_args=args,\n extra_link_args=link_args,\n define_macros=[('NO_ATLAS_INFO',3)])\n return\n\n atlas_info = get_info('atlas_blas_threads')\n if not atlas_info:\n atlas_info = get_info('atlas_blas')\n atlas_version = None\n need_blas = 0\n info = {}\n if atlas_info:\n version_info = atlas_info.copy()\n version_info['libraries'] = [version_info['libraries'][-1]]\n atlas_version = get_atlas_version(**version_info)\n if not atlas_info.has_key('define_macros'):\n atlas_info['define_macros'] = []\n if atlas_version is None:\n atlas_info['define_macros'].append(('NO_ATLAS_INFO',2))\n else:\n atlas_info['define_macros'].append(('ATLAS_INFO',\n '\"\\\\\"%s\\\\\"\"' % atlas_version))\n info = atlas_info\n else:\n warnings.warn(AtlasNotFoundError.__doc__)\n need_blas = 1\n dict_append(info,define_macros=[('NO_ATLAS_INFO',1)])\n\n if need_blas:\n blas_info = get_info('blas')\n if blas_info:\n dict_append(info,**blas_info)\n else:\n warnings.warn(BlasNotFoundError.__doc__)\n blas_src_info = get_info('blas_src')\n if not blas_src_info:\n warnings.warn(BlasSrcNotFoundError.__doc__)\n return\n dict_append(info,libraries=[('fblas_src',blas_src_info)])\n\n self.set_info(**info)\n return\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n _lib_names = ['blas']\n notfounderror = BlasNotFoundError\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', self._lib_names)\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n info['language'] = 'f77' # XXX: is it generally true?\n self.set_info(**info)\n\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n notfounderror = BlasSrcNotFoundError\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources,'language':'f77'}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n notfounderror = X11NotFoundError\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\nclass numpy_info(system_info):\n section = 'numpy'\n modulename = 'Numeric'\n notfounderror = NumericNotFoundError\n\n def __init__(self):\n from distutils.sysconfig import get_python_inc\n include_dirs = []\n try:\n module = __import__(self.modulename)\n prefix = []\n for name in module.__file__.split(os.sep):\n if name=='lib':\n break\n prefix.append(name)\n include_dirs.append(get_python_inc(prefix=os.sep.join(prefix)))\n except ImportError:\n pass\n py_incl_dir = get_python_inc()\n include_dirs.append(py_incl_dir)\n for d in default_include_dirs:\n d = os.path.join(d, os.path.basename(py_incl_dir))\n if d not in include_dirs:\n include_dirs.append(d)\n system_info.__init__(self,\n default_lib_dirs=[],\n default_include_dirs=include_dirs)\n\n def calc_info(self):\n try:\n module = __import__(self.modulename)\n except ImportError:\n return\n info = {}\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (module.__version__))]\n## try:\n## macros.append(\n## (self.modulename.upper()+'_VERSION_HEX',\n## hex(vstr2hex(module.__version__))),\n## )\n## except Exception,msg:\n## print msg\n dict_append(info, define_macros = macros)\n include_dirs = self.get_include_dirs()\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d,\n os.path.join(self.modulename,\n 'arrayobject.h')):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n if info:\n self.set_info(**info)\n return\n\nclass numarray_info(numpy_info):\n section = 'numarray'\n modulename = 'numarray'\n\nclass boost_python_info(system_info):\n section = 'boost_python'\n dir_env_var = 'BOOST'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['boost*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n from distutils.sysconfig import get_python_inc\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'libs','python','src','module.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n py_incl_dir = get_python_inc()\n srcs_dir = os.path.join(src_dir,'libs','python','src')\n bpl_srcs = glob(os.path.join(srcs_dir,'*.cpp'))\n bpl_srcs += glob(os.path.join(srcs_dir,'*','*.cpp'))\n info = {'libraries':[('boost_python_src',{'include_dirs':[src_dir,py_incl_dir],\n 'sources':bpl_srcs})],\n 'include_dirs':[src_dir],\n }\n if info:\n self.set_info(**info)\n return\n\nclass agg2_info(system_info):\n section = 'agg2'\n dir_env_var = 'AGG2'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['agg2*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'src','agg_affine_matrix.cpp')):\n src_dir = d\n break\n if not src_dir:\n return\n if sys.platform=='win32':\n agg2_srcs = glob(os.path.join(src_dir,'src','platform','win32','agg_win32_bmp.cpp'))\n else:\n agg2_srcs = glob(os.path.join(src_dir,'src','*.cpp'))\n agg2_srcs += [os.path.join(src_dir,'src','platform','X11','agg_platform_support.cpp')]\n \n info = {'libraries':[('agg2_src',{'sources':agg2_srcs,\n 'include_dirs':[os.path.join(src_dir,'include')],\n })],\n 'include_dirs':[os.path.join(src_dir,'include')],\n }\n if info:\n self.set_info(**info)\n return\n\nclass _pkg_config_info(system_info):\n section = None\n config_env_var = 'PKG_CONFIG'\n default_config_exe = 'pkg-config'\n append_config_exe = ''\n version_macro_name = None\n release_macro_name = None\n version_flag = '--modversion'\n cflags_flag = '--cflags'\n\n def get_config_exe(self):\n if os.environ.has_key(self.config_env_var):\n return os.environ[self.config_env_var]\n return self.default_config_exe\n def get_config_output(self, config_exe, option):\n s,o = exec_command(config_exe+' '+self.append_config_exe+' '+option,use_tee=0)\n if not s:\n return o\n\n def calc_info(self):\n config_exe = find_executable(self.get_config_exe())\n if not os.path.isfile(config_exe):\n print 'File not found: %s. Cannot determine %s info.' \\\n % (config_exe, self.section)\n return\n info = {}\n macros = []\n libraries = []\n library_dirs = []\n include_dirs = []\n extra_link_args = []\n extra_compile_args = []\n version = self.get_config_output(config_exe,self.version_flag)\n if version:\n macros.append((self.__class__.__name__.split('.')[-1].upper(),\n '\"\\\\\"%s\\\\\"\"' % (version)))\n if self.version_macro_name:\n macros.append((self.version_macro_name+'_%s' % (version.replace('.','_')),None))\n if self.release_macro_name:\n release = self.get_config_output(config_exe,'--release')\n if release:\n macros.append((self.release_macro_name+'_%s' % (release.replace('.','_')),None))\n opts = self.get_config_output(config_exe,'--libs')\n if opts:\n for opt in opts.split():\n if opt[:2]=='-l':\n libraries.append(opt[2:])\n elif opt[:2]=='-L':\n library_dirs.append(opt[2:])\n else:\n extra_link_args.append(opt)\n opts = self.get_config_output(config_exe,self.cflags_flag)\n if opts:\n for opt in opts.split():\n if opt[:2]=='-I':\n include_dirs.append(opt[2:])\n elif opt[:2]=='-D':\n if '=' in opt:\n n,v = opt[2:].split('=')\n macros.append((n,v))\n else:\n macros.append((opt[2:],None))\n else:\n extra_compile_args.append(opt)\n if macros: dict_append(info, define_macros = macros)\n if libraries: dict_append(info, libraries = libraries)\n if library_dirs: dict_append(info, library_dirs = library_dirs)\n if include_dirs: dict_append(info, include_dirs = include_dirs)\n if extra_link_args: dict_append(info, extra_link_args = extra_link_args)\n if extra_compile_args: dict_append(info, extra_compile_args = extra_compile_args)\n if info:\n self.set_info(**info)\n return\n\nclass wx_info(_pkg_config_info):\n section = 'wx'\n config_env_var = 'WX_CONFIG'\n default_config_exe = 'wx-config'\n append_config_exe = ''\n version_macro_name = 'WX_VERSION'\n release_macro_name = 'WX_RELEASE'\n version_flag = '--version'\n cflags_flag = '--cxxflags'\n\nclass gdk_pixbuf_xlib_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_xlib_2'\n append_config_exe = 'gdk-pixbuf-xlib-2.0'\n version_macro_name = 'GDK_PIXBUF_XLIB_VERSION'\n\nclass gdk_pixbuf_2_info(_pkg_config_info):\n section = 'gdk_pixbuf_2'\n append_config_exe = 'gdk-pixbuf-2.0'\n version_macro_name = 'GDK_PIXBUF_VERSION'\n\nclass gdk_x11_2_info(_pkg_config_info):\n section = 'gdk_x11_2'\n append_config_exe = 'gdk-x11-2.0'\n version_macro_name = 'GDK_X11_VERSION'\n\nclass gdk_2_info(_pkg_config_info):\n section = 'gdk_2'\n append_config_exe = 'gdk-2.0'\n version_macro_name = 'GDK_VERSION'\n\nclass gdk_info(_pkg_config_info):\n section = 'gdk'\n append_config_exe = 'gdk'\n version_macro_name = 'GDK_VERSION'\n\nclass gtkp_x11_2_info(_pkg_config_info):\n section = 'gtkp_x11_2'\n append_config_exe = 'gtk+-x11-2.0'\n version_macro_name = 'GTK_X11_VERSION'\n\n\nclass gtkp_2_info(_pkg_config_info):\n section = 'gtkp_2'\n append_config_exe = 'gtk+-2.0'\n version_macro_name = 'GTK_VERSION'\n\nclass xft_info(_pkg_config_info):\n section = 'xft'\n append_config_exe = 'xft'\n version_macro_name = 'XFT_VERSION'\n\nclass freetype2_info(_pkg_config_info):\n section = 'freetype2'\n append_config_exe = 'freetype2'\n version_macro_name = 'FREETYPE2_VERSION'\n\n## def vstr2hex(version):\n## bits = []\n## n = [24,16,8,4,0]\n## r = 0\n## for s in version.split('.'):\n## r |= int(s) << n[0]\n## del n[0]\n## return r\n\n#--------------------------------------------------------------------\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\nlanguage_map = {'c':0,'c++':1,'f77':2,'f90':3}\ninv_language_map = {0:'c',1:'c++',2:'f77',3:'f90'}\ndef dict_append(d,**kws):\n languages = []\n for k,v in kws.items():\n if k=='language':\n languages.append(v)\n continue\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n if languages:\n l = inv_language_map[max([language_map.get(l,0) for l in languages])]\n d['language'] = l\n return\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n if 0:\n c = gdk_pixbuf_2_info()\n c.verbosity = 2\n c.get_info()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 377, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 380, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 393, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 420, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 445, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 512, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 519, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 555, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 563, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 647, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 690, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 709, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 716, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 824, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 819, "end_line": 873, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 69, "complexity": 19, "token_count": 449, "parameters": [ "self" ], "start_line": 878, "end_line": 954, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 959, "end_line": 1012, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1021, "end_line": 1033, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1041, "end_line": 1046, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1048, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1089, "end_line": 1092, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1094, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1120, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1143, "end_line": 1171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1181, "end_line": 1186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1188, "end_line": 1208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1214, "end_line": 1219, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1221, "end_line": 1243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1255, "end_line": 1258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1259, "end_line": 1262, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1264, "end_line": 1317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1386, "end_line": 1410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1414, "end_line": 1430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1432, "end_line": 1440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name , notfound_action = 0 )", "filename": "system_info.py", "nloc": 43, "complexity": 1, "token_count": 194, "parameters": [ "name", "notfound_action" ], "start_line": 144, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 49, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 25, "complexity": 3, "token_count": 200, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 272, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 298, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 301, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self , notfound_action = 0 )", "filename": "system_info.py", "nloc": 30, "complexity": 15, "token_count": 206, "parameters": [ "self", "notfound_action" ], "start_line": 304, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 35, "complexity": 15, "token_count": 341, "parameters": [ "self", "section", "key" ], "start_line": 341, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 377, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 380, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 10, "complexity": 5, "token_count": 76, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 393, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 406, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 420, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 431, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 445, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 512, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 519, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 74, "parameters": [ "self", "section", "key" ], "start_line": 548, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 556, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 6, "token_count": 138, "parameters": [ "self" ], "start_line": 640, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 682, "end_line": 694, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 232, "parameters": [ "self" ], "start_line": 708, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "get_atlas_version.atlas_version_c", "long_name": "get_atlas_version.atlas_version_c( extension , build_dir , magic = magic )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 74, "parameters": [ "extension", "build_dir", "magic" ], "start_line": 816, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_atlas_version", "long_name": "get_atlas_version( ** config )", "filename": "system_info.py", "nloc": 45, "complexity": 9, "token_count": 289, "parameters": [ "config" ], "start_line": 811, "end_line": 865, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 69, "complexity": 19, "token_count": 449, "parameters": [ "self" ], "start_line": 870, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 77, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 50, "complexity": 13, "token_count": 331, "parameters": [ "self" ], "start_line": 951, "end_line": 1004, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "self" ], "start_line": 1013, "end_line": 1025, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1033, "end_line": 1038, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 106, "parameters": [ "self" ], "start_line": 1040, "end_line": 1075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 1081, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 114, "parameters": [ "self" ], "start_line": 1086, "end_line": 1105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 139, "parameters": [ "self" ], "start_line": 1112, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 6, "token_count": 121, "parameters": [ "self" ], "start_line": 1135, "end_line": 1163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1173, "end_line": 1178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 5, "token_count": 156, "parameters": [ "self" ], "start_line": 1180, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 1206, "end_line": 1211, "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": 22, "complexity": 6, "token_count": 177, "parameters": [ "self" ], "start_line": 1213, "end_line": 1235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_config_exe", "long_name": "get_config_exe( self )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 1247, "end_line": 1250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_config_output", "long_name": "get_config_output( self , config_exe , option )", "filename": "system_info.py", "nloc": 4, "complexity": 2, "token_count": 37, "parameters": [ "self", "config_exe", "option" ], "start_line": 1251, "end_line": 1254, "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": 54, "complexity": 22, "token_count": 435, "parameters": [ "self" ], "start_line": 1256, "end_line": 1309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 1378, "end_line": 1402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 17, "complexity": 9, "token_count": 128, "parameters": [ "d", "kws" ], "start_line": 1406, "end_line": 1422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 1424, "end_line": 1432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 78, "complexity": 17, "token_count": 441, "parameters": [ "self" ], "start_line": 563, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 80, "top_nesting_level": 1 } ], "nloc": 1274, "complexity": 264, "token_count": 7046, "diff_parsed": { "added": [ " if sys.platform[:7]=='freebsd':", " _lib_atlas = ['atlas_r']", " _lib_lapack = ['alapack_r']", " else:", " _lib_atlas = ['atlas']", " _lib_lapack = ['lapack']", "", " self._lib_names + self._lib_atlas)", " lapack_libs = self.get_libs('lapack_libs',self._lib_lapack)", " self._lib_names + self._lib_atlas)", "" ], "deleted": [ " self._lib_names + ['atlas'])", " lapack_libs = self.get_libs('lapack_libs',['lapack'])", " self._lib_names + ['atlas'])" ] } } ] }, { "hash": "92a567734599080b8c7a086d7a2a21d7cf1a15c1", "msg": "Impl. inverse hyperbolic functions (copy from Numeric), freebsd seem not to have them.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-11-02T00:37:50+00:00", "author_timezone": 0, "committer_date": "2004-11-02T00:37:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7fad517ca39ee524c5d50756ae80ee1624884aa5" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 54, "lines": 54, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumath_nounsigned.inc", "new_path": "scipy_base/fastumath_nounsigned.inc", "filename": "fastumath_nounsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -45,6 +45,33 @@ extern double modf (double, double *);\n #define M_PI 3.1415926535897931\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 (xx < 0.0) {\n+ sign = -1;\n+ x = -xx;\n+ }\n+ else {\n+ sign = 1;\n+ x = 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 \n #define ABS(x) ((x) < 0 ? -(x) : (x))\n \n", "added_lines": 27, "deleted_lines": 0, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n#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 (xx < 0.0) {\n sign = -1;\n x = -xx;\n }\n else {\n sign = 1;\n x = 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\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, INT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, INT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\n\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_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 logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod_;\n multiply_data[8] = (void *)c_prod_;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n /*\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 */\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow_;\n power_data[8] = (void *)c_pow_;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[7] = (void *)c_quot_fast;\n true_divide_data[8] = (void *)c_quot_fast;\n true_divide_data[9] = (void *)PyNumber_TrueDivide;\n true_divide_functions[7] = fastumath_FF_F_As_DD_D;\n true_divide_functions[8] = fastumath_DD_D;\n true_divide_functions[9] = PyUFunc_OO_O;\n\n floor_divide_data[7] = (void *)c_quot_floor_fast;\n floor_divide_data[8] = (void *)c_quot_floor_fast;\n floor_divide_data[9] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[7] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[8] = fastumath_DD_D;\n floor_divide_functions[9] = PyUFunc_OO_O;\n#endif\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, INT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, INT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\n\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_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 logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod_;\n multiply_data[8] = (void *)c_prod_;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n /*\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 */\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow_;\n power_data[8] = (void *)c_pow_;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[7] = (void *)c_quot_fast;\n true_divide_data[8] = (void *)c_quot_fast;\n true_divide_data[9] = (void *)PyNumber_TrueDivide;\n true_divide_functions[7] = fastumath_FF_F_As_DD_D;\n true_divide_functions[8] = fastumath_DD_D;\n true_divide_functions[9] = PyUFunc_OO_O;\n\n floor_divide_data[7] = (void *)c_quot_floor_fast;\n floor_divide_data[8] = (void *)c_quot_floor_fast;\n floor_divide_data[9] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[7] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[8] = fastumath_DD_D;\n floor_divide_functions[9] = PyUFunc_OO_O;\n#endif\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "#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 (xx < 0.0) {", " sign = -1;", " x = -xx;", " }", " else {", " sign = 1;", " x = 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", "" ], "deleted": [] } }, { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -54,6 +54,33 @@ extern double modf (double, double *);\n #define M_PI 3.1415926535897931\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 (xx < 0.0) {\n+ sign = -1;\n+ x = -xx;\n+ }\n+ else {\n+ sign = 1;\n+ x = 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 \n #define ABS(x) ((x) < 0 ? -(x) : (x))\n \n", "added_lines": 27, "deleted_lines": 0, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n#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 (xx < 0.0) {\n sign = -1;\n x = -xx;\n }\n else {\n sign = 1;\n x = 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\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *) NULL, (void *) NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod_;\n multiply_data[10] = (void *)c_prod_;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n /* need to add and worry \n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n */\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow_;\n power_data[10] = (void *)c_pow_;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[8] = PyUFunc_dd_d;\n remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = fastumath_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *) NULL, (void *) NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod_;\n multiply_data[10] = (void *)c_prod_;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n /* need to add and worry \n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n */\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow_;\n power_data[10] = (void *)c_pow_;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[8] = PyUFunc_dd_d;\n remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = fastumath_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, logical_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "#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 (xx < 0.0) {", " sign = -1;", " x = -xx;", " }", " else {", " sign = 1;", " x = 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", "" ], "deleted": [] } } ] }, { "hash": "c93e129cda9a1f380bb3abdeb481284086a53982", "msg": "Force -UHAVE_INVERSE_HYPERBOLIC on freebsd4 and win32.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-11-02T07:07:51+00:00", "author_timezone": 0, "committer_date": "2004-11-02T07:07:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "92a567734599080b8c7a086d7a2a21d7cf1a15c1" ], "project_name": "repo_copy", "project_path": "/tmp/tmppng3nd2e/repo_copy", "deletions": 0, "insertions": 7, "lines": 7, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -33,12 +33,19 @@ def configuration(parent_package='',parent_path=None):\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n+ undef_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n+ if sys.platform in ['freebsd4','win32']:\n+ undef_macros.append('HAVE_INVERSE_HYPERBOLIC')\n+ else:\n+ define_macros.append(('HAVE_INVERSE_HYPERBOLIC',None))\n+\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n+ undef_macros = undef_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n", "added_lines": 7, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n undef_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n if sys.platform in ['freebsd4','win32']:\n undef_macros.append('HAVE_INVERSE_HYPERBOLIC')\n else:\n define_macros.append(('HAVE_INVERSE_HYPERBOLIC',None))\n\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n undef_macros = undef_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n depends = ['_scipy_mapping.c','_scipy_number.c']\n depends = [os.path.join(local_path,x) for x in depends]\n\n ext = Extension(dot_join(package,'_compiled_base'),sources,\n depends = depends)\n config['ext_modules'].append(ext)\n\n # display_test module\n sources = [os.path.join(local_path,'src','display_test.c')]\n x11 = get_info('x11')\n if x11:\n x11['define_macros'] = [('HAVE_X11',None)]\n ext = Extension(dot_join(package,'display_test'), sources, **x11)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.system_info import get_info, NumericNotFoundError\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n numpy_info = get_info('numpy')\n if not numpy_info:\n raise NumericNotFoundError, NumericNotFoundError.__doc__\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args,\n depends = umath_c_sources)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n depends = ['_scipy_mapping.c','_scipy_number.c']\n depends = [os.path.join(local_path,x) for x in depends]\n\n ext = Extension(dot_join(package,'_compiled_base'),sources,\n depends = depends)\n config['ext_modules'].append(ext)\n\n # display_test module\n sources = [os.path.join(local_path,'src','display_test.c')]\n x11 = get_info('x11')\n if x11:\n x11['define_macros'] = [('HAVE_X11',None)]\n ext = Extension(dot_join(package,'display_test'), sources, **x11)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n from scipy_distutils.core import setup\n\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 50, "complexity": 8, "token_count": 397, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 44, "complexity": 7, "token_count": 360, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 58, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 50, "complexity": 8, "token_count": 397, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 0 } ], "nloc": 65, "complexity": 8, "token_count": 458, "diff_parsed": { "added": [ " undef_macros = []", " if sys.platform in ['freebsd4','win32']:", " undef_macros.append('HAVE_INVERSE_HYPERBOLIC')", " else:", " define_macros.append(('HAVE_INVERSE_HYPERBOLIC',None))", "", " undef_macros = undef_macros," ], "deleted": [] } } ] } ]