diff --git "a/partition_89.json" "b/partition_89.json" new file mode 100644--- /dev/null +++ "b/partition_89.json" @@ -0,0 +1,74347 @@ +[ + { + "hash": "698a593861f8a9c4f2346e456eee978393bf5595", + "msg": "Fix restoring distutils.core globals on setup failure.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T07:35:43+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T07:35:43+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1f1b3b4fca312fe3c17b72845af0a84711d83469" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/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": "numpy/distutils/system_info.py", + "new_path": "numpy/distutils/system_info.py", + "filename": "system_info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1103,18 +1103,22 @@ def atlas_version_c(extension, build_dir,magic=magic):\n import distutils.core\n old_dist = distutils.core._setup_distribution\n distutils.core._setup_distribution = None\n+ return_flag = True\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n+ return_flag = False\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 distutils.core._setup_distribution = old_dist\n \n+ if return_flag:\n+ return\n+\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n target = os.path.join(build_dir,'atlas_version'+so_ext)\n", + "added_lines": 5, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n\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 numpy_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 umfpack_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' is looked for in\n\n1) Directory of main setup.py file being run.\n2) Home directory of user running the setup.py file (Not implemented yet)\n3) System wide directory (location of this file...)\n\nThe first one found is used to get system configuration options The\nformat is that used by ConfigParser (i.e., Windows .INI style). The\nsection DEFAULT has options that are the default for each section. The\navailable sections are fftw, atlas, and x11. Appropiate defaults are\nused if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command, get_pythonexe\nfrom numpy.distutils.misc_util import is_sequence, is_string\nimport distutils.sysconfig\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\',\n os.path.join(distutils.sysconfig.EXEC_PREFIX,\n 'libs')]\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 '/opt/local/lib', '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/opt/local/include', '/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_standard_file(fname):\n \"\"\"Returns a list of files named 'fname' from\n 1) System-wide directory (directory-location of this module)\n 2) Users HOME directory (os.environ['HOME'])\n 3) Local directory\n \"\"\"\n # System-wide file\n filenames = []\n try:\n f = __file__\n except NameError:\n f = sys.argv[0]\n else:\n sysfile = os.path.join(os.path.split(os.path.abspath(f))[0],\n fname)\n if os.path.isfile(sysfile):\n filenames.append(sysfile)\n\n # Home directory\n # And look for the user config file\n try:\n f = os.environ['HOME']\n except KeyError:\n pass\n else:\n user_file = os.path.join(f, fname)\n if os.path.isfile(user_file):\n filenames.append(user_file)\n\n # Local file\n if os.path.isfile(fname):\n filenames.append(os.path.abspath(fname))\n\n return filenames\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 'mkl':mkl_info,\n 'lapack_mkl':lapack_mkl_info, # use lapack_opt instead\n 'blas_mkl':blas_mkl_info, # use blas_opt instead\n 'x11':x11_info,\n 'fft_opt':fft_opt_info,\n 'fftw':fftw_info,\n 'fftw2':fftw2_info,\n 'fftw3':fftw3_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 'f2py':f2py_info,\n 'Numeric':Numeric_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 'umfpack':umfpack_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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\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 UmfpackNotFoundError(NotFoundError):\n \"\"\"\n UMFPACK sparse solver (http://www.cise.ufl.edu/research/sparse/umfpack/)\n not found. Directories to search for the libraries can be specified in the\n numpy/distutils/site.cfg file (section [umfpack]) or by setting\n the UMFPACK environment variable.\"\"\"\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['libraries'] = ''\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 self.files = get_standard_file('site.cfg')\n self.parse_config_files()\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def parse_config_files(self):\n self.cp.read(self.files)\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n\n def calc_libraries_info(self):\n libs = self.get_libraries()\n dirs = self.get_lib_dirs()\n info = {}\n for lib in libs:\n i = None\n for d in dirs:\n i = self.check_libs(d,[lib])\n if i is not None:\n break\n if i is not None:\n dict_append(info,**i)\n else:\n print 'Library %s was not found. Ignoring' % (lib)\n return info\n\n def set_info(self,**info):\n if info:\n lib_info = self.calc_libraries_info()\n dict_append(info,**lib_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 numpy.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(repr(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 env_var = self.dir_env_var\n if env_var:\n if is_sequence(env_var):\n e0 = env_var[-1]\n for e in env_var:\n if os.environ.has_key(e):\n e0 = e\n break\n if not env_var[0]==e0:\n print 'Setting %s=%s' % (env_var[0],e0)\n env_var = e0\n if env_var and os.environ.has_key(env_var):\n d = os.environ[env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' \\\n % (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 if not default:\n return []\n if is_string(default):\n return [default]\n return default\n return [b for b in [a.strip() for a in libs.split(',')] if b]\n\n def get_libraries(self, key='libraries'):\n return self.get_libs(key,'')\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 return\n\n def check_libs2(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 info = self._check_libs(lib_dir,libs,opt_libs,exts)\n if info is not None: return info\n return\n\n def _lib_list(self, lib_dir, libs, exts):\n assert is_string(lib_dir)\n liblist = []\n for l in libs:\n for ext in exts:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n break\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, exts):\n found_libs = self._lib_list(lib_dir, libs, exts)\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, exts)\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 else:\n warnings.warn(\"Library error: libs=%s found_libs=%s\" % \\\n (libs, found_libs))\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\n\nclass fft_opt_info(system_info):\n\n def calc_info(self):\n info = {}\n fftw_info = get_info('fftw3') or get_info('fftw2') or get_info('dfftw')\n djbfft_info = get_info('djbfft')\n if fftw_info:\n dict_append(info,**fftw_info)\n if djbfft_info:\n dict_append(info,**djbfft_info)\n self.set_info(**info)\n return\n\n\nclass fftw_info(system_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_ver_info(self,ver_param):\n \"\"\"Returns True on successful version detection, else False\"\"\"\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', ver_param['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,ver_param['includes']))==len(ver_param['includes']):\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=ver_param['macros'])\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n return True\n else:\n if self.verbosity>0:\n print ' %s not found' % (ver_param['name'])\n return False\n\n def calc_info(self):\n for i in self.ver_info:\n if self.calc_ver_info(i):\n break\n\nclass fftw2_info(fftw_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}\n ]\n\nclass fftw3_info(fftw_info):\n #variables to override\n section = 'fftw3'\n dir_env_var = 'FFTW3'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n ]\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n ver_info = [ { 'name':'dfftw',\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 ver_info = [ { 'name':'sfftw',\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 ver_info = [ { 'name':'fftw threads',\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 ver_info = [ { 'name':'dfftw threads',\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 ver_info = [ { 'name':'sfftw threads',\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','libdjbfft'+so_ext])\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 return\n\nclass mkl_info(system_info):\n section = 'mkl'\n dir_env_var = 'MKL'\n _lib_mkl = ['mkl','vml','guide']\n\n def get_mkl_rootdir(self):\n mklroot = os.environ.get('MKLROOT',None)\n if mklroot is not None:\n return mklroot\n paths = os.environ.get('LD_LIBRARY_PATH','').split(os.pathsep)\n ld_so_conf = '/etc/ld.so.conf'\n if os.path.isfile(ld_so_conf):\n for d in open(ld_so_conf,'r').readlines():\n d = d.strip()\n if d: paths.append(d)\n intel_mkl_dirs = []\n for path in paths:\n path_atoms = path.split(os.sep)\n for m in path_atoms:\n if m.startswith('mkl'):\n d = os.sep.join(path_atoms[:path_atoms.index(m)+2])\n intel_mkl_dirs.append(d)\n break\n for d in paths:\n dirs = glob(os.path.join(d,'mkl','*')) + glob(os.path.join(d,'mkl*'))\n for d in dirs:\n if os.path.isdir(os.path.join(d,'lib')):\n return d\n return None\n\n def __init__(self):\n mklroot = self.get_mkl_rootdir()\n if mklroot is None:\n system_info.__init__(self)\n else:\n from cpuinfo import cpu\n if cpu.is_Itanium():\n plt = '64'\n l = 'mkl_ipf'\n elif cpu.is_Xeon():\n plt = 'em64t'\n l = 'mkl_em64t'\n else:\n plt = '32'\n l = 'mkl_ia32'\n if l not in self._lib_mkl:\n self._lib_mkl.insert(0,l)\n system_info.__init__(self,\n default_lib_dirs=[os.path.join(mklroot,'lib',plt)],\n default_include_dirs=[os.path.join(mklroot,'include')])\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n mkl_libs = self.get_libs('mkl_libs',self._lib_mkl)\n mkl = None\n for d in lib_dirs:\n mkl = self.check_libs2(d,mkl_libs)\n if mkl is not None:\n break\n if mkl is None:\n return\n info = {}\n dict_append(info,**mkl)\n dict_append(info,libraries = ['pthread'], include_dirs = incl_dirs)\n self.set_info(**info)\n\nclass lapack_mkl_info(mkl_info):\n\n def calc_info(self):\n mkl = get_info('mkl')\n if not mkl:\n return\n lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])\n info = {'libraries': lapack_libs}\n dict_append(info,**mkl)\n self.set_info(**info)\n\nclass blas_mkl_info(mkl_info):\n pass\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\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 numpy/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 dir_env_var = ['PTATLAS','ATLAS']\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n dir_env_var = ['PTATLAS','ATLAS']\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 numpy_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_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\ndef get_atlas_version(**config):\n os.environ['NO_SCIPY_IMPORT']='get_atlas_version'\n from core import Extension, setup\n from misc_util import get_cmd\n import log\n magic = hex(hash(repr(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 build_dir = _get_build_temp()\n extra_args = ['--build-lib',build_dir]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n import distutils.core\n old_dist = distutils.core._setup_distribution\n distutils.core._setup_distribution = None\n return_flag = True\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n return_flag = False\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n distutils.core._setup_distribution = old_dist\n\n if return_flag:\n return\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n target = os.path.join(build_dir,'atlas_version'+so_ext)\n cmd = [get_pythonexe(),'-c',\n '\"import imp,os;os.environ[\\\\\"NO_SCIPY_IMPORT\\\\\"]='\\\n '\\\\\"system_info.get_atlas_version:load atlas_version\\\\\";'\\\n '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.search(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'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec'])\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 lapack_mkl_info = get_info('lapack_mkl')\n if lapack_mkl_info:\n self.set_info(**lapack_mkl_info)\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 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 if atlas_version=='3.2.1_pre3.3.6':\n 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',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\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 blas_mkl_info = get_info('blas_mkl')\n if blas_mkl_info:\n self.set_info(**blas_mkl_info)\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 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 = 'Numeric'\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 = []\n for v in ['__version__','version']:\n vrs = getattr(module,v,None)\n if vrs is None:\n continue\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (vrs)),\n (self.modulename.upper(),None)]\n break\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 Numeric_info(_numpy_info):\n section = 'Numeric'\n modulename = 'Numeric'\n\nclass numpy_info(_numpy_info):\n section = 'numpy'\n modulename = 'numpy'\n\nclass f2py_info(system_info):\n def calc_info(self):\n try:\n import numpy.f2py as f2py\n except ImportError:\n return\n f2py_dir = os.path.join(os.path.dirname(f2py.__file__),'src')\n self.set_info(sources = [os.path.join(f2py_dir,'fortranobject.c')],\n include_dirs = [f2py_dir])\n return\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\nclass umfpack_info(system_info):\n section = 'umfpack'\n dir_env_var = 'UMFPACK'\n notfounderror = UmfpackNotFoundError\n _lib_names = ['umfpack','amd']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n umfpack_libs = self.get_libs('umfpack_libs', self._lib_names)\n for d in lib_dirs:\n umf = self.check_libs(d,umfpack_libs,[])\n if umf is not None:\n info = umf\n break\n else:\n return\n\n include_dirs = self.get_include_dirs()\n\n inc_dir = None\n for d in include_dirs:\n d = os.path.join(d,'umfpack')\n if self.combine_paths(d,'umfpack.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir],\n define_macros=[('SCIPY_UMFPACK_H',None)],\n swig_opts = ['-I' + inc_dir])\n\n self.set_info(**info)\n return\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 is_string(a):\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 show_only = []\n for n in sys.argv[1:]:\n if n[-5:] != '_info':\n n = n + '_info'\n show_only.append(n)\n show_all = not show_only\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n if not show_all:\n if n not in show_only: continue\n del show_only[show_only.index(n)]\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n if show_only:\n print 'Info classes not defined:',','.join(show_only)\nif __name__ == \"__main__\":\n show_all()\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n\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 numpy_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 umfpack_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' is looked for in\n\n1) Directory of main setup.py file being run.\n2) Home directory of user running the setup.py file (Not implemented yet)\n3) System wide directory (location of this file...)\n\nThe first one found is used to get system configuration options The\nformat is that used by ConfigParser (i.e., Windows .INI style). The\nsection DEFAULT has options that are the default for each section. The\navailable sections are fftw, atlas, and x11. Appropiate defaults are\nused if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command, get_pythonexe\nfrom numpy.distutils.misc_util import is_sequence, is_string\nimport distutils.sysconfig\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\',\n os.path.join(distutils.sysconfig.EXEC_PREFIX,\n 'libs')]\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 '/opt/local/lib', '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/opt/local/include', '/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_standard_file(fname):\n \"\"\"Returns a list of files named 'fname' from\n 1) System-wide directory (directory-location of this module)\n 2) Users HOME directory (os.environ['HOME'])\n 3) Local directory\n \"\"\"\n # System-wide file\n filenames = []\n try:\n f = __file__\n except NameError:\n f = sys.argv[0]\n else:\n sysfile = os.path.join(os.path.split(os.path.abspath(f))[0],\n fname)\n if os.path.isfile(sysfile):\n filenames.append(sysfile)\n\n # Home directory\n # And look for the user config file\n try:\n f = os.environ['HOME']\n except KeyError:\n pass\n else:\n user_file = os.path.join(f, fname)\n if os.path.isfile(user_file):\n filenames.append(user_file)\n\n # Local file\n if os.path.isfile(fname):\n filenames.append(os.path.abspath(fname))\n\n return filenames\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 'mkl':mkl_info,\n 'lapack_mkl':lapack_mkl_info, # use lapack_opt instead\n 'blas_mkl':blas_mkl_info, # use blas_opt instead\n 'x11':x11_info,\n 'fft_opt':fft_opt_info,\n 'fftw':fftw_info,\n 'fftw2':fftw2_info,\n 'fftw3':fftw3_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 'f2py':f2py_info,\n 'Numeric':Numeric_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 'umfpack':umfpack_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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\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 UmfpackNotFoundError(NotFoundError):\n \"\"\"\n UMFPACK sparse solver (http://www.cise.ufl.edu/research/sparse/umfpack/)\n not found. Directories to search for the libraries can be specified in the\n numpy/distutils/site.cfg file (section [umfpack]) or by setting\n the UMFPACK environment variable.\"\"\"\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['libraries'] = ''\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 self.files = get_standard_file('site.cfg')\n self.parse_config_files()\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def parse_config_files(self):\n self.cp.read(self.files)\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n\n def calc_libraries_info(self):\n libs = self.get_libraries()\n dirs = self.get_lib_dirs()\n info = {}\n for lib in libs:\n i = None\n for d in dirs:\n i = self.check_libs(d,[lib])\n if i is not None:\n break\n if i is not None:\n dict_append(info,**i)\n else:\n print 'Library %s was not found. Ignoring' % (lib)\n return info\n\n def set_info(self,**info):\n if info:\n lib_info = self.calc_libraries_info()\n dict_append(info,**lib_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 numpy.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(repr(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 env_var = self.dir_env_var\n if env_var:\n if is_sequence(env_var):\n e0 = env_var[-1]\n for e in env_var:\n if os.environ.has_key(e):\n e0 = e\n break\n if not env_var[0]==e0:\n print 'Setting %s=%s' % (env_var[0],e0)\n env_var = e0\n if env_var and os.environ.has_key(env_var):\n d = os.environ[env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' \\\n % (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 if not default:\n return []\n if is_string(default):\n return [default]\n return default\n return [b for b in [a.strip() for a in libs.split(',')] if b]\n\n def get_libraries(self, key='libraries'):\n return self.get_libs(key,'')\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 return\n\n def check_libs2(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 info = self._check_libs(lib_dir,libs,opt_libs,exts)\n if info is not None: return info\n return\n\n def _lib_list(self, lib_dir, libs, exts):\n assert is_string(lib_dir)\n liblist = []\n for l in libs:\n for ext in exts:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n break\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, exts):\n found_libs = self._lib_list(lib_dir, libs, exts)\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, exts)\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 else:\n warnings.warn(\"Library error: libs=%s found_libs=%s\" % \\\n (libs, found_libs))\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\n\nclass fft_opt_info(system_info):\n\n def calc_info(self):\n info = {}\n fftw_info = get_info('fftw3') or get_info('fftw2') or get_info('dfftw')\n djbfft_info = get_info('djbfft')\n if fftw_info:\n dict_append(info,**fftw_info)\n if djbfft_info:\n dict_append(info,**djbfft_info)\n self.set_info(**info)\n return\n\n\nclass fftw_info(system_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_ver_info(self,ver_param):\n \"\"\"Returns True on successful version detection, else False\"\"\"\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', ver_param['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,ver_param['includes']))==len(ver_param['includes']):\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=ver_param['macros'])\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n return True\n else:\n if self.verbosity>0:\n print ' %s not found' % (ver_param['name'])\n return False\n\n def calc_info(self):\n for i in self.ver_info:\n if self.calc_ver_info(i):\n break\n\nclass fftw2_info(fftw_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}\n ]\n\nclass fftw3_info(fftw_info):\n #variables to override\n section = 'fftw3'\n dir_env_var = 'FFTW3'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n ]\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n ver_info = [ { 'name':'dfftw',\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 ver_info = [ { 'name':'sfftw',\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 ver_info = [ { 'name':'fftw threads',\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 ver_info = [ { 'name':'dfftw threads',\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 ver_info = [ { 'name':'sfftw threads',\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','libdjbfft'+so_ext])\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 return\n\nclass mkl_info(system_info):\n section = 'mkl'\n dir_env_var = 'MKL'\n _lib_mkl = ['mkl','vml','guide']\n\n def get_mkl_rootdir(self):\n mklroot = os.environ.get('MKLROOT',None)\n if mklroot is not None:\n return mklroot\n paths = os.environ.get('LD_LIBRARY_PATH','').split(os.pathsep)\n ld_so_conf = '/etc/ld.so.conf'\n if os.path.isfile(ld_so_conf):\n for d in open(ld_so_conf,'r').readlines():\n d = d.strip()\n if d: paths.append(d)\n intel_mkl_dirs = []\n for path in paths:\n path_atoms = path.split(os.sep)\n for m in path_atoms:\n if m.startswith('mkl'):\n d = os.sep.join(path_atoms[:path_atoms.index(m)+2])\n intel_mkl_dirs.append(d)\n break\n for d in paths:\n dirs = glob(os.path.join(d,'mkl','*')) + glob(os.path.join(d,'mkl*'))\n for d in dirs:\n if os.path.isdir(os.path.join(d,'lib')):\n return d\n return None\n\n def __init__(self):\n mklroot = self.get_mkl_rootdir()\n if mklroot is None:\n system_info.__init__(self)\n else:\n from cpuinfo import cpu\n if cpu.is_Itanium():\n plt = '64'\n l = 'mkl_ipf'\n elif cpu.is_Xeon():\n plt = 'em64t'\n l = 'mkl_em64t'\n else:\n plt = '32'\n l = 'mkl_ia32'\n if l not in self._lib_mkl:\n self._lib_mkl.insert(0,l)\n system_info.__init__(self,\n default_lib_dirs=[os.path.join(mklroot,'lib',plt)],\n default_include_dirs=[os.path.join(mklroot,'include')])\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n mkl_libs = self.get_libs('mkl_libs',self._lib_mkl)\n mkl = None\n for d in lib_dirs:\n mkl = self.check_libs2(d,mkl_libs)\n if mkl is not None:\n break\n if mkl is None:\n return\n info = {}\n dict_append(info,**mkl)\n dict_append(info,libraries = ['pthread'], include_dirs = incl_dirs)\n self.set_info(**info)\n\nclass lapack_mkl_info(mkl_info):\n\n def calc_info(self):\n mkl = get_info('mkl')\n if not mkl:\n return\n lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])\n info = {'libraries': lapack_libs}\n dict_append(info,**mkl)\n self.set_info(**info)\n\nclass blas_mkl_info(mkl_info):\n pass\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\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 numpy/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 dir_env_var = ['PTATLAS','ATLAS']\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n dir_env_var = ['PTATLAS','ATLAS']\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 numpy_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_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\ndef get_atlas_version(**config):\n os.environ['NO_SCIPY_IMPORT']='get_atlas_version'\n from core import Extension, setup\n from misc_util import get_cmd\n import log\n magic = hex(hash(repr(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 build_dir = _get_build_temp()\n extra_args = ['--build-lib',build_dir]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n import distutils.core\n old_dist = distutils.core._setup_distribution\n distutils.core._setup_distribution = None\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 distutils.core._setup_distribution = old_dist\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n target = os.path.join(build_dir,'atlas_version'+so_ext)\n cmd = [get_pythonexe(),'-c',\n '\"import imp,os;os.environ[\\\\\"NO_SCIPY_IMPORT\\\\\"]='\\\n '\\\\\"system_info.get_atlas_version:load atlas_version\\\\\";'\\\n '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.search(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'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec'])\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 lapack_mkl_info = get_info('lapack_mkl')\n if lapack_mkl_info:\n self.set_info(**lapack_mkl_info)\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 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 if atlas_version=='3.2.1_pre3.3.6':\n 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',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\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 blas_mkl_info = get_info('blas_mkl')\n if blas_mkl_info:\n self.set_info(**blas_mkl_info)\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 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 = 'Numeric'\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 = []\n for v in ['__version__','version']:\n vrs = getattr(module,v,None)\n if vrs is None:\n continue\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (vrs)),\n (self.modulename.upper(),None)]\n break\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 Numeric_info(_numpy_info):\n section = 'Numeric'\n modulename = 'Numeric'\n\nclass numpy_info(_numpy_info):\n section = 'numpy'\n modulename = 'numpy'\n\nclass f2py_info(system_info):\n def calc_info(self):\n try:\n import numpy.f2py as f2py\n except ImportError:\n return\n f2py_dir = os.path.join(os.path.dirname(f2py.__file__),'src')\n self.set_info(sources = [os.path.join(f2py_dir,'fortranobject.c')],\n include_dirs = [f2py_dir])\n return\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\nclass umfpack_info(system_info):\n section = 'umfpack'\n dir_env_var = 'UMFPACK'\n notfounderror = UmfpackNotFoundError\n _lib_names = ['umfpack','amd']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n umfpack_libs = self.get_libs('umfpack_libs', self._lib_names)\n for d in lib_dirs:\n umf = self.check_libs(d,umfpack_libs,[])\n if umf is not None:\n info = umf\n break\n else:\n return\n\n include_dirs = self.get_include_dirs()\n\n inc_dir = None\n for d in include_dirs:\n d = os.path.join(d,'umfpack')\n if self.combine_paths(d,'umfpack.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir],\n define_macros=[('SCIPY_UMFPACK_H',None)],\n swig_opts = ['-I' + inc_dir])\n\n self.set_info(**info)\n return\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 is_string(a):\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 show_only = []\n for n in sys.argv[1:]:\n if n[-5:] != '_info':\n n = n + '_info'\n show_only.append(n)\n show_all = not show_only\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n if not show_all:\n if n not in show_only: continue\n del show_only[show_only.index(n)]\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n if show_only:\n print 'Info classes not defined:',','.join(show_only)\nif __name__ == \"__main__\":\n show_all()\n", + "methods": [ + { + "name": "get_standard_file", + "long_name": "get_standard_file( fname )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 6, + "token_count": 142, + "parameters": [ + "fname" + ], + "start_line": 154, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "get_info", + "long_name": "get_info( name , notfound_action = 0 )", + "filename": "system_info.py", + "nloc": 52, + "complexity": 1, + "token_count": 230, + "parameters": [ + "name", + "notfound_action" + ], + "start_line": 189, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 19, + "complexity": 1, + "token_count": 140, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs", + "verbosity" + ], + "start_line": 328, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "parse_config_files", + "long_name": "parse_config_files( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "calc_libraries_info", + "long_name": "calc_libraries_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 5, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 353, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "info" + ], + "start_line": 369, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 375, + "end_line": 376, + "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": 208, + "parameters": [ + "self", + "notfound_action" + ], + "start_line": 378, + "end_line": 413, + "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": 47, + "complexity": 20, + "token_count": 399, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 415, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "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": 469, + "end_line": 470, + "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": 10, + "complexity": 7, + "token_count": 74, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 472, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_libraries", + "long_name": "get_libraries( self , key = 'libraries' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "key" + ], + "start_line": 483, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 5, + "token_count": 79, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 486, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_libs2", + "long_name": "check_libs2( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 10, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 500, + "end_line": 511, + "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 , exts )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self", + "lib_dir", + "libs", + "exts" + ], + "start_line": 513, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "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": 525, + "end_line": 527, + "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 , exts )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 3, + "token_count": 114, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs", + "exts" + ], + "start_line": 529, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 543, + "end_line": 544, + "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": 10, + "complexity": 5, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 549, + "end_line": 558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_ver_info", + "long_name": "calc_ver_info( self , ver_param )", + "filename": "system_info.py", + "nloc": 31, + "complexity": 9, + "token_count": 184, + "parameters": [ + "self", + "ver_param" + ], + "start_line": 578, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 3, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 611, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 683, + "end_line": 688, + "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": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 690, + "end_line": 711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "get_mkl_rootdir", + "long_name": "get_mkl_rootdir( self )", + "filename": "system_info.py", + "nloc": 24, + "complexity": 11, + "token_count": 211, + "parameters": [ + "self" + ], + "start_line": 718, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 762, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 4, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 764, + "end_line": 778, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 782, + "end_line": 789, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 807, + "end_line": 813, + "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": 815, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "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": 900, + "end_line": 922, + "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": 945, + "end_line": 957, + "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": 964, + "end_line": 969, + "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": 971, + "end_line": 1055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 1 + }, + { + "name": "_get_build_temp", + "long_name": "_get_build_temp( )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 1074, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "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": 1085, + "end_line": 1094, + "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": 54, + "complexity": 10, + "token_count": 322, + "parameters": [ + "config" + ], + "start_line": 1079, + "end_line": 1143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 72, + "complexity": 20, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 1148, + "end_line": 1228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 57, + "complexity": 14, + "token_count": 331, + "parameters": [ + "self" + ], + "start_line": 1233, + "end_line": 1294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "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": 1303, + "end_line": 1315, + "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": 1323, + "end_line": 1328, + "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": 1330, + "end_line": 1365, + "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": 1371, + "end_line": 1374, + "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": 1376, + "end_line": 1395, + "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": 1402, + "end_line": 1423, + "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": 29, + "complexity": 8, + "token_count": 161, + "parameters": [ + "self" + ], + "start_line": 1425, + "end_line": 1460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 1475, + "end_line": 1483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1489, + "end_line": 1494, + "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": 1496, + "end_line": 1516, + "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": 1522, + "end_line": 1527, + "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": 1529, + "end_line": 1551, + "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": 1563, + "end_line": 1566, + "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": 1567, + "end_line": 1570, + "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": 1572, + "end_line": 1625, + "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": 23, + "complexity": 6, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 1689, + "end_line": 1715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args , ** kws )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 11, + "token_count": 191, + "parameters": [ + "args", + "kws" + ], + "start_line": 1728, + "end_line": 1752, + "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": 1756, + "end_line": 1772, + "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": 20, + "complexity": 8, + "token_count": 137, + "parameters": [], + "start_line": 1774, + "end_line": 1793, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_standard_file", + "long_name": "get_standard_file( fname )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 6, + "token_count": 142, + "parameters": [ + "fname" + ], + "start_line": 154, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "get_info", + "long_name": "get_info( name , notfound_action = 0 )", + "filename": "system_info.py", + "nloc": 52, + "complexity": 1, + "token_count": 230, + "parameters": [ + "name", + "notfound_action" + ], + "start_line": 189, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 19, + "complexity": 1, + "token_count": 140, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs", + "verbosity" + ], + "start_line": 328, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "parse_config_files", + "long_name": "parse_config_files( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "calc_libraries_info", + "long_name": "calc_libraries_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 5, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 353, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "info" + ], + "start_line": 369, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 375, + "end_line": 376, + "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": 208, + "parameters": [ + "self", + "notfound_action" + ], + "start_line": 378, + "end_line": 413, + "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": 47, + "complexity": 20, + "token_count": 399, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 415, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "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": 469, + "end_line": 470, + "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": 10, + "complexity": 7, + "token_count": 74, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 472, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_libraries", + "long_name": "get_libraries( self , key = 'libraries' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "key" + ], + "start_line": 483, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 5, + "token_count": 79, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 486, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_libs2", + "long_name": "check_libs2( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 10, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 500, + "end_line": 511, + "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 , exts )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self", + "lib_dir", + "libs", + "exts" + ], + "start_line": 513, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "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": 525, + "end_line": 527, + "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 , exts )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 3, + "token_count": 114, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs", + "exts" + ], + "start_line": 529, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 543, + "end_line": 544, + "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": 10, + "complexity": 5, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 549, + "end_line": 558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_ver_info", + "long_name": "calc_ver_info( self , ver_param )", + "filename": "system_info.py", + "nloc": 31, + "complexity": 9, + "token_count": 184, + "parameters": [ + "self", + "ver_param" + ], + "start_line": 578, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 3, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 611, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 683, + "end_line": 688, + "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": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 690, + "end_line": 711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "get_mkl_rootdir", + "long_name": "get_mkl_rootdir( self )", + "filename": "system_info.py", + "nloc": 24, + "complexity": 11, + "token_count": 211, + "parameters": [ + "self" + ], + "start_line": 718, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 762, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 4, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 764, + "end_line": 778, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 782, + "end_line": 789, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 807, + "end_line": 813, + "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": 815, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "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": 900, + "end_line": 922, + "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": 945, + "end_line": 957, + "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": 964, + "end_line": 969, + "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": 971, + "end_line": 1055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 1 + }, + { + "name": "_get_build_temp", + "long_name": "_get_build_temp( )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 1074, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "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": 1085, + "end_line": 1094, + "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": 51, + "complexity": 9, + "token_count": 314, + "parameters": [ + "config" + ], + "start_line": 1079, + "end_line": 1139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 72, + "complexity": 20, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 1144, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 57, + "complexity": 14, + "token_count": 331, + "parameters": [ + "self" + ], + "start_line": 1229, + "end_line": 1290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "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": 1299, + "end_line": 1311, + "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": 1319, + "end_line": 1324, + "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": 1326, + "end_line": 1361, + "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": 1367, + "end_line": 1370, + "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": 1372, + "end_line": 1391, + "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": 1398, + "end_line": 1419, + "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": 29, + "complexity": 8, + "token_count": 161, + "parameters": [ + "self" + ], + "start_line": 1421, + "end_line": 1456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 1471, + "end_line": 1479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1485, + "end_line": 1490, + "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": 1492, + "end_line": 1512, + "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": 1518, + "end_line": 1523, + "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": 1525, + "end_line": 1547, + "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": 1559, + "end_line": 1562, + "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": 1563, + "end_line": 1566, + "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": 1568, + "end_line": 1621, + "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": 23, + "complexity": 6, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 1685, + "end_line": 1711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args , ** kws )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 11, + "token_count": 191, + "parameters": [ + "args", + "kws" + ], + "start_line": 1724, + "end_line": 1748, + "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": 1752, + "end_line": 1768, + "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": 20, + "complexity": 8, + "token_count": 137, + "parameters": [], + "start_line": 1770, + "end_line": 1789, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "get_atlas_version", + "long_name": "get_atlas_version( ** config )", + "filename": "system_info.py", + "nloc": 54, + "complexity": 10, + "token_count": 322, + "parameters": [ + "config" + ], + "start_line": 1079, + "end_line": 1143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + } + ], + "nloc": 1574, + "complexity": 341, + "token_count": 8791, + "diff_parsed": { + "added": [ + " return_flag = True", + " return_flag = False", + " if return_flag:", + " return", + "" + ], + "deleted": [ + " return None" + ] + } + } + ] + }, + { + "hash": "da78766309515905b4016ac494dac384fe80a5fd", + "msg": "Fix-up record-array pickling and attribute access errors. Fix minor pickling inconsistency with un-ordered ('|') data-types.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-03-31T08:32:04+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T08:32:04+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "698a593861f8a9c4f2346e456eee978393bf5595" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 10, + "insertions": 30, + "lines": 40, + "files": 4, + "dmm_unit_size": 0.1111111111111111, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.5, + "modified_files": [ + { + "old_path": "numpy/core/records.py", + "new_path": "numpy/core/records.py", + "filename": "records.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -106,21 +106,34 @@ def __str__(self):\n def __getattribute__(self, attr):\n if attr in ['setfield', 'getfield', 'dtype']:\n return nt.void.__getattribute__(self, attr)\n+ try:\n+ return nt.void.__getattribute__(self, attr)\n+ except AttributeError:\n+ pass\n fielddict = nt.void.__getattribute__(self, 'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.getfield(*res[:2])\n- return nt.void.__getattribute__(self, attr)\n+ else:\n+ raise AttributeError, \"'record' object has no \"\\\n+ \"attribute '%s'\" % attr\n+ \n \n def __setattr__(self, attr, val):\n if attr in ['setfield', 'getfield', 'dtype']:\n raise AttributeError, \"Cannot set '%s' attribute\" % attr;\n+ try:\n+ return nt.void.__setattr__(self,attr,val)\n+ except AttributeError:\n+ pass\n fielddict = nt.void.__getattribute__(self,'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.setfield(val,*res[:2])\n+ else:\n+ raise AttributeError, \"'record' object has no \"\\\n+ \"attribute '%s'\" % attr\n \n- return nt.void.__setattr__(self,attr,val)\n \n # The recarray is almost identical to a standard array (which supports\n # named fields already) The biggest difference is that it can use\n@@ -159,7 +172,10 @@ def __getattribute__(self, attr):\n except AttributeError: # attr must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n- res = fielddict[attr][:2]\n+ try:\n+ res = fielddict[attr][:2]\n+ except KeyError:\n+ raise AttributeError, \"record array has no attribute %s\" % attr\n obj = self.getfield(*res)\n # if it has fields return a recarray, otherwise return\n # normal array\n@@ -175,7 +191,10 @@ def __setattr__(self, attr, val):\n except AttributeError: # Must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n- res = fielddict[attr][:2]\n+ try:\n+ res = fielddict[attr][:2]\n+ except KeyError:\n+ raise AttributeError, \"record array has no attribute %s\" % attr \n return self.setfield(val,*res)\n \n def field(self,attr, val=None):\n", + "added_lines": 23, + "deleted_lines": 4, + "source_code": "__all__ = ['record', 'recarray', 'format_parser']\n\nimport numeric as sb\nfrom defchararray import chararray\nimport numerictypes as nt\nimport types\nimport stat, os\n\n_byteorderconv = {'b':'>',\n 'l':'<',\n 'n':'=',\n 'B':'>',\n 'L':'<',\n 'N':'=',\n 'S':'s',\n 's':'s',\n '>':'>',\n '<':'<',\n '=':'=',\n '|':'|',\n 'I':'|',\n 'i':'|'}\n\n# formats regular expression\n# allows multidimension spec with a tuple syntax in front\n# of the letter code '(2,3)f4' and ' ( 2 , 3 ) f4 '\n# are equally allowed\n\nnumfmt = nt.typeDict\n_typestr = nt._typestr\n\ndef find_duplicate(list):\n \"\"\"Find duplication in a list, return a list of duplicated elements\"\"\"\n dup = []\n for i in range(len(list)):\n if (list[i] in list[i+1:]):\n if (list[i] not in dup):\n dup.append(list[i])\n return dup\n\n\nclass format_parser:\n def __init__(self, formats, names, titles, aligned=False):\n self._parseFormats(formats, aligned)\n self._setfieldnames(names, titles)\n self._createdescr()\n\n def _parseFormats(self, formats, aligned=0):\n \"\"\" Parse the field formats \"\"\"\n\n dtype = sb.dtype(formats, aligned)\n fields = dtype.fields\n keys = fields[-1]\n self._f_formats = [fields[key][0] for key in keys]\n self._offsets = [fields[key][1] for key in keys]\n self._nfields = len(keys)\n\n def _setfieldnames(self, names, titles):\n \"\"\"convert input field names into a list and assign to the _names\n attribute \"\"\"\n\n if (names):\n if (type(names) in [types.ListType, types.TupleType]):\n pass\n elif (type(names) == types.StringType):\n names = names.split(',')\n else:\n raise NameError, \"illegal input names %s\" % `names`\n\n self._names = [n.strip() for n in names[:self._nfields]]\n else:\n self._names = []\n\n # if the names are not specified, they will be assigned as \"f1, f2,...\"\n # if not enough names are specified, they will be assigned as \"f[n+1],\n # f[n+2],...\" etc. where n is the number of specified names...\"\n self._names += ['f%d' % i for i in range(len(self._names)+1,\n self._nfields+1)]\n # check for redundant names\n _dup = find_duplicate(self._names)\n if _dup:\n raise ValueError, \"Duplicate field names: %s\" % _dup\n\n if (titles):\n self._titles = [n.strip() for n in titles[:self._nfields]]\n else:\n self._titles = []\n titles = []\n\n if (self._nfields > len(titles)):\n self._titles += [None]*(self._nfields-len(titles))\n\n def _createdescr(self):\n self._descr = sb.dtype({'names':self._names,\n 'formats':self._f_formats,\n 'offsets':self._offsets,\n 'titles':self._titles})\n\nclass record(nt.void):\n def __repr__(self):\n return self.__str__()\n\n def __str__(self):\n return str(self.item())\n\n def __getattribute__(self, attr):\n if attr in ['setfield', 'getfield', 'dtype']:\n return nt.void.__getattribute__(self, attr)\n try:\n return nt.void.__getattribute__(self, attr)\n except AttributeError:\n pass\n fielddict = nt.void.__getattribute__(self, 'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.getfield(*res[:2])\n else:\n raise AttributeError, \"'record' object has no \"\\\n \"attribute '%s'\" % attr\n \n\n def __setattr__(self, attr, val):\n if attr in ['setfield', 'getfield', 'dtype']:\n raise AttributeError, \"Cannot set '%s' attribute\" % attr;\n try:\n return nt.void.__setattr__(self,attr,val)\n except AttributeError:\n pass\n fielddict = nt.void.__getattribute__(self,'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.setfield(val,*res[:2])\n else:\n raise AttributeError, \"'record' object has no \"\\\n \"attribute '%s'\" % attr\n\n\n# The recarray is almost identical to a standard array (which supports\n# named fields already) The biggest difference is that it can use\n# attribute-lookup to find the fields and it is constructed using\n# a record.\n\n# If byteorder is given it forces a particular byteorder on all\n# the fields (and any subfields)\n\nclass recarray(sb.ndarray):\n def __new__(subtype, shape, formats, names=None, titles=None,\n buf=None, offset=0, strides=None, byteorder=None,\n aligned=0):\n\n if isinstance(formats, sb.dtype):\n descr = formats\n else:\n parsed = format_parser(formats, names, titles, aligned)\n descr = parsed._descr\n\n if (byteorder is not None):\n byteorder = _byteorderconv[byteorder[0]]\n descr = descr.newbyteorder(byteorder)\n\n if buf is None:\n self = sb.ndarray.__new__(subtype, shape, (record, descr))\n else:\n self = sb.ndarray.__new__(subtype, shape, (record, descr),\n buffer=buf, offset=offset,\n strides=strides)\n return self\n\n def __getattribute__(self, attr):\n try:\n return object.__getattribute__(self,attr)\n except AttributeError: # attr must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n try:\n res = fielddict[attr][:2]\n except KeyError:\n raise AttributeError, \"record array has no attribute %s\" % attr\n obj = self.getfield(*res)\n # if it has fields return a recarray, otherwise return\n # normal array\n if obj.dtype.fields:\n return obj\n if obj.dtype.char in 'SU':\n return obj.view(chararray)\n return obj.view(sb.ndarray)\n\n def __setattr__(self, attr, val):\n try:\n return object.__setattr__(self, attr, val)\n except AttributeError: # Must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n try:\n res = fielddict[attr][:2]\n except KeyError:\n raise AttributeError, \"record array has no attribute %s\" % attr \n return self.setfield(val,*res)\n\n def field(self,attr, val=None):\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n\n if isinstance(attr,int):\n attr=fielddict[-1][attr]\n\n if val is None:\n return self.__getattribute__(attr)\n else:\n return self.__setattr__(attr,val)\n\ndef fromarrays(arrayList, formats=None, names=None, titles=None, shape=None,\n aligned=0):\n \"\"\" create a record array from a (flat) list of arrays\n\n >>> x1=array([1,2,3,4])\n >>> x2=array(['a','dd','xyz','12'])\n >>> x3=array([1.1,2,3,4])\n >>> r=fromarrays([x1,x2,x3],names='a,b,c')\n >>> print r[1]\n (2, 'dd', 2.0)\n >>> x1[1]=34\n >>> r.a\n array([1, 2, 3, 4])\n \"\"\"\n\n if shape is None or shape == 0:\n shape = arrayList[0].shape\n\n if isinstance(shape, int):\n shape = (shape,)\n\n if formats is None:\n # go through each object in the list to see if it is an ndarray\n # and determine the formats.\n formats = ''\n for obj in arrayList:\n if not isinstance(obj, sb.ndarray):\n raise ValueError, \"item in the array list must be an ndarray.\"\n formats += _typestr[obj.dtype.type]\n if issubclass(obj.dtype.type, nt.flexible):\n formats += `obj.itemsize`\n formats += ','\n formats=formats[:-1]\n\n for obj in arrayList:\n if obj.shape != shape:\n raise ValueError, \"array has different shape\"\n\n parsed = format_parser(formats, names, titles, aligned)\n _names = parsed._names\n _array = recarray(shape, parsed._descr)\n\n # populate the record array (makes a copy)\n for i in range(len(arrayList)):\n _array[_names[i]] = arrayList[i]\n\n return _array\n\n# shape must be 1-d if you use list of lists...\ndef fromrecords(recList, formats=None, names=None, titles=None, shape=None,\n aligned=0):\n \"\"\" create a recarray from a list of records in text form\n\n The data in the same field can be heterogeneous, they will be promoted\n to the highest data type. This method is intended for creating\n smaller record arrays. If used to create large array without formats\n defined\n\n r=fromrecords([(2,3.,'abc')]*100000)\n\n it can be slow.\n\n If formats is None, then this will auto-detect formats. Use list of\n tuples rather than list of lists for faster processing.\n\n >>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3')\n >>> print r[0]\n (456, 'dbe', 1.2)\n >>> r.col1\n array([456, 2])\n >>> r.col2\n chararray(['dbe', 'de'])\n >>> import cPickle\n >>> print cPickle.loads(cPickle.dumps(r))\n recarray[\n (456, 'dbe', 1.2),\n (2, 'de', 1.3)\n ]\n \"\"\"\n\n nfields = len(recList[0])\n if formats is None: # slower\n obj = sb.array(recList,dtype=object)\n arrlist = [sb.array(obj[...,i].tolist()) for i in xrange(nfields)]\n return fromarrays(arrlist, formats=formats, shape=shape, names=names,\n titles=titles, aligned=aligned)\n\n parsed = format_parser(formats, names, titles, aligned)\n try:\n retval = sb.array(recList, dtype = parsed._descr)\n except TypeError: # list of lists instead of list of tuples\n if (shape is None or shape == 0):\n shape = len(recList)\n if isinstance(shape, (int, long)):\n shape = (shape,)\n if len(shape) > 1:\n raise ValueError, \"Can only deal with 1-d array.\"\n _array = recarray(shape, parsed._descr)\n for k in xrange(_array.size):\n _array[k] = tuple(recList[k])\n return _array\n else:\n if shape is not None and retval.shape != shape:\n retval.shape = shape\n\n res = retval.view(recarray)\n res.dtype = sb.dtype((record, res.dtype))\n return res\n\n\ndef fromstring(datastring, formats, shape=None, names=None, titles=None,\n byteorder=None, aligned=0, offset=0):\n \"\"\" create a (read-only) record array from binary data contained in\n a string\"\"\"\n\n parsed = format_parser(formats, names, titles, aligned)\n itemsize = parsed._descr.itemsize\n if (shape is None or shape == 0 or shape == -1):\n shape = (len(datastring)-offset) / itemsize\n\n _array = recarray(shape, parsed._descr, names=names,\n titles=titles, buf=datastring, offset=offset,\n byteorder=byteorder)\n return _array\n\ndef fromfile(fd, formats, shape=None, names=None, titles=None,\n byteorder=None, aligned=0, offset=0):\n \"\"\"Create an array from binary file data\n\n If file is a string then that file is opened, else it is assumed\n to be a file object.\n\n >>> import testdata, sys\n >>> fd=open(testdata.filename)\n >>> fd.seek(2880*2)\n >>> r=fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big')\n >>> print r[0]\n (5.1000000000000005, 61, 'abcde')\n >>> r._shape\n (3,)\n \"\"\"\n\n if (shape is None or shape == 0):\n shape = (-1,)\n elif isinstance(shape, (int, long)):\n shape = (shape,)\n\n name = 0\n if isinstance(fd, str):\n name = 1\n fd = open(fd, 'rb')\n if (offset > 0):\n fd.seek(offset, 1)\n try:\n size = os.fstat(fd.fileno())[stat.ST_SIZE] - fd.tell()\n except:\n size = os.path.getsize(fd.name) - fd.tell()\n\n parsed = format_parser(formats, names, titles, aligned)\n itemsize = parsed._descr.itemsize\n\n shapeprod = sb.array(shape).prod()\n shapesize = shapeprod*itemsize\n if shapesize < 0:\n shape = list(shape)\n shape[ shape.index(-1) ] = size / -shapesize\n shape = tuple(shape)\n shapeprod = sb.array(shape).prod()\n\n nbytes = shapeprod*itemsize\n\n if nbytes > size:\n raise ValueError(\n \"Not enough bytes left in file for specified shape and type\")\n\n # create the array\n _array = recarray(shape, parsed._descr, byteorder=byteorder)\n nbytesread = fd.readinto(_array.data)\n if nbytesread != nbytes:\n raise IOError(\"Didn't read as many bytes as expected\")\n if name:\n fd.close()\n\n return _array\n\n\ndef array(obj, formats=None, names=None, titles=None, shape=None,\n byteorder=None, aligned=0, offset=0, strides=None):\n\n if isinstance(obj, (type(None), str, file)) and (formats is None):\n raise ValueError(\"Must define formats if object is \"\\\n \"None, string, or an open file\")\n\n elif obj is None:\n if shape is None:\n raise ValueError(\"Must define a shape if obj is None\")\n return recarray(shape, formats, names=names, titles=titles,\n buf=obj, offset=offset, strides=strides,\n byteorder=byteorder, aligned=aligned)\n elif isinstance(obj, str):\n return fromstring(obj, formats, names=names, titles=titles,\n shape=shape, byteorder=byteorder, aligned=aligned,\n offset=offset)\n elif isinstance(obj, (list, tuple)):\n if isinstance(obj[0], sb.ndarray):\n return fromarrays(obj, formats=formats, names=names, titles=titles,\n shape=shape, aligned=aligned)\n else:\n return fromrecords(obj, formats=formats, names=names, titles=titles,\n shape=shape, aligned=aligned)\n elif isinstance(obj, recarray):\n new = obj.copy()\n parsed = format_parser(formats, names, titles, aligned)\n new.dtype = parsed._descr\n return new\n elif isinstance(obj, file):\n return fromfile(obj, formats=formats, names=names, titles=titles,\n shape=shape, byteorder=byteorder, aligned=aligned,\n offset=offset)\n elif isinstance(obj, sb.ndarray):\n res = obj.view(recarray)\n if issubclass(res.dtype.type, nt.void):\n res.dtype = sb.dtype((record, res.dtype))\n return res\n else:\n raise ValueError(\"Unknown input type\")\n", + "source_code_before": "__all__ = ['record', 'recarray', 'format_parser']\n\nimport numeric as sb\nfrom defchararray import chararray\nimport numerictypes as nt\nimport types\nimport stat, os\n\n_byteorderconv = {'b':'>',\n 'l':'<',\n 'n':'=',\n 'B':'>',\n 'L':'<',\n 'N':'=',\n 'S':'s',\n 's':'s',\n '>':'>',\n '<':'<',\n '=':'=',\n '|':'|',\n 'I':'|',\n 'i':'|'}\n\n# formats regular expression\n# allows multidimension spec with a tuple syntax in front\n# of the letter code '(2,3)f4' and ' ( 2 , 3 ) f4 '\n# are equally allowed\n\nnumfmt = nt.typeDict\n_typestr = nt._typestr\n\ndef find_duplicate(list):\n \"\"\"Find duplication in a list, return a list of duplicated elements\"\"\"\n dup = []\n for i in range(len(list)):\n if (list[i] in list[i+1:]):\n if (list[i] not in dup):\n dup.append(list[i])\n return dup\n\n\nclass format_parser:\n def __init__(self, formats, names, titles, aligned=False):\n self._parseFormats(formats, aligned)\n self._setfieldnames(names, titles)\n self._createdescr()\n\n def _parseFormats(self, formats, aligned=0):\n \"\"\" Parse the field formats \"\"\"\n\n dtype = sb.dtype(formats, aligned)\n fields = dtype.fields\n keys = fields[-1]\n self._f_formats = [fields[key][0] for key in keys]\n self._offsets = [fields[key][1] for key in keys]\n self._nfields = len(keys)\n\n def _setfieldnames(self, names, titles):\n \"\"\"convert input field names into a list and assign to the _names\n attribute \"\"\"\n\n if (names):\n if (type(names) in [types.ListType, types.TupleType]):\n pass\n elif (type(names) == types.StringType):\n names = names.split(',')\n else:\n raise NameError, \"illegal input names %s\" % `names`\n\n self._names = [n.strip() for n in names[:self._nfields]]\n else:\n self._names = []\n\n # if the names are not specified, they will be assigned as \"f1, f2,...\"\n # if not enough names are specified, they will be assigned as \"f[n+1],\n # f[n+2],...\" etc. where n is the number of specified names...\"\n self._names += ['f%d' % i for i in range(len(self._names)+1,\n self._nfields+1)]\n # check for redundant names\n _dup = find_duplicate(self._names)\n if _dup:\n raise ValueError, \"Duplicate field names: %s\" % _dup\n\n if (titles):\n self._titles = [n.strip() for n in titles[:self._nfields]]\n else:\n self._titles = []\n titles = []\n\n if (self._nfields > len(titles)):\n self._titles += [None]*(self._nfields-len(titles))\n\n def _createdescr(self):\n self._descr = sb.dtype({'names':self._names,\n 'formats':self._f_formats,\n 'offsets':self._offsets,\n 'titles':self._titles})\n\nclass record(nt.void):\n def __repr__(self):\n return self.__str__()\n\n def __str__(self):\n return str(self.item())\n\n def __getattribute__(self, attr):\n if attr in ['setfield', 'getfield', 'dtype']:\n return nt.void.__getattribute__(self, attr)\n fielddict = nt.void.__getattribute__(self, 'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.getfield(*res[:2])\n return nt.void.__getattribute__(self, attr)\n\n def __setattr__(self, attr, val):\n if attr in ['setfield', 'getfield', 'dtype']:\n raise AttributeError, \"Cannot set '%s' attribute\" % attr;\n fielddict = nt.void.__getattribute__(self,'dtype').fields\n res = fielddict.get(attr,None)\n if res:\n return self.setfield(val,*res[:2])\n\n return nt.void.__setattr__(self,attr,val)\n\n# The recarray is almost identical to a standard array (which supports\n# named fields already) The biggest difference is that it can use\n# attribute-lookup to find the fields and it is constructed using\n# a record.\n\n# If byteorder is given it forces a particular byteorder on all\n# the fields (and any subfields)\n\nclass recarray(sb.ndarray):\n def __new__(subtype, shape, formats, names=None, titles=None,\n buf=None, offset=0, strides=None, byteorder=None,\n aligned=0):\n\n if isinstance(formats, sb.dtype):\n descr = formats\n else:\n parsed = format_parser(formats, names, titles, aligned)\n descr = parsed._descr\n\n if (byteorder is not None):\n byteorder = _byteorderconv[byteorder[0]]\n descr = descr.newbyteorder(byteorder)\n\n if buf is None:\n self = sb.ndarray.__new__(subtype, shape, (record, descr))\n else:\n self = sb.ndarray.__new__(subtype, shape, (record, descr),\n buffer=buf, offset=offset,\n strides=strides)\n return self\n\n def __getattribute__(self, attr):\n try:\n return object.__getattribute__(self,attr)\n except AttributeError: # attr must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n res = fielddict[attr][:2]\n obj = self.getfield(*res)\n # if it has fields return a recarray, otherwise return\n # normal array\n if obj.dtype.fields:\n return obj\n if obj.dtype.char in 'SU':\n return obj.view(chararray)\n return obj.view(sb.ndarray)\n\n def __setattr__(self, attr, val):\n try:\n return object.__setattr__(self, attr, val)\n except AttributeError: # Must be a fieldname\n pass\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n res = fielddict[attr][:2]\n return self.setfield(val,*res)\n\n def field(self,attr, val=None):\n fielddict = sb.ndarray.__getattribute__(self,'dtype').fields\n\n if isinstance(attr,int):\n attr=fielddict[-1][attr]\n\n if val is None:\n return self.__getattribute__(attr)\n else:\n return self.__setattr__(attr,val)\n\ndef fromarrays(arrayList, formats=None, names=None, titles=None, shape=None,\n aligned=0):\n \"\"\" create a record array from a (flat) list of arrays\n\n >>> x1=array([1,2,3,4])\n >>> x2=array(['a','dd','xyz','12'])\n >>> x3=array([1.1,2,3,4])\n >>> r=fromarrays([x1,x2,x3],names='a,b,c')\n >>> print r[1]\n (2, 'dd', 2.0)\n >>> x1[1]=34\n >>> r.a\n array([1, 2, 3, 4])\n \"\"\"\n\n if shape is None or shape == 0:\n shape = arrayList[0].shape\n\n if isinstance(shape, int):\n shape = (shape,)\n\n if formats is None:\n # go through each object in the list to see if it is an ndarray\n # and determine the formats.\n formats = ''\n for obj in arrayList:\n if not isinstance(obj, sb.ndarray):\n raise ValueError, \"item in the array list must be an ndarray.\"\n formats += _typestr[obj.dtype.type]\n if issubclass(obj.dtype.type, nt.flexible):\n formats += `obj.itemsize`\n formats += ','\n formats=formats[:-1]\n\n for obj in arrayList:\n if obj.shape != shape:\n raise ValueError, \"array has different shape\"\n\n parsed = format_parser(formats, names, titles, aligned)\n _names = parsed._names\n _array = recarray(shape, parsed._descr)\n\n # populate the record array (makes a copy)\n for i in range(len(arrayList)):\n _array[_names[i]] = arrayList[i]\n\n return _array\n\n# shape must be 1-d if you use list of lists...\ndef fromrecords(recList, formats=None, names=None, titles=None, shape=None,\n aligned=0):\n \"\"\" create a recarray from a list of records in text form\n\n The data in the same field can be heterogeneous, they will be promoted\n to the highest data type. This method is intended for creating\n smaller record arrays. If used to create large array without formats\n defined\n\n r=fromrecords([(2,3.,'abc')]*100000)\n\n it can be slow.\n\n If formats is None, then this will auto-detect formats. Use list of\n tuples rather than list of lists for faster processing.\n\n >>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3')\n >>> print r[0]\n (456, 'dbe', 1.2)\n >>> r.col1\n array([456, 2])\n >>> r.col2\n chararray(['dbe', 'de'])\n >>> import cPickle\n >>> print cPickle.loads(cPickle.dumps(r))\n recarray[\n (456, 'dbe', 1.2),\n (2, 'de', 1.3)\n ]\n \"\"\"\n\n nfields = len(recList[0])\n if formats is None: # slower\n obj = sb.array(recList,dtype=object)\n arrlist = [sb.array(obj[...,i].tolist()) for i in xrange(nfields)]\n return fromarrays(arrlist, formats=formats, shape=shape, names=names,\n titles=titles, aligned=aligned)\n\n parsed = format_parser(formats, names, titles, aligned)\n try:\n retval = sb.array(recList, dtype = parsed._descr)\n except TypeError: # list of lists instead of list of tuples\n if (shape is None or shape == 0):\n shape = len(recList)\n if isinstance(shape, (int, long)):\n shape = (shape,)\n if len(shape) > 1:\n raise ValueError, \"Can only deal with 1-d array.\"\n _array = recarray(shape, parsed._descr)\n for k in xrange(_array.size):\n _array[k] = tuple(recList[k])\n return _array\n else:\n if shape is not None and retval.shape != shape:\n retval.shape = shape\n\n res = retval.view(recarray)\n res.dtype = sb.dtype((record, res.dtype))\n return res\n\n\ndef fromstring(datastring, formats, shape=None, names=None, titles=None,\n byteorder=None, aligned=0, offset=0):\n \"\"\" create a (read-only) record array from binary data contained in\n a string\"\"\"\n\n parsed = format_parser(formats, names, titles, aligned)\n itemsize = parsed._descr.itemsize\n if (shape is None or shape == 0 or shape == -1):\n shape = (len(datastring)-offset) / itemsize\n\n _array = recarray(shape, parsed._descr, names=names,\n titles=titles, buf=datastring, offset=offset,\n byteorder=byteorder)\n return _array\n\ndef fromfile(fd, formats, shape=None, names=None, titles=None,\n byteorder=None, aligned=0, offset=0):\n \"\"\"Create an array from binary file data\n\n If file is a string then that file is opened, else it is assumed\n to be a file object.\n\n >>> import testdata, sys\n >>> fd=open(testdata.filename)\n >>> fd.seek(2880*2)\n >>> r=fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big')\n >>> print r[0]\n (5.1000000000000005, 61, 'abcde')\n >>> r._shape\n (3,)\n \"\"\"\n\n if (shape is None or shape == 0):\n shape = (-1,)\n elif isinstance(shape, (int, long)):\n shape = (shape,)\n\n name = 0\n if isinstance(fd, str):\n name = 1\n fd = open(fd, 'rb')\n if (offset > 0):\n fd.seek(offset, 1)\n try:\n size = os.fstat(fd.fileno())[stat.ST_SIZE] - fd.tell()\n except:\n size = os.path.getsize(fd.name) - fd.tell()\n\n parsed = format_parser(formats, names, titles, aligned)\n itemsize = parsed._descr.itemsize\n\n shapeprod = sb.array(shape).prod()\n shapesize = shapeprod*itemsize\n if shapesize < 0:\n shape = list(shape)\n shape[ shape.index(-1) ] = size / -shapesize\n shape = tuple(shape)\n shapeprod = sb.array(shape).prod()\n\n nbytes = shapeprod*itemsize\n\n if nbytes > size:\n raise ValueError(\n \"Not enough bytes left in file for specified shape and type\")\n\n # create the array\n _array = recarray(shape, parsed._descr, byteorder=byteorder)\n nbytesread = fd.readinto(_array.data)\n if nbytesread != nbytes:\n raise IOError(\"Didn't read as many bytes as expected\")\n if name:\n fd.close()\n\n return _array\n\n\ndef array(obj, formats=None, names=None, titles=None, shape=None,\n byteorder=None, aligned=0, offset=0, strides=None):\n\n if isinstance(obj, (type(None), str, file)) and (formats is None):\n raise ValueError(\"Must define formats if object is \"\\\n \"None, string, or an open file\")\n\n elif obj is None:\n if shape is None:\n raise ValueError(\"Must define a shape if obj is None\")\n return recarray(shape, formats, names=names, titles=titles,\n buf=obj, offset=offset, strides=strides,\n byteorder=byteorder, aligned=aligned)\n elif isinstance(obj, str):\n return fromstring(obj, formats, names=names, titles=titles,\n shape=shape, byteorder=byteorder, aligned=aligned,\n offset=offset)\n elif isinstance(obj, (list, tuple)):\n if isinstance(obj[0], sb.ndarray):\n return fromarrays(obj, formats=formats, names=names, titles=titles,\n shape=shape, aligned=aligned)\n else:\n return fromrecords(obj, formats=formats, names=names, titles=titles,\n shape=shape, aligned=aligned)\n elif isinstance(obj, recarray):\n new = obj.copy()\n parsed = format_parser(formats, names, titles, aligned)\n new.dtype = parsed._descr\n return new\n elif isinstance(obj, file):\n return fromfile(obj, formats=formats, names=names, titles=titles,\n shape=shape, byteorder=byteorder, aligned=aligned,\n offset=offset)\n elif isinstance(obj, sb.ndarray):\n res = obj.view(recarray)\n if issubclass(res.dtype.type, nt.void):\n res.dtype = sb.dtype((record, res.dtype))\n return res\n else:\n raise ValueError(\"Unknown input type\")\n", + "methods": [ + { + "name": "find_duplicate", + "long_name": "find_duplicate( list )", + "filename": "records.py", + "nloc": 7, + "complexity": 4, + "token_count": 59, + "parameters": [ + "list" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , formats , names , titles , aligned = False )", + "filename": "records.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "formats", + "names", + "titles", + "aligned" + ], + "start_line": 43, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_parseFormats", + "long_name": "_parseFormats( self , formats , aligned = 0 )", + "filename": "records.py", + "nloc": 7, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self", + "formats", + "aligned" + ], + "start_line": 48, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "_setfieldnames", + "long_name": "_setfieldnames( self , names , titles )", + "filename": "records.py", + "nloc": 23, + "complexity": 10, + "token_count": 207, + "parameters": [ + "self", + "names", + "titles" + ], + "start_line": 58, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "_createdescr", + "long_name": "_createdescr( self )", + "filename": "records.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "records.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "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": "__str__", + "long_name": "__str__( self )", + "filename": "records.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 103, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattribute__", + "long_name": "__getattribute__( self , attr )", + "filename": "records.py", + "nloc": 14, + "complexity": 4, + "token_count": 95, + "parameters": [ + "self", + "attr" + ], + "start_line": 106, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , attr , val )", + "filename": "records.py", + "nloc": 14, + "complexity": 4, + "token_count": 97, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 122, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__new__", + "long_name": "__new__( subtype , shape , formats , names = None , titles = None , buf = None , offset = 0 , strides = None , byteorder = None , aligned = 0 )", + "filename": "records.py", + "nloc": 18, + "complexity": 4, + "token_count": 151, + "parameters": [ + "subtype", + "shape", + "formats", + "names", + "titles", + "buf", + "offset", + "strides", + "byteorder", + "aligned" + ], + "start_line": 147, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__getattribute__", + "long_name": "__getattribute__( self , attr )", + "filename": "records.py", + "nloc": 16, + "complexity": 5, + "token_count": 100, + "parameters": [ + "self", + "attr" + ], + "start_line": 169, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , attr , val )", + "filename": "records.py", + "nloc": 11, + "complexity": 3, + "token_count": 71, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 188, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "field", + "long_name": "field( self , attr , val = None )", + "filename": "records.py", + "nloc": 8, + "complexity": 3, + "token_count": 66, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 200, + "end_line": 209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "fromarrays", + "long_name": "fromarrays( arrayList , formats = None , names = None , titles = None , shape = None , aligned = 0 )", + "filename": "records.py", + "nloc": 25, + "complexity": 11, + "token_count": 195, + "parameters": [ + "arrayList", + "formats", + "names", + "titles", + "shape", + "aligned" + ], + "start_line": 211, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "fromrecords", + "long_name": "fromrecords( recList , formats = None , names = None , titles = None , shape = None , aligned = 0 )", + "filename": "records.py", + "nloc": 28, + "complexity": 11, + "token_count": 260, + "parameters": [ + "recList", + "formats", + "names", + "titles", + "shape", + "aligned" + ], + "start_line": 260, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( datastring , formats , shape = None , names = None , titles = None , byteorder = None , aligned = 0 , offset = 0 )", + "filename": "records.py", + "nloc": 10, + "complexity": 4, + "token_count": 111, + "parameters": [ + "datastring", + "formats", + "shape", + "names", + "titles", + "byteorder", + "aligned", + "offset" + ], + "start_line": 321, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( fd , formats , shape = None , names = None , titles = None , byteorder = None , aligned = 0 , offset = 0 )", + "filename": "records.py", + "nloc": 36, + "complexity": 11, + "token_count": 289, + "parameters": [ + "fd", + "formats", + "shape", + "names", + "titles", + "byteorder", + "aligned", + "offset" + ], + "start_line": 336, + "end_line": 394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "array", + "long_name": "array( obj , formats = None , names = None , titles = None , shape = None , byteorder = None , aligned = 0 , offset = 0 , strides = None )", + "filename": "records.py", + "nloc": 38, + "complexity": 12, + "token_count": 367, + "parameters": [ + "obj", + "formats", + "names", + "titles", + "shape", + "byteorder", + "aligned", + "offset", + "strides" + ], + "start_line": 397, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "find_duplicate", + "long_name": "find_duplicate( list )", + "filename": "records.py", + "nloc": 7, + "complexity": 4, + "token_count": 59, + "parameters": [ + "list" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , formats , names , titles , aligned = False )", + "filename": "records.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "formats", + "names", + "titles", + "aligned" + ], + "start_line": 43, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_parseFormats", + "long_name": "_parseFormats( self , formats , aligned = 0 )", + "filename": "records.py", + "nloc": 7, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self", + "formats", + "aligned" + ], + "start_line": 48, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "_setfieldnames", + "long_name": "_setfieldnames( self , names , titles )", + "filename": "records.py", + "nloc": 23, + "complexity": 10, + "token_count": 207, + "parameters": [ + "self", + "names", + "titles" + ], + "start_line": 58, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "_createdescr", + "long_name": "_createdescr( self )", + "filename": "records.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "records.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "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": "__str__", + "long_name": "__str__( self )", + "filename": "records.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 103, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattribute__", + "long_name": "__getattribute__( self , attr )", + "filename": "records.py", + "nloc": 8, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self", + "attr" + ], + "start_line": 106, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , attr , val )", + "filename": "records.py", + "nloc": 8, + "complexity": 3, + "token_count": 81, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 115, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__new__", + "long_name": "__new__( subtype , shape , formats , names = None , titles = None , buf = None , offset = 0 , strides = None , byteorder = None , aligned = 0 )", + "filename": "records.py", + "nloc": 18, + "complexity": 4, + "token_count": 151, + "parameters": [ + "subtype", + "shape", + "formats", + "names", + "titles", + "buf", + "offset", + "strides", + "byteorder", + "aligned" + ], + "start_line": 134, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__getattribute__", + "long_name": "__getattribute__( self , attr )", + "filename": "records.py", + "nloc": 13, + "complexity": 4, + "token_count": 89, + "parameters": [ + "self", + "attr" + ], + "start_line": 156, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , attr , val )", + "filename": "records.py", + "nloc": 8, + "complexity": 2, + "token_count": 60, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 172, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "field", + "long_name": "field( self , attr , val = None )", + "filename": "records.py", + "nloc": 8, + "complexity": 3, + "token_count": 66, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 181, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "fromarrays", + "long_name": "fromarrays( arrayList , formats = None , names = None , titles = None , shape = None , aligned = 0 )", + "filename": "records.py", + "nloc": 25, + "complexity": 11, + "token_count": 195, + "parameters": [ + "arrayList", + "formats", + "names", + "titles", + "shape", + "aligned" + ], + "start_line": 192, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "fromrecords", + "long_name": "fromrecords( recList , formats = None , names = None , titles = None , shape = None , aligned = 0 )", + "filename": "records.py", + "nloc": 28, + "complexity": 11, + "token_count": 260, + "parameters": [ + "recList", + "formats", + "names", + "titles", + "shape", + "aligned" + ], + "start_line": 241, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( datastring , formats , shape = None , names = None , titles = None , byteorder = None , aligned = 0 , offset = 0 )", + "filename": "records.py", + "nloc": 10, + "complexity": 4, + "token_count": 111, + "parameters": [ + "datastring", + "formats", + "shape", + "names", + "titles", + "byteorder", + "aligned", + "offset" + ], + "start_line": 302, + "end_line": 315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( fd , formats , shape = None , names = None , titles = None , byteorder = None , aligned = 0 , offset = 0 )", + "filename": "records.py", + "nloc": 36, + "complexity": 11, + "token_count": 289, + "parameters": [ + "fd", + "formats", + "shape", + "names", + "titles", + "byteorder", + "aligned", + "offset" + ], + "start_line": 317, + "end_line": 375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "array", + "long_name": "array( obj , formats = None , names = None , titles = None , shape = None , byteorder = None , aligned = 0 , offset = 0 , strides = None )", + "filename": "records.py", + "nloc": 38, + "complexity": 12, + "token_count": 367, + "parameters": [ + "obj", + "formats", + "names", + "titles", + "shape", + "byteorder", + "aligned", + "offset", + "strides" + ], + "start_line": 378, + "end_line": 417, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__getattribute__", + "long_name": "__getattribute__( self , attr )", + "filename": "records.py", + "nloc": 14, + "complexity": 4, + "token_count": 95, + "parameters": [ + "self", + "attr" + ], + "start_line": 106, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , attr , val )", + "filename": "records.py", + "nloc": 14, + "complexity": 4, + "token_count": 97, + "parameters": [ + "self", + "attr", + "val" + ], + "start_line": 122, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + } + ], + "nloc": 293, + "complexity": 93, + "token_count": 2377, + "diff_parsed": { + "added": [ + " try:", + " return nt.void.__getattribute__(self, attr)", + " except AttributeError:", + " pass", + " else:", + " raise AttributeError, \"'record' object has no \"\\", + " \"attribute '%s'\" % attr", + "", + " try:", + " return nt.void.__setattr__(self,attr,val)", + " except AttributeError:", + " pass", + " else:", + " raise AttributeError, \"'record' object has no \"\\", + " \"attribute '%s'\" % attr", + " try:", + " res = fielddict[attr][:2]", + " except KeyError:", + " raise AttributeError, \"record array has no attribute %s\" % attr", + " try:", + " res = fielddict[attr][:2]", + " except KeyError:", + " raise AttributeError, \"record array has no attribute %s\" % attr" + ], + "deleted": [ + " return nt.void.__getattribute__(self, attr)", + " return nt.void.__setattr__(self,attr,val)", + " res = fielddict[attr][:2]", + " res = fielddict[attr][:2]" + ] + } + }, + { + "old_path": "numpy/core/src/arraymethods.c", + "new_path": "numpy/core/src/arraymethods.c", + "filename": "arraymethods.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -876,12 +876,12 @@ array_reduce(PyArrayObject *self, PyObject *args)\n \tPy_DECREF(mod);\n \tPyTuple_SET_ITEM(ret, 0, obj);\n \tPyTuple_SET_ITEM(ret, 1, \n-\t\t\t Py_BuildValue(\"ONN\",\n+\t\t\t Py_BuildValue(\"ONc\",\n \t\t\t\t (PyObject *)self->ob_type,\n \t\t\t\t Py_BuildValue(\"(N)\",\n \t\t\t\t\t\t PyInt_FromLong(0)),\n-\t\t\t\t PyObject_GetAttrString((PyObject *)(self->descr),\n-\t\t\t\t\t\t\t \"char\")));\n+\t\t\t\t /* dummy data-type */\n+\t\t\t\t 'b'));\n \t\n \t/* Now fill in object's state. This is a tuple with \n \t 4 arguments\n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "\n/* Should only be used if x is known to be an nd-array */\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_take[] = \"a.take(indices, axis=None). Selects the elements \"\\\n\t\"in indices from array a along the given axis.\";\n\nstatic PyObject *\narray_take(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint dimension=MAX_DIMS;\n\tPyObject *indices;\n\tstatic char *kwlist[] = {\"indices\", \"axis\", NULL};\n\t\n\tdimension=0;\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &indices, PyArray_AxisConverter,\n\t\t\t\t\t &dimension))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Take(self, indices, dimension));\n}\n\nstatic char doc_fill[] = \"a.fill(value) places the scalar value at every \"\\\n\t\"position in the array.\";\n\nstatic PyObject *\narray_fill(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *obj;\n\tif (!PyArg_ParseTuple(args, \"O\", &obj))\n\t\treturn NULL;\n\tif (PyArray_FillWithScalar(self, obj) < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_put[] = \"a.put(values, indices) sets a.flat[n] = v[n] \"\\\n\t\"for each n in indices. v can be scalar or shorter than indices, \"\\\n\t\"will repeat.\";\n\nstatic PyObject *\narray_put(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *indices, *values;\n\tstatic char *kwlist[] = {\"values\", \"indices\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &indices))\n\t\treturn NULL;\n\treturn PyArray_Put(self, values, indices);\n}\n\nstatic char doc_putmask[] = \"a.putmask(values, mask) sets a.flat[n] = v[n] \"\\\n\t\"for each n where mask.flat[n] is TRUE. v can be scalar.\";\n\nstatic PyObject *\narray_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *mask, *values;\n\n\tstatic char *kwlist[] = {\"values\", \"mask\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &mask))\n\t\treturn NULL;\n\treturn PyArray_PutMask(self, values, mask);\n}\n\nstatic char doc_reshape[] = \\\n\t\"self.reshape(d1, d2, ..., dn, order='C') \\n\"\t\n\t\"Return a new array from this one. \\n\"\t\t\t\t\n\t\"\\n The new array must have the same number of elements as self. \" \n\t\"Also\\n always returns a view or raises a ValueError if that is \\n\"\n\t\"impossible.\";\n\nstatic PyObject *\narray_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tPyArray_ORDER order=PyArray_CORDER;\n\tint n;\n\t\n\tif (kwds != NULL) {\n\t\tPyObject *ref;\n\t\tref = PyDict_GetItemString(kwds, \"order\");\n\t\tif (ref == NULL || \\\n\t\t (PyArray_OrderConverter(ref, &order) == PY_FAIL))\n\t\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\tgoto fail;\n\t\t}\n\t}\n\tret = PyArray_Newshape(self, &newshape, order);\n\tPyDimMem_FREE(newshape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(newshape.ptr);\n\treturn NULL;\n}\n\nstatic char doc_squeeze[] = \"m.squeeze() eliminate all length-1 dimensions\";\n\nstatic PyObject *\narray_squeeze(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return _ARET(PyArray_Squeeze(self));\n}\n\nstatic char doc_view[] = \"a.view() return a new view of array with same data. type can be either a new sub-type object or a data-descriptor object\";\n\nstatic PyObject *\narray_view(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *otype=NULL;\n PyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTuple(args, \"|O\", &otype)) return NULL;\n\n\tif (otype) {\n\t\tif (PyType_Check(otype) &&\t\t\t\\\n\t\t PyType_IsSubtype((PyTypeObject *)otype, \n\t\t\t\t &PyArray_Type)) {\n\t\t\treturn PyArray_View(self, NULL, \n (PyTypeObject *)otype);\n }\n\t\telse {\n\t\t\tif (PyArray_DescrConverter(otype, &type) == PY_FAIL) \n\t\t\t\treturn NULL;\n\t\t}\n\t}\n\treturn PyArray_View(self, type, NULL);\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn _ARET(PyArray_ArgMax(self, axis));\n}\n\nstatic char doc_argmin[] = \"a.argmin(axis=None)\";\n\nstatic PyObject *\narray_argmin(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn _ARET(PyArray_ArgMin(self, axis));\n}\n\nstatic char doc_max[] = \"a.max(axis=None)\";\n\nstatic PyObject *\narray_max(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Max(self, axis);\n}\n\nstatic char doc_ptp[] = \"a.ptp(axis=None) a.max(axis)-a.min(axis)\";\n\nstatic PyObject *\narray_ptp(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\t\n\treturn PyArray_Ptp(self, axis);\n}\n\n\nstatic char doc_min[] = \"a.min(axis=None)\";\n\nstatic PyObject *\narray_min(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Min(self, axis);\n}\n\nstatic char doc_swapaxes[] = \"a.swapaxes(axis1, axis2) returns new view with axes swapped.\";\n\nstatic PyObject *\narray_swapaxes(PyArrayObject *self, PyObject *args)\n{\n\tint axis1, axis2;\n\n\tif (!PyArg_ParseTuple(args, \"ii\", &axis1, &axis2)) return NULL;\n\n\treturn PyArray_SwapAxes(self, axis1, axis2);\n}\n\nstatic char doc_getfield[] = \"m.getfield(dtype, offset) returns a field \"\\\n\t\" of the given array as a certain type. A field is a view of \"\\\n\t\" the array's data with each itemsize determined by the given type\"\\\n\t\" and the offset into the current array.\";\n\n/* steals typed reference */\n/*OBJECT_API\n Get a subset of bytes from each element of the array\n*/\nstatic PyObject *\nPyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int offset)\n{\n\tPyObject *ret=NULL;\n\n\tif (offset < 0 || (offset + typed->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-typed->elsize, offset);\n\t\tPy_DECREF(typed);\n\t\treturn NULL;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t typed,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, \n\t\t\t\t self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self; \n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\treturn ret;\n}\n\nstatic PyObject *\narray_getfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tstatic char *kwlist[] = {\"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|i\", kwlist,\n\t\t\t\t\t PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\t\n\treturn _ARET(PyArray_GetField(self, dtype, offset));\n}\n\n\nstatic char doc_setfield[] = \"m.setfield(value, dtype, offset) places val \"\\\n\t\"into field of the given array defined by the data type and offset.\";\n\n/*OBJECT_API\n Set a subset of bytes from each element of the array\n*/\nstatic int\nPyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,\n\t\t int offset, PyObject *val)\n{\n\tPyObject *ret=NULL;\n\tint retval = 0;\n \n\tif (offset < 0 || (offset + dtype->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-dtype->elsize, offset);\n\t\tPy_DECREF(dtype);\n\t\treturn -1;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t dtype, self->nd, self->dimensions,\n\t\t\t\t self->strides, self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return -1;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self;\n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\t\n\tretval = PyArray_CopyObject((PyArrayObject *)ret, val);\n\tPy_DECREF(ret);\n\treturn retval;\n}\n\nstatic PyObject *\narray_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tPyObject *value;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value, PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\n\tif (PyArray_SetField(self, dtype, offset, value) < 0)\n\t\treturn NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* This doesn't change the descriptor just the actual data...\n */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Byteswap(PyArrayObject *self, Bool inplace)\n{\n PyArrayObject *ret;\n\tintp size;\n\tPyArray_CopySwapNFunc *copyswapn;\n\tPyArray_CopySwapFunc *copyswap;\n\tPyArrayIterObject *it;\n\n\tif (inplace) {\n\t\tcopyswapn = self->descr->f->copyswapn;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\t\tif (PyArray_ISONESEGMENT(self)) {\n\t\t\tcopyswapn(self->data, NULL, size, 1, \n\t\t\t\t self->descr->elsize);\n\t\t}\n\t\telse { /* Use iterator */\n\t\t\t\n\t\t\tit = (PyArrayIterObject *)\\\n\t\t\t\tPyArray_IterNew((PyObject *)self);\n\t\t\tcopyswap = self->descr->f->copyswap;\n\t\t\twhile (it->index < it->size) {\n\t\t\t\tcopyswap(it->dataptr, NULL, 1, \n\t\t\t\t\t self->descr->elsize);\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t}\n\t\t\tPy_DECREF(it);\n\t\t}\n\t\t\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tif ((ret = (PyArrayObject *)PyArray_NewCopy(self,-1)) == NULL) \n\t\t\treturn NULL;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\n\t\t/* now ret has the same dtypedescr as self (including\n\t\t byteorder)\n\t\t*/\n\n\t\tret->descr->f->copyswapn(ret->data, NULL, size, 1, \n\t\t\t\t\t ret->descr->elsize);\n\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic char doc_byteswap[] = \"m.byteswap(False) Swap the bytes in\"\\\n\t\" the array. Return the byteswapped array. If the first argument\"\\\n\t\" is TRUE, byteswap in-place and return a reference to self.\";\n\nstatic PyObject *\narray_byteswap(PyArrayObject *self, PyObject *args) \n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\treturn PyArray_Byteswap(self, inplace);\n}\n\nstatic char doc_tolist[] = \"m.tolist().\t Copy the data portion of the array\"\\\n\t\" to a hierarchical python list and return that list.\";\n\nstatic PyObject *\narray_tolist(PyArrayObject *self, PyObject *args) \n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n if (self->nd <= 0) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can't convert a 0-d array to a list\");\n return NULL;\n }\n\t\n return PyArray_ToList(self);\n}\n\nstatic char doc_tostring[] = \"m.tostring() Construct a Python string \"\\\n \"containing the raw bytes in the array\";\n\nstatic PyObject *\narray_tostring(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return PyArray_ToString(self);\n}\n\nstatic char doc_tofile[] = \"m.tofile(fid, sep=\"\") write the data to a file.\";\n\nstatic PyObject *\narray_tofile(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tint ret;\n PyObject *file;\n\tFILE *fd;\n char *sep=\"\";\n\tchar *format=\"\";\n\tchar *mode=\"\";\n\tstatic char *kwlist[] = {\"file\", \"sep\", \"format\", NULL};\n \n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ss\", kwlist, \n &file, &sep, &format)) return NULL;\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"wb\";\n\t\telse mode=\"w\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfd = PyFile_AsFile(file);\n\tif (fd == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"first argument must be a \" \\\n\t\t\t\t\"string or open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_ToFile(self, fd, sep, format);\n\tPy_DECREF(file);\n\tif (ret < 0) return NULL;\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_toscalar[] = \"m.item(). Copy the first data point of \"\\\n\t\"the array to a standard Python scalar and return it.\";\n\nstatic PyObject *\narray_toscalar(PyArrayObject *self, PyObject *args) {\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tif (self->nd == 0 || PyArray_SIZE(self) == 1) \n\t\treturn self->descr->f->getitem(self->data, self);\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \"can only convert an\"\t\\\n\t\t\t\t\" array of size 1 to Python scalar.\");\n\t\treturn NULL;\n\t}\n}\n\nstatic char doc_cast[] = \"m.astype(t).\tCast array m to type t.\t \\n\\n\"\\\n\t\"t can be either a string representing a typecode, or a python type\"\\\n\t\" object of type int, float, or complex.\";\n\nstatic PyObject *\narray_cast(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *descr=NULL;\n\tPyObject *obj;\n\t\n if (!PyArg_ParseTuple(args, \"O&\", PyArray_DescrConverter,\n\t\t\t &descr)) return NULL;\n\t\n\tif (descr == self->descr) {\n\t\tobj = _ARET(PyArray_NewCopy(self,0));\n\t\tPy_XDECREF(descr);\n\t\treturn obj;\n\t}\n\treturn _ARET(PyArray_CastToType(self, descr, 0));\n}\t \n\n/* default sub-type implementation */\n\nstatic char doc_wraparray[] = \"m.__array_wrap__(obj) returns an object of \"\\\n\t\"type m from the ndarray object obj\";\n\nstatic PyObject *\narray_wraparray(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *arr;\n\tPyObject *ret;\n\t\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\t\n\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t PyArray_NDIM(arr),\n\t\t\t\t PyArray_DIMS(arr), \n\t\t\t\t PyArray_STRIDES(arr), PyArray_DATA(arr),\n\t\t\t\t PyArray_FLAGS(arr), (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(arr);\n\tPyArray_BASE(ret) = arr;\n\treturn ret;\n}\n\n/* NO-OP --- just so all subclasses will have one by default. */\nstatic PyObject *\narray_finalize(PyArrayObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic char doc_array_getarray[] = \"m.__array__(|dtype) just returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.\";\n\nstatic PyObject *\narray_getarray(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *newtype=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_DescrConverter,\n\t\t\t &newtype)) return NULL;\n\t\n\t/* convert to PyArray_Type */\n\tif (!PyArray_CheckExact(self)) {\n\t\tPyObject *new;\n\t\tPyTypeObject *subtype = &PyArray_Type;\n\n\t\tif (!PyType_IsSubtype(self->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyArray_Type;\n\t\t}\n\t\t\n\t\tPy_INCREF(PyArray_DESCR(self));\n\t\tnew = PyArray_NewFromDescr(subtype, \n\t\t\t\t\t PyArray_DESCR(self),\n\t\t\t\t\t PyArray_NDIM(self),\n\t\t\t\t\t PyArray_DIMS(self), \n\t\t\t\t\t PyArray_STRIDES(self), \n\t\t\t\t\t PyArray_DATA(self),\n\t\t\t\t\t PyArray_FLAGS(self), NULL);\n\t\tif (new == NULL) return NULL;\n\t\tPy_INCREF(self);\n\t\tPyArray_BASE(new) = (PyObject *)self;\n\t\tself = (PyArrayObject *)new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t}\n\t\t\n\tif ((newtype == NULL) || \\\n\t PyArray_EquivTypes(self->descr, newtype)) {\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tret = PyArray_CastToType(self, newtype, 0);\n\t\tPy_DECREF(self);\n\t\treturn ret;\n\t}\n}\n\nstatic char doc_copy[] = \"m.copy(|fortran). Return a copy of the array.\\n\"\\\n\t\"If fortran is false then the result is contiguous (default). \\n\"\\\n\t\"If fortran is true then the result has fortran data order. \\n\"\\\n\t\"If fortran is None then the result has fortran data order only if m\\n\"\n\t\" is already in fortran order.\";\n\nstatic PyObject *\narray_copy(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n if (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter,\n\t\t\t &fortran)) return NULL;\n\t\n return PyArray_NewCopy(self, fortran);\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape, refcheck=True, fortran=False). \"\\\n\t\"Change size and shape of self inplace.\\n\"\\\n\t\"\\n Array must own its own memory and not be referenced by other \" \\\n\t\"arrays\\n Returns None.\";\n\nstatic PyObject *\narray_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\n\tint refcheck = 1;\n\tPyArray_ORDER fortran=PyArray_ANYORDER;\n\t\n\tif (kwds != NULL) {\n\t\tPyObject *ref;\n\t\tref = PyDict_GetItemString(kwds, \"refcheck\");\n\t\tif (ref) {\n\t\t\trefcheck = PyInt_AsLong(ref);\n\t\t\tif (refcheck==-1 && PyErr_Occurred()) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tref = PyDict_GetItemString(kwds, \"fortran\");\n\t\tif (ref != NULL || \n\t\t (PyArray_OrderConverter(ref, &fortran) == PY_FAIL))\n\t\t\treturn NULL;\n\t}\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\treturn NULL;\t\t\t\n\t\t}\n\t}\t\n\tret = PyArray_Resize(self, &newshape, refcheck, fortran);\n PyDimMem_FREE(newshape.ptr);\n if (ret == NULL) return NULL;\n\tPy_DECREF(ret);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_repeat[] = \"a.repeat(repeats=, axis=None)\\n\"\\\n\t\"\\n\"\\\n\t\" Copy elements of a, repeats times. The repeats argument must\\n\"\\\n\t\" be a sequence of length a.shape[axis] or a scalar.\";\n\nstatic PyObject *\narray_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {\n\tPyObject *repeats;\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"repeats\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &repeats, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Repeat(self, repeats, axis));\n}\n\nstatic char doc_choose[] = \"a.choose(b0, b1, ..., bn)\\n\"\\\n\t\"\\n\"\\\n\t\"Return an array with elements chosen from 'a' at the positions\\n\"\\\n \"of the given arrays b_i. The array 'a' should be an integer array\\n\"\\\n \"with entries from 0 to n+1, and the b_i arrays should have the same\\n\"\\\n \"shape as 'a'.\";\n\nstatic PyObject *\narray_choose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *choices;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O\", &choices))\n\t\t\treturn NULL;\n\t}\n else {\n\t\tchoices = args;\n\t}\n\t\n\treturn _ARET(PyArray_Choose(self, choices));\n}\n\nstatic char doc_sort[] = \"a.sort(axis=-1,kind='quicksort') sorts in place along axis. Return is None and kind can be 'quicksort', 'mergesort', or 'heapsort'\";\n\nstatic PyObject *\narray_sort(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=-1;\n\tint val;\n\tPyArray_SORTKIND which=PyArray_QUICKSORT;\n\tstatic char *kwlist[] = {\"axis\", \"kind\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iO&\", kwlist, &axis,\n\t\t\t\t\t PyArray_SortkindConverter, &which))\n\t\treturn NULL;\n\t\n\tval = PyArray_Sort(self, axis, which);\n\tif (val < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_argsort[] = \"a.argsort(axis=-1,kind='quicksort')\\n\"\\\n\t\" Return the indexes into a that would sort it along the\"\\\n\t\" given axis; kind can be 'quicksort', 'mergesort', or 'heapsort'\";\n\nstatic PyObject *\narray_argsort(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=-1;\n\tPyArray_SORTKIND which=PyArray_QUICKSORT;\n\tstatic char *kwlist[] = {\"axis\", \"kind\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iO&\", kwlist, &axis,\n\t\t\t\t\t PyArray_SortkindConverter, &which))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_ArgSort(self, axis, which));\n}\n\nstatic char doc_searchsorted[] = \"a.searchsorted(v)\\n\"\\\n\t\" Assuming that a is a 1-D array, in ascending order and\\n\"\\\n\t\" represents bin boundaries, then a.searchsorted(values) gives an\\n\"\\\n\t\" array of bin numbers, giving the bin into which each value would\\n\"\\\n\t\" be placed. This method is helpful for histograming. \\n\"\\\n\t\" Note: No warning is given if the boundaries, in a, are not \\n\"\\\n\t\" in ascending order.\";\n\nstatic PyObject *\narray_searchsorted(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *values;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &values)) return NULL;\n\t\n\treturn _ARET(PyArray_SearchSorted(self, values));\n}\n\nstatic char doc_deepcopy[] = \"Used if copy.deepcopy is called on an array.\";\n\nstatic PyObject *\narray_deepcopy(PyArrayObject *self, PyObject *args) \n{\n PyObject* visit;\n PyObject **optr;\n PyArrayIterObject *it;\n PyObject *copy, *ret, *deepcopy, *temp, *res;\n\n if (!PyArg_ParseTuple(args, \"O\", &visit)) return NULL;\n ret = PyArray_Copy(self);\n if (PyArray_ISOBJECT(self)) {\n copy = PyImport_ImportModule(\"copy\");\n if (copy == NULL) return NULL;\n deepcopy = PyObject_GetAttrString(copy, \"deepcopy\");\n Py_DECREF(copy);\n if (deepcopy == NULL) return NULL;\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it == NULL) {Py_DECREF(deepcopy); return NULL;}\n optr = (PyObject **)PyArray_DATA(ret);\n while(it->index < it->size) {\n temp = *((PyObject **)it->dataptr);\n Py_INCREF(temp);\n /* call deepcopy on this argument */\n res = PyObject_CallFunctionObjArgs(deepcopy, \n temp, visit, NULL);\n Py_DECREF(temp);\n Py_DECREF(*optr);\n *optr++ = res;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(deepcopy);\n Py_DECREF(it);\n }\n return _ARET(ret);\n}\n\n/* Convert Object Array to flat list and pickle the flat list string */\nstatic PyObject *\n_getobject_pkl(PyArrayObject *self)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tPyObject *list;\n\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return NULL;\n\tlist = PyList_New(iter->size);\n\tif (list == NULL) {Py_DECREF(iter); return NULL;}\n\twhile (iter->index < iter->size) {\n\t\ttheobject = *((PyObject **)iter->dataptr);\n\t\tPy_INCREF(theobject);\n\t\tPyList_SET_ITEM(list, (int) iter->index, theobject);\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_DECREF(iter);\n\treturn list;\n}\n\nstatic int\n_setobject_pkl(PyArrayObject *self, PyObject *list)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tint size;\n\n\tsize = self->descr->elsize;\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return -1;\n\twhile(iter->index < iter->size) {\n\t\ttheobject = PyList_GET_ITEM(list, (int) iter->index);\n\t\tPy_INCREF(theobject);\n\t\t*((PyObject **)iter->dataptr) = theobject;\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_XDECREF(iter);\n\treturn 0;\n}\n\nstatic char doc_reduce[] = \"a.__reduce__() for pickling.\";\n\nstatic PyObject *\narray_reduce(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *state=NULL, *obj=NULL, *mod=NULL;\n\tPyObject *mybool, *thestr=NULL;\n\tPyArray_Descr *descr;\n\n\t/* Return a tuple of (callable object, arguments, object's state) */\n\t/* We will put everything in the object's state, so that on UnPickle\n\t it can use the string object as memory without a copy */\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"numpy.core._internal\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"_reconstruct\");\n\tPy_DECREF(mod);\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t Py_BuildValue(\"ONc\",\n\t\t\t\t (PyObject *)self->ob_type,\n\t\t\t\t Py_BuildValue(\"(N)\",\n\t\t\t\t\t\t PyInt_FromLong(0)),\n\t\t\t\t /* dummy data-type */\n\t\t\t\t 'b'));\n\t\n\t/* Now fill in object's state. This is a tuple with \n\t 4 arguments\n\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object (with correct bytorder set)\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list for Object arrays)\n\n\t Notice because Python does not describe a mechanism to write \n\t raw data to the pickle, this performs a copy to a string first\n\t*/\n\n\tstate = PyTuple_New(4);\n\tif (state == NULL) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 0, PyObject_GetAttrString((PyObject *)self, \n\t\t\t\t\t\t\t \"shape\"));\n\tdescr = self->descr;\n\tPy_INCREF(descr);\n\tPyTuple_SET_ITEM(state, 1, (PyObject *)descr);\n\tmybool = (PyArray_ISFORTRAN(self) ? Py_True : Py_False);\n\tPy_INCREF(mybool);\n\tPyTuple_SET_ITEM(state, 2, mybool);\n\tif (PyArray_ISOBJECT(self)) {\n\t\tthestr = _getobject_pkl(self);\n\t}\n\telse {\n thestr = PyArray_ToString(self);\n\t}\n\tif (thestr == NULL) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(state);\n\t\treturn NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 3, thestr);\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\nstatic char doc_setstate[] = \"a.__setstate__(tuple) for unpickling.\";\n\n/*\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list if Object array) \n*/\n\nstatic intp _array_fill_strides(intp *, intp *, int, intp, int, int *);\n\nstatic int _IsAligned(PyArrayObject *); \n\nstatic PyArray_Descr * _array_typedescr_fromstr(char *);\n\nstatic PyObject *\narray_setstate(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *shape;\n\tPyArray_Descr *typecode;\n\tint fortran;\n\tPyObject *rawdata;\n\tchar *datastr;\n\tint len;\n\tintp dimensions[MAX_DIMS];\n\tint nd;\n\t\n\t/* This will free any memory associated with a and\n\t use the string in setstate as the (writeable) memory.\n\t*/\n\tif (!PyArg_ParseTuple(args, \"(O!O!iO)\", &PyTuple_Type,\n\t\t\t &shape, &PyArrayDescr_Type, &typecode, \n\t\t\t &fortran, &rawdata))\n\t\treturn NULL;\n\n\tPy_XDECREF(self->descr);\n\tself->descr = typecode;\n\tPy_INCREF(typecode);\n\tnd = PyArray_IntpFromSequence(shape, dimensions, MAX_DIMS);\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (!PyList_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"object pickle not returning list\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tif (!PyString_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"pickle not returning string\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (PyString_AsStringAndSize(rawdata, &datastr, &len))\n\t\t\treturn NULL;\n\n\t\tif ((len != (self->descr->elsize *\t\t\t\\\n\t\t\t (int) PyArray_MultiplyList(dimensions, nd)))) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size does not\"\t\\\n\t\t\t\t\t\" match array size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n if ((self->flags & OWN_DATA)) {\n\t\tif (self->data != NULL)\n\t\t\tPyDataMem_FREE(self->data);\n\t\tself->flags &= ~OWN_DATA;\n }\n\tPy_XDECREF(self->base);\n\n\tself->flags &= ~UPDATEIFCOPY;\n\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t\tself->dimensions = NULL;\n\t}\n\n\tself->flags = DEFAULT_FLAGS;\n\n\tself->nd = nd;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(nd * 2);\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dimensions, sizeof(intp)*nd);\n\t\t(void) _array_fill_strides(self->strides, dimensions, nd,\n\t\t\t\t\t self->descr->elsize, \n (fortran ? FORTRAN : CONTIGUOUS),\n\t\t\t\t\t &(self->flags));\n\t}\n\n\tif (typecode->type_num != PyArray_OBJECT) {\n\t\tself->data = datastr;\n\t\tif (!_IsAligned(self)) {\n\t\t\tintp num = PyArray_NBYTES(self);\n\t\t\tself->data = PyDataMem_NEW(num);\n\t\t\tif (self->data == NULL) {\n\t\t\t\tself->nd = 0;\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemcpy(self->data, datastr, num);\n\t\t\tself->flags |= OWN_DATA;\n\t\t\tself->base = NULL;\n\t\t}\n\t\telse {\n\t\t\tself->base = rawdata;\n\t\t\tPy_INCREF(self->base);\n\t\t}\n\t}\n\telse {\n\t\tself->data = PyDataMem_NEW(PyArray_NBYTES(self));\n\t\tif (self->data == NULL) { \n\t\t\tself->nd = 0;\n\t\t\tself->data = PyDataMem_NEW(self->descr->elsize);\n\t\t\tif (self->dimensions) PyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\t\tself->base = NULL;\n\t\tif (_setobject_pkl(self, rawdata) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\t\n}\n\n/*OBJECT_API*/\nstatic int\nPyArray_Dump(PyObject *self, PyObject *file, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return -1;\n\n\tif PyString_Check(file) {\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), \"wb\");\n\t\tif (file==NULL) return -1;\n\t}\n\telse Py_INCREF(file);\n\tret = PyObject_CallMethod(cpick, \"dump\", \"OOi\", self, \n\t\t\t\t file, protocol);\n\tPy_XDECREF(ret);\n\tPy_DECREF(file);\n\tPy_DECREF(cpick);\n\tif (PyErr_Occurred()) return -1;\n\treturn 0;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Dumps(PyObject *self, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return NULL;\n\tret = PyObject_CallMethod(cpick, \"dumps\", \"Oi\", self, protocol);\n\tPy_DECREF(cpick);\n\treturn ret;\n}\n\n\nstatic char doc_dump[] = \"m.dump(file)\";\n\nstatic PyObject *\narray_dump(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump((PyObject *)self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_dumps[] = \"m.dumps()\";\n\nstatic PyObject *\narray_dumps(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps((PyObject *)self, 2);\n}\n\n\nstatic char doc_transpose[] = \"m.transpose()\";\n\nstatic PyObject *\narray_transpose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *shape=Py_None;\n\tint n;\n\tPyArray_Dims permute;\n\tPyObject *ret;\n\n\tn = PyTuple_Size(args);\n\tif (n > 1) shape = args;\n\telse if (n == 1) shape = PyTuple_GET_ITEM(args, 0);\n\t\n\tif (shape == Py_None)\n\t\tret = PyArray_Transpose(self, NULL);\n\telse {\n\t\tif (!PyArray_IntpConverter(shape, &permute)) return NULL;\n\t\tret = PyArray_Transpose(self, &permute);\n\t\tPyDimMem_FREE(permute.ptr);\n\t}\n\t\n\treturn _ARET(ret);\n}\n\nstatic char doc_mean[] = \"a.mean(axis=None, dtype=None)\\n\\n\"\\\n \"Average the array over the given axis. If the axis is None, average\\n\"\\\n \"over all dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"If an integer axis is given, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / len(a)\\n\"\\\n \"\\n\"\\\n \"If axis is None, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / product(a.shape)\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for intermediate\\n\"\\\n \"calculations in the sum.\";\n\n#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)\n\nstatic PyObject *\narray_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist,\n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\n\treturn PyArray_Mean(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_sum[] = \"a.sum(axis=None, dtype=None)\\n\\n\"\\\n \"Sum the array over the given axis. If the axis is None, sum over all\\n\"\\\n \"dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for the returned value\\n\"\\\n \"and intermediate calculations. The default is to upcast (promote)\\n\"\\\n \"smaller integer types to the platform-dependent int. For example, on\\n\"\\\n \"32-bit platforms:\\n\"\\\n \"\\n\"\\\n \" a.dtype default sum() dtype\\n\"\\\n \" ---------------------------------------------------\\n\"\\\n \" bool, int8, int16, int32 int32\\n\"\\\n \"\\n\"\\\n \"Examples:\\n\"\\\n \"\\n\"\\\n \">>> array([0.5, 1.5]).sum()\\n\"\\\n \"2.0\\n\"\\\n \">>> array([0.5, 1.5]).sum(dtype=int32)\\n\"\\\n \"1\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=0)\\n\"\\\n \"array([0, 6])\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=1)\\n\"\\\n \"array([1, 5])\";\n\nstatic PyObject *\narray_sum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Sum(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumsum[] = \"a.cumsum(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_prod[] = \"a.prod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_prod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Prod(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumprod[] = \"a.cumprod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_any[] = \"a.any(axis=None)\";\n\nstatic PyObject *\narray_any(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Any(self, axis);\n}\n\nstatic char doc_all[] = \"a.all(axis=None)\";\n\nstatic PyObject *\narray_all(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\n\treturn PyArray_All(self, axis);\n}\n\nstatic char doc_stddev[] = \"a.std(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 0);\n}\n\nstatic char doc_variance[] = \"a.var(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 1);\n}\n\nstatic char doc_compress[] = \"a.compress(condition=, axis=None)\";\n\nstatic PyObject *\narray_compress(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyObject *condition;\t\n\tstatic char *kwlist[] = {\"condition\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &condition, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\n\treturn _ARET(PyArray_Compress(self, condition, axis));\n}\n\nstatic char doc_nonzero[] = \"a.nonzero() return a tuple of indices referencing \"\\\n\t\"the elements of a that are nonzero.\";\n\nstatic PyObject *\narray_nonzero(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\treturn _ARET(PyArray_Nonzero(self));\n}\n\n\nstatic char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, dtype=None)\\n\"\\\n\t\"return the sum along the offset diagonal of the arrays indicated\\n\" \\\n\t\"axis1 and axis2.\";\n\nstatic PyObject *\narray_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iiiO&\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2,\n\t\t\t\t\t PyArray_DescrConverter2, &dtype))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Trace(self, offset, axis1, axis2, \n\t\t\t\t _CHKTYPENUM(dtype)));\n}\n\n#undef _CHKTYPENUM\n\n\nstatic char doc_clip[] = \"a.clip(min=, max=)\";\n\nstatic PyObject *\narray_clip(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *min, *max;\n\tstatic char *kwlist[] = {\"min\", \"max\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &min, &max)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Clip(self, min, max));\n}\n\nstatic char doc_conj[] = \"a.conj()\";\n\nstatic char doc_conjugate[] = \"a.conjugate()\";\n\nstatic PyObject *\narray_conjugate(PyArrayObject *self, PyObject *args) \n{\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\treturn PyArray_Conjugate(self);\n}\n\n\nstatic char doc_diagonal[] = \"a.diagonal(offset=0, axis1=0, axis2=1)\";\n\nstatic PyObject *\narray_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iii\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Diagonal(self, offset, axis1, axis2));\n}\n\nstatic char doc_flatten[] = \"a.flatten([fortran]) return a 1-d array (always copy)\";\n\nstatic PyObject *\narray_flatten(PyArrayObject *self, PyObject *args)\n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter, \n\t\t\t &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, fortran);\n}\n\nstatic char doc_ravel[] = \"a.ravel([fortran]) return a 1-d array (copy only if needed)\";\n\nstatic PyObject *\narray_ravel(PyArrayObject *self, PyObject *args)\n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter, \n\t\t\t &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\n\nstatic char doc_round[] = \"a.round(decimals=0)\";\n\nstatic PyObject *\narray_round(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint decimals = 0;\n\tstatic char *kwlist[] = {\"decimals\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|i\", kwlist,\n\t\t\t\t\t &decimals)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Round(self, decimals));\n}\n\n\nstatic char doc_setflags[] = \"a.setflags(write=None, align=None, uic=None)\";\n\nstatic int _IsAligned(PyArrayObject *);\nstatic Bool _IsWriteable(PyArrayObject *);\n\nstatic PyObject *\narray_setflags(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"write\", \"align\", \"uic\", NULL};\n\tPyObject *write=Py_None;\n\tPyObject *align=Py_None;\n\tPyObject *uic=Py_None;\n\tint flagback = self->flags;\n\t\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOO\", kwlist,\n\t\t\t\t\t &write, &align, &uic))\n\t\treturn NULL;\n\n\tif (align != Py_None) {\n\t\tif (PyObject_Not(align)) self->flags &= ~ALIGNED;\n\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot set aligned flag of mis-\"\\\n\t\t\t\t\t\"aligned array to True\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif (uic != Py_None) {\n if (PyObject_IsTrue(uic)) {\n\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return NULL;\n }\n else {\n self->flags &= ~UPDATEIFCOPY;\n Py_XDECREF(self->base);\n self->base = NULL;\n }\n }\n \n if (write != Py_None) {\n if (PyObject_IsTrue(write)) \n\t\t\tif (_IsWriteable(self)) {\n\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tself->flags = flagback;\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"cannot set WRITEABLE \"\t\\\n\t\t\t\t\t\t\"flag to True of this \"\t\\\n\t\t\t\t\t\t\"array\");\t\t\\\n\t\t\t\treturn NULL;\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n \n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_newbyteorder[] = \"a.newbyteorder() is equivalent\\n\" \\\n\t\" to a.view(a.dtype.newbytorder())\\n\";\n\nstatic PyObject *\narray_newbyteorder(PyArrayObject *self, PyObject *args) \n{\n\tchar endian = PyArray_SWAP;\n\tPyArray_Descr *new;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\tnew = PyArray_DescrNewByteorder(self->descr, endian);\n\tif (!new) return NULL;\n\treturn PyArray_View(self, new, NULL);\n\n}\n\nstatic PyMethodDef array_methods[] = {\n {\"tolist\",\t (PyCFunction)array_tolist,\t1, doc_tolist},\n {\"item\", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},\n\t{\"tofile\", (PyCFunction)array_tofile, \n METH_VARARGS | METH_KEYWORDS, doc_tofile},\n {\"tostring\", (PyCFunction)array_tostring, METH_VARARGS, doc_tostring},\n {\"byteswap\", (PyCFunction)array_byteswap,\t1, doc_byteswap},\n {\"astype\", (PyCFunction)array_cast, 1, doc_cast},\n\t{\"getfield\", (PyCFunction)array_getfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_getfield},\n\t{\"setfield\", (PyCFunction)array_setfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_setfield},\n {\"copy\", (PyCFunction)array_copy, 1, doc_copy}, \n {\"resize\", (PyCFunction)array_resize, \n\t METH_VARARGS | METH_KEYWORDS, doc_resize}, \n\n\t/* for subtypes */\n\t{\"__array__\", (PyCFunction)array_getarray, 1, doc_array_getarray},\n\t{\"__array_wrap__\", (PyCFunction)array_wraparray, 1, doc_wraparray},\n\t/* default version so it is found... -- only used for subclasses */\n\t{\"__array_finalize__\", (PyCFunction)array_finalize, 1, NULL},\n\t\n\t\n\t/* for the copy module */\n {\"__copy__\", (PyCFunction)array_copy, 1, doc_copy},\t \n {\"__deepcopy__\", (PyCFunction)array_deepcopy, 1, doc_deepcopy}, \n\t\n /* for Pickling */\n {\"__reduce__\", (PyCFunction) array_reduce, 1, doc_reduce},\t\n\t{\"__setstate__\", (PyCFunction) array_setstate, 1, doc_setstate},\n\t{\"dumps\", (PyCFunction) array_dumps, 1, doc_dumps},\n\t{\"dump\", (PyCFunction) array_dump, 1, doc_dump},\n\n\t/* Extended methods added 2005 */\n\t{\"fill\", (PyCFunction)array_fill,\n\t METH_VARARGS, doc_fill},\n\t{\"transpose\",\t(PyCFunction)array_transpose, \n\t METH_VARARGS, doc_transpose},\n\t{\"take\",\t(PyCFunction)array_take, \n\t METH_VARARGS|METH_KEYWORDS, doc_take},\n\t{\"put\",\t(PyCFunction)array_put, \n\t METH_VARARGS|METH_KEYWORDS, doc_put},\n\t{\"putmask\",\t(PyCFunction)array_putmask, \n\t METH_VARARGS|METH_KEYWORDS, doc_putmask},\n\t{\"repeat\",\t(PyCFunction)array_repeat, \n\t METH_VARARGS|METH_KEYWORDS, doc_repeat},\n\t{\"choose\",\t(PyCFunction)array_choose, \n\t METH_VARARGS, doc_choose},\t\n\t{\"sort\",\t(PyCFunction)array_sort, \n\t METH_VARARGS|METH_KEYWORDS, doc_sort},\n\t{\"argsort\",\t(PyCFunction)array_argsort, \n\t METH_VARARGS|METH_KEYWORDS, doc_argsort},\n\t{\"searchsorted\", (PyCFunction)array_searchsorted, \n\t METH_VARARGS, doc_searchsorted},\t\n\t{\"argmax\",\t(PyCFunction)array_argmax, \n\t METH_VARARGS|METH_KEYWORDS, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS|METH_KEYWORDS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS|METH_KEYWORDS, doc_reshape},\n\t{\"squeeze\",\t(PyCFunction)array_squeeze,\n\t METH_VARARGS, doc_squeeze},\n\t{\"view\", (PyCFunction)array_view, \n\t METH_VARARGS, doc_view},\n\t{\"swapaxes\", (PyCFunction)array_swapaxes,\n\t METH_VARARGS, doc_swapaxes},\n\t{\"max\", (PyCFunction)array_max,\n\t METH_VARARGS|METH_KEYWORDS, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS|METH_KEYWORDS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS|METH_KEYWORDS, doc_ptp},\n\t{\"mean\", (PyCFunction)array_mean,\n\t METH_VARARGS|METH_KEYWORDS, doc_mean},\n\t{\"trace\", (PyCFunction)array_trace,\n\t METH_VARARGS|METH_KEYWORDS, doc_trace},\n\t{\"diagonal\", (PyCFunction)array_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, doc_diagonal},\n\t{\"clip\", (PyCFunction)array_clip,\n\t METH_VARARGS|METH_KEYWORDS, doc_clip},\n\t{\"conj\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conj},\n\t{\"conjugate\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conjugate},\n\t{\"nonzero\", (PyCFunction)array_nonzero,\n\t METH_VARARGS, doc_nonzero},\n\t{\"std\", (PyCFunction)array_stddev,\n\t METH_VARARGS|METH_KEYWORDS, doc_stddev},\n\t{\"var\", (PyCFunction)array_variance,\n\t METH_VARARGS|METH_KEYWORDS, doc_variance},\n\t{\"sum\", (PyCFunction)array_sum,\n\t METH_VARARGS|METH_KEYWORDS, doc_sum},\n\t{\"cumsum\", (PyCFunction)array_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumsum},\n\t{\"prod\", (PyCFunction)array_prod,\n\t METH_VARARGS|METH_KEYWORDS, doc_prod},\n\t{\"cumprod\", (PyCFunction)array_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumprod},\n\t{\"all\", (PyCFunction)array_all,\n\t METH_VARARGS|METH_KEYWORDS, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS|METH_KEYWORDS, doc_any},\n\t{\"compress\", (PyCFunction)array_compress,\n\t METH_VARARGS|METH_KEYWORDS, doc_compress},\n\t{\"flatten\", (PyCFunction)array_flatten,\n\t METH_VARARGS, doc_flatten},\n\t{\"ravel\", (PyCFunction)array_ravel,\n\t METH_VARARGS, doc_ravel},\n\t{\"round\", (PyCFunction)array_round,\n\t METH_VARARGS|METH_KEYWORDS, doc_round},\n\t{\"setflags\", (PyCFunction)array_setflags,\n\t METH_VARARGS|METH_KEYWORDS, doc_setflags},\n\t{\"newbyteorder\", (PyCFunction)array_newbyteorder,\n\t METH_VARARGS, doc_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n#undef _ARET\n\n\n", + "source_code_before": "\n/* Should only be used if x is known to be an nd-array */\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_take[] = \"a.take(indices, axis=None). Selects the elements \"\\\n\t\"in indices from array a along the given axis.\";\n\nstatic PyObject *\narray_take(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint dimension=MAX_DIMS;\n\tPyObject *indices;\n\tstatic char *kwlist[] = {\"indices\", \"axis\", NULL};\n\t\n\tdimension=0;\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &indices, PyArray_AxisConverter,\n\t\t\t\t\t &dimension))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Take(self, indices, dimension));\n}\n\nstatic char doc_fill[] = \"a.fill(value) places the scalar value at every \"\\\n\t\"position in the array.\";\n\nstatic PyObject *\narray_fill(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *obj;\n\tif (!PyArg_ParseTuple(args, \"O\", &obj))\n\t\treturn NULL;\n\tif (PyArray_FillWithScalar(self, obj) < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_put[] = \"a.put(values, indices) sets a.flat[n] = v[n] \"\\\n\t\"for each n in indices. v can be scalar or shorter than indices, \"\\\n\t\"will repeat.\";\n\nstatic PyObject *\narray_put(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *indices, *values;\n\tstatic char *kwlist[] = {\"values\", \"indices\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &indices))\n\t\treturn NULL;\n\treturn PyArray_Put(self, values, indices);\n}\n\nstatic char doc_putmask[] = \"a.putmask(values, mask) sets a.flat[n] = v[n] \"\\\n\t\"for each n where mask.flat[n] is TRUE. v can be scalar.\";\n\nstatic PyObject *\narray_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *mask, *values;\n\n\tstatic char *kwlist[] = {\"values\", \"mask\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &mask))\n\t\treturn NULL;\n\treturn PyArray_PutMask(self, values, mask);\n}\n\nstatic char doc_reshape[] = \\\n\t\"self.reshape(d1, d2, ..., dn, order='C') \\n\"\t\n\t\"Return a new array from this one. \\n\"\t\t\t\t\n\t\"\\n The new array must have the same number of elements as self. \" \n\t\"Also\\n always returns a view or raises a ValueError if that is \\n\"\n\t\"impossible.\";\n\nstatic PyObject *\narray_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tPyArray_ORDER order=PyArray_CORDER;\n\tint n;\n\t\n\tif (kwds != NULL) {\n\t\tPyObject *ref;\n\t\tref = PyDict_GetItemString(kwds, \"order\");\n\t\tif (ref == NULL || \\\n\t\t (PyArray_OrderConverter(ref, &order) == PY_FAIL))\n\t\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\tgoto fail;\n\t\t}\n\t}\n\tret = PyArray_Newshape(self, &newshape, order);\n\tPyDimMem_FREE(newshape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(newshape.ptr);\n\treturn NULL;\n}\n\nstatic char doc_squeeze[] = \"m.squeeze() eliminate all length-1 dimensions\";\n\nstatic PyObject *\narray_squeeze(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return _ARET(PyArray_Squeeze(self));\n}\n\nstatic char doc_view[] = \"a.view() return a new view of array with same data. type can be either a new sub-type object or a data-descriptor object\";\n\nstatic PyObject *\narray_view(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *otype=NULL;\n PyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTuple(args, \"|O\", &otype)) return NULL;\n\n\tif (otype) {\n\t\tif (PyType_Check(otype) &&\t\t\t\\\n\t\t PyType_IsSubtype((PyTypeObject *)otype, \n\t\t\t\t &PyArray_Type)) {\n\t\t\treturn PyArray_View(self, NULL, \n (PyTypeObject *)otype);\n }\n\t\telse {\n\t\t\tif (PyArray_DescrConverter(otype, &type) == PY_FAIL) \n\t\t\t\treturn NULL;\n\t\t}\n\t}\n\treturn PyArray_View(self, type, NULL);\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn _ARET(PyArray_ArgMax(self, axis));\n}\n\nstatic char doc_argmin[] = \"a.argmin(axis=None)\";\n\nstatic PyObject *\narray_argmin(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn _ARET(PyArray_ArgMin(self, axis));\n}\n\nstatic char doc_max[] = \"a.max(axis=None)\";\n\nstatic PyObject *\narray_max(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Max(self, axis);\n}\n\nstatic char doc_ptp[] = \"a.ptp(axis=None) a.max(axis)-a.min(axis)\";\n\nstatic PyObject *\narray_ptp(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\t\n\treturn PyArray_Ptp(self, axis);\n}\n\n\nstatic char doc_min[] = \"a.min(axis=None)\";\n\nstatic PyObject *\narray_min(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Min(self, axis);\n}\n\nstatic char doc_swapaxes[] = \"a.swapaxes(axis1, axis2) returns new view with axes swapped.\";\n\nstatic PyObject *\narray_swapaxes(PyArrayObject *self, PyObject *args)\n{\n\tint axis1, axis2;\n\n\tif (!PyArg_ParseTuple(args, \"ii\", &axis1, &axis2)) return NULL;\n\n\treturn PyArray_SwapAxes(self, axis1, axis2);\n}\n\nstatic char doc_getfield[] = \"m.getfield(dtype, offset) returns a field \"\\\n\t\" of the given array as a certain type. A field is a view of \"\\\n\t\" the array's data with each itemsize determined by the given type\"\\\n\t\" and the offset into the current array.\";\n\n/* steals typed reference */\n/*OBJECT_API\n Get a subset of bytes from each element of the array\n*/\nstatic PyObject *\nPyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int offset)\n{\n\tPyObject *ret=NULL;\n\n\tif (offset < 0 || (offset + typed->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-typed->elsize, offset);\n\t\tPy_DECREF(typed);\n\t\treturn NULL;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t typed,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, \n\t\t\t\t self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self; \n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\treturn ret;\n}\n\nstatic PyObject *\narray_getfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tstatic char *kwlist[] = {\"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|i\", kwlist,\n\t\t\t\t\t PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\t\n\treturn _ARET(PyArray_GetField(self, dtype, offset));\n}\n\n\nstatic char doc_setfield[] = \"m.setfield(value, dtype, offset) places val \"\\\n\t\"into field of the given array defined by the data type and offset.\";\n\n/*OBJECT_API\n Set a subset of bytes from each element of the array\n*/\nstatic int\nPyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,\n\t\t int offset, PyObject *val)\n{\n\tPyObject *ret=NULL;\n\tint retval = 0;\n \n\tif (offset < 0 || (offset + dtype->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-dtype->elsize, offset);\n\t\tPy_DECREF(dtype);\n\t\treturn -1;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t dtype, self->nd, self->dimensions,\n\t\t\t\t self->strides, self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return -1;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self;\n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\t\n\tretval = PyArray_CopyObject((PyArrayObject *)ret, val);\n\tPy_DECREF(ret);\n\treturn retval;\n}\n\nstatic PyObject *\narray_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tPyObject *value;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value, PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\n\tif (PyArray_SetField(self, dtype, offset, value) < 0)\n\t\treturn NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* This doesn't change the descriptor just the actual data...\n */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Byteswap(PyArrayObject *self, Bool inplace)\n{\n PyArrayObject *ret;\n\tintp size;\n\tPyArray_CopySwapNFunc *copyswapn;\n\tPyArray_CopySwapFunc *copyswap;\n\tPyArrayIterObject *it;\n\n\tif (inplace) {\n\t\tcopyswapn = self->descr->f->copyswapn;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\t\tif (PyArray_ISONESEGMENT(self)) {\n\t\t\tcopyswapn(self->data, NULL, size, 1, \n\t\t\t\t self->descr->elsize);\n\t\t}\n\t\telse { /* Use iterator */\n\t\t\t\n\t\t\tit = (PyArrayIterObject *)\\\n\t\t\t\tPyArray_IterNew((PyObject *)self);\n\t\t\tcopyswap = self->descr->f->copyswap;\n\t\t\twhile (it->index < it->size) {\n\t\t\t\tcopyswap(it->dataptr, NULL, 1, \n\t\t\t\t\t self->descr->elsize);\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t}\n\t\t\tPy_DECREF(it);\n\t\t}\n\t\t\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tif ((ret = (PyArrayObject *)PyArray_NewCopy(self,-1)) == NULL) \n\t\t\treturn NULL;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\n\t\t/* now ret has the same dtypedescr as self (including\n\t\t byteorder)\n\t\t*/\n\n\t\tret->descr->f->copyswapn(ret->data, NULL, size, 1, \n\t\t\t\t\t ret->descr->elsize);\n\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic char doc_byteswap[] = \"m.byteswap(False) Swap the bytes in\"\\\n\t\" the array. Return the byteswapped array. If the first argument\"\\\n\t\" is TRUE, byteswap in-place and return a reference to self.\";\n\nstatic PyObject *\narray_byteswap(PyArrayObject *self, PyObject *args) \n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\treturn PyArray_Byteswap(self, inplace);\n}\n\nstatic char doc_tolist[] = \"m.tolist().\t Copy the data portion of the array\"\\\n\t\" to a hierarchical python list and return that list.\";\n\nstatic PyObject *\narray_tolist(PyArrayObject *self, PyObject *args) \n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n if (self->nd <= 0) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can't convert a 0-d array to a list\");\n return NULL;\n }\n\t\n return PyArray_ToList(self);\n}\n\nstatic char doc_tostring[] = \"m.tostring() Construct a Python string \"\\\n \"containing the raw bytes in the array\";\n\nstatic PyObject *\narray_tostring(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return PyArray_ToString(self);\n}\n\nstatic char doc_tofile[] = \"m.tofile(fid, sep=\"\") write the data to a file.\";\n\nstatic PyObject *\narray_tofile(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tint ret;\n PyObject *file;\n\tFILE *fd;\n char *sep=\"\";\n\tchar *format=\"\";\n\tchar *mode=\"\";\n\tstatic char *kwlist[] = {\"file\", \"sep\", \"format\", NULL};\n \n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ss\", kwlist, \n &file, &sep, &format)) return NULL;\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"wb\";\n\t\telse mode=\"w\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfd = PyFile_AsFile(file);\n\tif (fd == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"first argument must be a \" \\\n\t\t\t\t\"string or open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_ToFile(self, fd, sep, format);\n\tPy_DECREF(file);\n\tif (ret < 0) return NULL;\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_toscalar[] = \"m.item(). Copy the first data point of \"\\\n\t\"the array to a standard Python scalar and return it.\";\n\nstatic PyObject *\narray_toscalar(PyArrayObject *self, PyObject *args) {\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tif (self->nd == 0 || PyArray_SIZE(self) == 1) \n\t\treturn self->descr->f->getitem(self->data, self);\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \"can only convert an\"\t\\\n\t\t\t\t\" array of size 1 to Python scalar.\");\n\t\treturn NULL;\n\t}\n}\n\nstatic char doc_cast[] = \"m.astype(t).\tCast array m to type t.\t \\n\\n\"\\\n\t\"t can be either a string representing a typecode, or a python type\"\\\n\t\" object of type int, float, or complex.\";\n\nstatic PyObject *\narray_cast(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *descr=NULL;\n\tPyObject *obj;\n\t\n if (!PyArg_ParseTuple(args, \"O&\", PyArray_DescrConverter,\n\t\t\t &descr)) return NULL;\n\t\n\tif (descr == self->descr) {\n\t\tobj = _ARET(PyArray_NewCopy(self,0));\n\t\tPy_XDECREF(descr);\n\t\treturn obj;\n\t}\n\treturn _ARET(PyArray_CastToType(self, descr, 0));\n}\t \n\n/* default sub-type implementation */\n\nstatic char doc_wraparray[] = \"m.__array_wrap__(obj) returns an object of \"\\\n\t\"type m from the ndarray object obj\";\n\nstatic PyObject *\narray_wraparray(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *arr;\n\tPyObject *ret;\n\t\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\t\n\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t PyArray_NDIM(arr),\n\t\t\t\t PyArray_DIMS(arr), \n\t\t\t\t PyArray_STRIDES(arr), PyArray_DATA(arr),\n\t\t\t\t PyArray_FLAGS(arr), (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(arr);\n\tPyArray_BASE(ret) = arr;\n\treturn ret;\n}\n\n/* NO-OP --- just so all subclasses will have one by default. */\nstatic PyObject *\narray_finalize(PyArrayObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic char doc_array_getarray[] = \"m.__array__(|dtype) just returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.\";\n\nstatic PyObject *\narray_getarray(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *newtype=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_DescrConverter,\n\t\t\t &newtype)) return NULL;\n\t\n\t/* convert to PyArray_Type */\n\tif (!PyArray_CheckExact(self)) {\n\t\tPyObject *new;\n\t\tPyTypeObject *subtype = &PyArray_Type;\n\n\t\tif (!PyType_IsSubtype(self->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyArray_Type;\n\t\t}\n\t\t\n\t\tPy_INCREF(PyArray_DESCR(self));\n\t\tnew = PyArray_NewFromDescr(subtype, \n\t\t\t\t\t PyArray_DESCR(self),\n\t\t\t\t\t PyArray_NDIM(self),\n\t\t\t\t\t PyArray_DIMS(self), \n\t\t\t\t\t PyArray_STRIDES(self), \n\t\t\t\t\t PyArray_DATA(self),\n\t\t\t\t\t PyArray_FLAGS(self), NULL);\n\t\tif (new == NULL) return NULL;\n\t\tPy_INCREF(self);\n\t\tPyArray_BASE(new) = (PyObject *)self;\n\t\tself = (PyArrayObject *)new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t}\n\t\t\n\tif ((newtype == NULL) || \\\n\t PyArray_EquivTypes(self->descr, newtype)) {\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tret = PyArray_CastToType(self, newtype, 0);\n\t\tPy_DECREF(self);\n\t\treturn ret;\n\t}\n}\n\nstatic char doc_copy[] = \"m.copy(|fortran). Return a copy of the array.\\n\"\\\n\t\"If fortran is false then the result is contiguous (default). \\n\"\\\n\t\"If fortran is true then the result has fortran data order. \\n\"\\\n\t\"If fortran is None then the result has fortran data order only if m\\n\"\n\t\" is already in fortran order.\";\n\nstatic PyObject *\narray_copy(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n if (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter,\n\t\t\t &fortran)) return NULL;\n\t\n return PyArray_NewCopy(self, fortran);\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape, refcheck=True, fortran=False). \"\\\n\t\"Change size and shape of self inplace.\\n\"\\\n\t\"\\n Array must own its own memory and not be referenced by other \" \\\n\t\"arrays\\n Returns None.\";\n\nstatic PyObject *\narray_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\n\tint refcheck = 1;\n\tPyArray_ORDER fortran=PyArray_ANYORDER;\n\t\n\tif (kwds != NULL) {\n\t\tPyObject *ref;\n\t\tref = PyDict_GetItemString(kwds, \"refcheck\");\n\t\tif (ref) {\n\t\t\trefcheck = PyInt_AsLong(ref);\n\t\t\tif (refcheck==-1 && PyErr_Occurred()) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\tref = PyDict_GetItemString(kwds, \"fortran\");\n\t\tif (ref != NULL || \n\t\t (PyArray_OrderConverter(ref, &fortran) == PY_FAIL))\n\t\t\treturn NULL;\n\t}\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\treturn NULL;\t\t\t\n\t\t}\n\t}\t\n\tret = PyArray_Resize(self, &newshape, refcheck, fortran);\n PyDimMem_FREE(newshape.ptr);\n if (ret == NULL) return NULL;\n\tPy_DECREF(ret);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_repeat[] = \"a.repeat(repeats=, axis=None)\\n\"\\\n\t\"\\n\"\\\n\t\" Copy elements of a, repeats times. The repeats argument must\\n\"\\\n\t\" be a sequence of length a.shape[axis] or a scalar.\";\n\nstatic PyObject *\narray_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {\n\tPyObject *repeats;\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"repeats\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &repeats, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Repeat(self, repeats, axis));\n}\n\nstatic char doc_choose[] = \"a.choose(b0, b1, ..., bn)\\n\"\\\n\t\"\\n\"\\\n\t\"Return an array with elements chosen from 'a' at the positions\\n\"\\\n \"of the given arrays b_i. The array 'a' should be an integer array\\n\"\\\n \"with entries from 0 to n+1, and the b_i arrays should have the same\\n\"\\\n \"shape as 'a'.\";\n\nstatic PyObject *\narray_choose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *choices;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O\", &choices))\n\t\t\treturn NULL;\n\t}\n else {\n\t\tchoices = args;\n\t}\n\t\n\treturn _ARET(PyArray_Choose(self, choices));\n}\n\nstatic char doc_sort[] = \"a.sort(axis=-1,kind='quicksort') sorts in place along axis. Return is None and kind can be 'quicksort', 'mergesort', or 'heapsort'\";\n\nstatic PyObject *\narray_sort(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=-1;\n\tint val;\n\tPyArray_SORTKIND which=PyArray_QUICKSORT;\n\tstatic char *kwlist[] = {\"axis\", \"kind\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iO&\", kwlist, &axis,\n\t\t\t\t\t PyArray_SortkindConverter, &which))\n\t\treturn NULL;\n\t\n\tval = PyArray_Sort(self, axis, which);\n\tif (val < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_argsort[] = \"a.argsort(axis=-1,kind='quicksort')\\n\"\\\n\t\" Return the indexes into a that would sort it along the\"\\\n\t\" given axis; kind can be 'quicksort', 'mergesort', or 'heapsort'\";\n\nstatic PyObject *\narray_argsort(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=-1;\n\tPyArray_SORTKIND which=PyArray_QUICKSORT;\n\tstatic char *kwlist[] = {\"axis\", \"kind\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iO&\", kwlist, &axis,\n\t\t\t\t\t PyArray_SortkindConverter, &which))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_ArgSort(self, axis, which));\n}\n\nstatic char doc_searchsorted[] = \"a.searchsorted(v)\\n\"\\\n\t\" Assuming that a is a 1-D array, in ascending order and\\n\"\\\n\t\" represents bin boundaries, then a.searchsorted(values) gives an\\n\"\\\n\t\" array of bin numbers, giving the bin into which each value would\\n\"\\\n\t\" be placed. This method is helpful for histograming. \\n\"\\\n\t\" Note: No warning is given if the boundaries, in a, are not \\n\"\\\n\t\" in ascending order.\";\n\nstatic PyObject *\narray_searchsorted(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *values;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &values)) return NULL;\n\t\n\treturn _ARET(PyArray_SearchSorted(self, values));\n}\n\nstatic char doc_deepcopy[] = \"Used if copy.deepcopy is called on an array.\";\n\nstatic PyObject *\narray_deepcopy(PyArrayObject *self, PyObject *args) \n{\n PyObject* visit;\n PyObject **optr;\n PyArrayIterObject *it;\n PyObject *copy, *ret, *deepcopy, *temp, *res;\n\n if (!PyArg_ParseTuple(args, \"O\", &visit)) return NULL;\n ret = PyArray_Copy(self);\n if (PyArray_ISOBJECT(self)) {\n copy = PyImport_ImportModule(\"copy\");\n if (copy == NULL) return NULL;\n deepcopy = PyObject_GetAttrString(copy, \"deepcopy\");\n Py_DECREF(copy);\n if (deepcopy == NULL) return NULL;\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it == NULL) {Py_DECREF(deepcopy); return NULL;}\n optr = (PyObject **)PyArray_DATA(ret);\n while(it->index < it->size) {\n temp = *((PyObject **)it->dataptr);\n Py_INCREF(temp);\n /* call deepcopy on this argument */\n res = PyObject_CallFunctionObjArgs(deepcopy, \n temp, visit, NULL);\n Py_DECREF(temp);\n Py_DECREF(*optr);\n *optr++ = res;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(deepcopy);\n Py_DECREF(it);\n }\n return _ARET(ret);\n}\n\n/* Convert Object Array to flat list and pickle the flat list string */\nstatic PyObject *\n_getobject_pkl(PyArrayObject *self)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tPyObject *list;\n\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return NULL;\n\tlist = PyList_New(iter->size);\n\tif (list == NULL) {Py_DECREF(iter); return NULL;}\n\twhile (iter->index < iter->size) {\n\t\ttheobject = *((PyObject **)iter->dataptr);\n\t\tPy_INCREF(theobject);\n\t\tPyList_SET_ITEM(list, (int) iter->index, theobject);\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_DECREF(iter);\n\treturn list;\n}\n\nstatic int\n_setobject_pkl(PyArrayObject *self, PyObject *list)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tint size;\n\n\tsize = self->descr->elsize;\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return -1;\n\twhile(iter->index < iter->size) {\n\t\ttheobject = PyList_GET_ITEM(list, (int) iter->index);\n\t\tPy_INCREF(theobject);\n\t\t*((PyObject **)iter->dataptr) = theobject;\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_XDECREF(iter);\n\treturn 0;\n}\n\nstatic char doc_reduce[] = \"a.__reduce__() for pickling.\";\n\nstatic PyObject *\narray_reduce(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *state=NULL, *obj=NULL, *mod=NULL;\n\tPyObject *mybool, *thestr=NULL;\n\tPyArray_Descr *descr;\n\n\t/* Return a tuple of (callable object, arguments, object's state) */\n\t/* We will put everything in the object's state, so that on UnPickle\n\t it can use the string object as memory without a copy */\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"numpy.core._internal\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"_reconstruct\");\n\tPy_DECREF(mod);\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t Py_BuildValue(\"ONN\",\n\t\t\t\t (PyObject *)self->ob_type,\n\t\t\t\t Py_BuildValue(\"(N)\",\n\t\t\t\t\t\t PyInt_FromLong(0)),\n\t\t\t\t PyObject_GetAttrString((PyObject *)(self->descr),\n\t\t\t\t\t\t\t \"char\")));\n\t\n\t/* Now fill in object's state. This is a tuple with \n\t 4 arguments\n\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object (with correct bytorder set)\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list for Object arrays)\n\n\t Notice because Python does not describe a mechanism to write \n\t raw data to the pickle, this performs a copy to a string first\n\t*/\n\n\tstate = PyTuple_New(4);\n\tif (state == NULL) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 0, PyObject_GetAttrString((PyObject *)self, \n\t\t\t\t\t\t\t \"shape\"));\n\tdescr = self->descr;\n\tPy_INCREF(descr);\n\tPyTuple_SET_ITEM(state, 1, (PyObject *)descr);\n\tmybool = (PyArray_ISFORTRAN(self) ? Py_True : Py_False);\n\tPy_INCREF(mybool);\n\tPyTuple_SET_ITEM(state, 2, mybool);\n\tif (PyArray_ISOBJECT(self)) {\n\t\tthestr = _getobject_pkl(self);\n\t}\n\telse {\n thestr = PyArray_ToString(self);\n\t}\n\tif (thestr == NULL) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(state);\n\t\treturn NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 3, thestr);\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\nstatic char doc_setstate[] = \"a.__setstate__(tuple) for unpickling.\";\n\n/*\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list if Object array) \n*/\n\nstatic intp _array_fill_strides(intp *, intp *, int, intp, int, int *);\n\nstatic int _IsAligned(PyArrayObject *); \n\nstatic PyArray_Descr * _array_typedescr_fromstr(char *);\n\nstatic PyObject *\narray_setstate(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *shape;\n\tPyArray_Descr *typecode;\n\tint fortran;\n\tPyObject *rawdata;\n\tchar *datastr;\n\tint len;\n\tintp dimensions[MAX_DIMS];\n\tint nd;\n\t\n\t/* This will free any memory associated with a and\n\t use the string in setstate as the (writeable) memory.\n\t*/\n\tif (!PyArg_ParseTuple(args, \"(O!O!iO)\", &PyTuple_Type,\n\t\t\t &shape, &PyArrayDescr_Type, &typecode, \n\t\t\t &fortran, &rawdata))\n\t\treturn NULL;\n\n\tPy_XDECREF(self->descr);\n\tself->descr = typecode;\n\tPy_INCREF(typecode);\n\tnd = PyArray_IntpFromSequence(shape, dimensions, MAX_DIMS);\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (!PyList_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"object pickle not returning list\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tif (!PyString_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"pickle not returning string\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (PyString_AsStringAndSize(rawdata, &datastr, &len))\n\t\t\treturn NULL;\n\n\t\tif ((len != (self->descr->elsize *\t\t\t\\\n\t\t\t (int) PyArray_MultiplyList(dimensions, nd)))) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size does not\"\t\\\n\t\t\t\t\t\" match array size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n if ((self->flags & OWN_DATA)) {\n\t\tif (self->data != NULL)\n\t\t\tPyDataMem_FREE(self->data);\n\t\tself->flags &= ~OWN_DATA;\n }\n\tPy_XDECREF(self->base);\n\n\tself->flags &= ~UPDATEIFCOPY;\n\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t\tself->dimensions = NULL;\n\t}\n\n\tself->flags = DEFAULT_FLAGS;\n\n\tself->nd = nd;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(nd * 2);\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dimensions, sizeof(intp)*nd);\n\t\t(void) _array_fill_strides(self->strides, dimensions, nd,\n\t\t\t\t\t self->descr->elsize, \n (fortran ? FORTRAN : CONTIGUOUS),\n\t\t\t\t\t &(self->flags));\n\t}\n\n\tif (typecode->type_num != PyArray_OBJECT) {\n\t\tself->data = datastr;\n\t\tif (!_IsAligned(self)) {\n\t\t\tintp num = PyArray_NBYTES(self);\n\t\t\tself->data = PyDataMem_NEW(num);\n\t\t\tif (self->data == NULL) {\n\t\t\t\tself->nd = 0;\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemcpy(self->data, datastr, num);\n\t\t\tself->flags |= OWN_DATA;\n\t\t\tself->base = NULL;\n\t\t}\n\t\telse {\n\t\t\tself->base = rawdata;\n\t\t\tPy_INCREF(self->base);\n\t\t}\n\t}\n\telse {\n\t\tself->data = PyDataMem_NEW(PyArray_NBYTES(self));\n\t\tif (self->data == NULL) { \n\t\t\tself->nd = 0;\n\t\t\tself->data = PyDataMem_NEW(self->descr->elsize);\n\t\t\tif (self->dimensions) PyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\t\tself->base = NULL;\n\t\tif (_setobject_pkl(self, rawdata) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\t\n}\n\n/*OBJECT_API*/\nstatic int\nPyArray_Dump(PyObject *self, PyObject *file, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return -1;\n\n\tif PyString_Check(file) {\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), \"wb\");\n\t\tif (file==NULL) return -1;\n\t}\n\telse Py_INCREF(file);\n\tret = PyObject_CallMethod(cpick, \"dump\", \"OOi\", self, \n\t\t\t\t file, protocol);\n\tPy_XDECREF(ret);\n\tPy_DECREF(file);\n\tPy_DECREF(cpick);\n\tif (PyErr_Occurred()) return -1;\n\treturn 0;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Dumps(PyObject *self, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return NULL;\n\tret = PyObject_CallMethod(cpick, \"dumps\", \"Oi\", self, protocol);\n\tPy_DECREF(cpick);\n\treturn ret;\n}\n\n\nstatic char doc_dump[] = \"m.dump(file)\";\n\nstatic PyObject *\narray_dump(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump((PyObject *)self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_dumps[] = \"m.dumps()\";\n\nstatic PyObject *\narray_dumps(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps((PyObject *)self, 2);\n}\n\n\nstatic char doc_transpose[] = \"m.transpose()\";\n\nstatic PyObject *\narray_transpose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *shape=Py_None;\n\tint n;\n\tPyArray_Dims permute;\n\tPyObject *ret;\n\n\tn = PyTuple_Size(args);\n\tif (n > 1) shape = args;\n\telse if (n == 1) shape = PyTuple_GET_ITEM(args, 0);\n\t\n\tif (shape == Py_None)\n\t\tret = PyArray_Transpose(self, NULL);\n\telse {\n\t\tif (!PyArray_IntpConverter(shape, &permute)) return NULL;\n\t\tret = PyArray_Transpose(self, &permute);\n\t\tPyDimMem_FREE(permute.ptr);\n\t}\n\t\n\treturn _ARET(ret);\n}\n\nstatic char doc_mean[] = \"a.mean(axis=None, dtype=None)\\n\\n\"\\\n \"Average the array over the given axis. If the axis is None, average\\n\"\\\n \"over all dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"If an integer axis is given, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / len(a)\\n\"\\\n \"\\n\"\\\n \"If axis is None, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / product(a.shape)\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for intermediate\\n\"\\\n \"calculations in the sum.\";\n\n#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)\n\nstatic PyObject *\narray_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist,\n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\n\treturn PyArray_Mean(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_sum[] = \"a.sum(axis=None, dtype=None)\\n\\n\"\\\n \"Sum the array over the given axis. If the axis is None, sum over all\\n\"\\\n \"dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for the returned value\\n\"\\\n \"and intermediate calculations. The default is to upcast (promote)\\n\"\\\n \"smaller integer types to the platform-dependent int. For example, on\\n\"\\\n \"32-bit platforms:\\n\"\\\n \"\\n\"\\\n \" a.dtype default sum() dtype\\n\"\\\n \" ---------------------------------------------------\\n\"\\\n \" bool, int8, int16, int32 int32\\n\"\\\n \"\\n\"\\\n \"Examples:\\n\"\\\n \"\\n\"\\\n \">>> array([0.5, 1.5]).sum()\\n\"\\\n \"2.0\\n\"\\\n \">>> array([0.5, 1.5]).sum(dtype=int32)\\n\"\\\n \"1\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=0)\\n\"\\\n \"array([0, 6])\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=1)\\n\"\\\n \"array([1, 5])\";\n\nstatic PyObject *\narray_sum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Sum(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumsum[] = \"a.cumsum(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_prod[] = \"a.prod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_prod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Prod(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumprod[] = \"a.cumprod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_any[] = \"a.any(axis=None)\";\n\nstatic PyObject *\narray_any(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\t\n\treturn PyArray_Any(self, axis);\n}\n\nstatic char doc_all[] = \"a.all(axis=None)\";\n\nstatic PyObject *\narray_all(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter,\n\t\t\t\t\t &axis))\n\t\treturn NULL;\t\n\n\treturn PyArray_All(self, axis);\n}\n\nstatic char doc_stddev[] = \"a.std(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 0);\n}\n\nstatic char doc_variance[] = \"a.var(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 1);\n}\n\nstatic char doc_compress[] = \"a.compress(condition=, axis=None)\";\n\nstatic PyObject *\narray_compress(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyObject *condition;\t\n\tstatic char *kwlist[] = {\"condition\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &condition, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\n\treturn _ARET(PyArray_Compress(self, condition, axis));\n}\n\nstatic char doc_nonzero[] = \"a.nonzero() return a tuple of indices referencing \"\\\n\t\"the elements of a that are nonzero.\";\n\nstatic PyObject *\narray_nonzero(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\treturn _ARET(PyArray_Nonzero(self));\n}\n\n\nstatic char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, dtype=None)\\n\"\\\n\t\"return the sum along the offset diagonal of the arrays indicated\\n\" \\\n\t\"axis1 and axis2.\";\n\nstatic PyObject *\narray_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iiiO&\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2,\n\t\t\t\t\t PyArray_DescrConverter2, &dtype))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Trace(self, offset, axis1, axis2, \n\t\t\t\t _CHKTYPENUM(dtype)));\n}\n\n#undef _CHKTYPENUM\n\n\nstatic char doc_clip[] = \"a.clip(min=, max=)\";\n\nstatic PyObject *\narray_clip(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *min, *max;\n\tstatic char *kwlist[] = {\"min\", \"max\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &min, &max)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Clip(self, min, max));\n}\n\nstatic char doc_conj[] = \"a.conj()\";\n\nstatic char doc_conjugate[] = \"a.conjugate()\";\n\nstatic PyObject *\narray_conjugate(PyArrayObject *self, PyObject *args) \n{\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\treturn PyArray_Conjugate(self);\n}\n\n\nstatic char doc_diagonal[] = \"a.diagonal(offset=0, axis1=0, axis2=1)\";\n\nstatic PyObject *\narray_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iii\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Diagonal(self, offset, axis1, axis2));\n}\n\nstatic char doc_flatten[] = \"a.flatten([fortran]) return a 1-d array (always copy)\";\n\nstatic PyObject *\narray_flatten(PyArrayObject *self, PyObject *args)\n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter, \n\t\t\t &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, fortran);\n}\n\nstatic char doc_ravel[] = \"a.ravel([fortran]) return a 1-d array (copy only if needed)\";\n\nstatic PyObject *\narray_ravel(PyArrayObject *self, PyObject *args)\n{\n\tPyArray_ORDER fortran=PyArray_CORDER;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_OrderConverter, \n\t\t\t &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\n\nstatic char doc_round[] = \"a.round(decimals=0)\";\n\nstatic PyObject *\narray_round(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint decimals = 0;\n\tstatic char *kwlist[] = {\"decimals\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|i\", kwlist,\n\t\t\t\t\t &decimals)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Round(self, decimals));\n}\n\n\nstatic char doc_setflags[] = \"a.setflags(write=None, align=None, uic=None)\";\n\nstatic int _IsAligned(PyArrayObject *);\nstatic Bool _IsWriteable(PyArrayObject *);\n\nstatic PyObject *\narray_setflags(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"write\", \"align\", \"uic\", NULL};\n\tPyObject *write=Py_None;\n\tPyObject *align=Py_None;\n\tPyObject *uic=Py_None;\n\tint flagback = self->flags;\n\t\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOO\", kwlist,\n\t\t\t\t\t &write, &align, &uic))\n\t\treturn NULL;\n\n\tif (align != Py_None) {\n\t\tif (PyObject_Not(align)) self->flags &= ~ALIGNED;\n\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot set aligned flag of mis-\"\\\n\t\t\t\t\t\"aligned array to True\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif (uic != Py_None) {\n if (PyObject_IsTrue(uic)) {\n\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return NULL;\n }\n else {\n self->flags &= ~UPDATEIFCOPY;\n Py_XDECREF(self->base);\n self->base = NULL;\n }\n }\n \n if (write != Py_None) {\n if (PyObject_IsTrue(write)) \n\t\t\tif (_IsWriteable(self)) {\n\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tself->flags = flagback;\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"cannot set WRITEABLE \"\t\\\n\t\t\t\t\t\t\"flag to True of this \"\t\\\n\t\t\t\t\t\t\"array\");\t\t\\\n\t\t\t\treturn NULL;\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n \n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_newbyteorder[] = \"a.newbyteorder() is equivalent\\n\" \\\n\t\" to a.view(a.dtype.newbytorder())\\n\";\n\nstatic PyObject *\narray_newbyteorder(PyArrayObject *self, PyObject *args) \n{\n\tchar endian = PyArray_SWAP;\n\tPyArray_Descr *new;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\tnew = PyArray_DescrNewByteorder(self->descr, endian);\n\tif (!new) return NULL;\n\treturn PyArray_View(self, new, NULL);\n\n}\n\nstatic PyMethodDef array_methods[] = {\n {\"tolist\",\t (PyCFunction)array_tolist,\t1, doc_tolist},\n {\"item\", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},\n\t{\"tofile\", (PyCFunction)array_tofile, \n METH_VARARGS | METH_KEYWORDS, doc_tofile},\n {\"tostring\", (PyCFunction)array_tostring, METH_VARARGS, doc_tostring},\n {\"byteswap\", (PyCFunction)array_byteswap,\t1, doc_byteswap},\n {\"astype\", (PyCFunction)array_cast, 1, doc_cast},\n\t{\"getfield\", (PyCFunction)array_getfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_getfield},\n\t{\"setfield\", (PyCFunction)array_setfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_setfield},\n {\"copy\", (PyCFunction)array_copy, 1, doc_copy}, \n {\"resize\", (PyCFunction)array_resize, \n\t METH_VARARGS | METH_KEYWORDS, doc_resize}, \n\n\t/* for subtypes */\n\t{\"__array__\", (PyCFunction)array_getarray, 1, doc_array_getarray},\n\t{\"__array_wrap__\", (PyCFunction)array_wraparray, 1, doc_wraparray},\n\t/* default version so it is found... -- only used for subclasses */\n\t{\"__array_finalize__\", (PyCFunction)array_finalize, 1, NULL},\n\t\n\t\n\t/* for the copy module */\n {\"__copy__\", (PyCFunction)array_copy, 1, doc_copy},\t \n {\"__deepcopy__\", (PyCFunction)array_deepcopy, 1, doc_deepcopy}, \n\t\n /* for Pickling */\n {\"__reduce__\", (PyCFunction) array_reduce, 1, doc_reduce},\t\n\t{\"__setstate__\", (PyCFunction) array_setstate, 1, doc_setstate},\n\t{\"dumps\", (PyCFunction) array_dumps, 1, doc_dumps},\n\t{\"dump\", (PyCFunction) array_dump, 1, doc_dump},\n\n\t/* Extended methods added 2005 */\n\t{\"fill\", (PyCFunction)array_fill,\n\t METH_VARARGS, doc_fill},\n\t{\"transpose\",\t(PyCFunction)array_transpose, \n\t METH_VARARGS, doc_transpose},\n\t{\"take\",\t(PyCFunction)array_take, \n\t METH_VARARGS|METH_KEYWORDS, doc_take},\n\t{\"put\",\t(PyCFunction)array_put, \n\t METH_VARARGS|METH_KEYWORDS, doc_put},\n\t{\"putmask\",\t(PyCFunction)array_putmask, \n\t METH_VARARGS|METH_KEYWORDS, doc_putmask},\n\t{\"repeat\",\t(PyCFunction)array_repeat, \n\t METH_VARARGS|METH_KEYWORDS, doc_repeat},\n\t{\"choose\",\t(PyCFunction)array_choose, \n\t METH_VARARGS, doc_choose},\t\n\t{\"sort\",\t(PyCFunction)array_sort, \n\t METH_VARARGS|METH_KEYWORDS, doc_sort},\n\t{\"argsort\",\t(PyCFunction)array_argsort, \n\t METH_VARARGS|METH_KEYWORDS, doc_argsort},\n\t{\"searchsorted\", (PyCFunction)array_searchsorted, \n\t METH_VARARGS, doc_searchsorted},\t\n\t{\"argmax\",\t(PyCFunction)array_argmax, \n\t METH_VARARGS|METH_KEYWORDS, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS|METH_KEYWORDS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS|METH_KEYWORDS, doc_reshape},\n\t{\"squeeze\",\t(PyCFunction)array_squeeze,\n\t METH_VARARGS, doc_squeeze},\n\t{\"view\", (PyCFunction)array_view, \n\t METH_VARARGS, doc_view},\n\t{\"swapaxes\", (PyCFunction)array_swapaxes,\n\t METH_VARARGS, doc_swapaxes},\n\t{\"max\", (PyCFunction)array_max,\n\t METH_VARARGS|METH_KEYWORDS, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS|METH_KEYWORDS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS|METH_KEYWORDS, doc_ptp},\n\t{\"mean\", (PyCFunction)array_mean,\n\t METH_VARARGS|METH_KEYWORDS, doc_mean},\n\t{\"trace\", (PyCFunction)array_trace,\n\t METH_VARARGS|METH_KEYWORDS, doc_trace},\n\t{\"diagonal\", (PyCFunction)array_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, doc_diagonal},\n\t{\"clip\", (PyCFunction)array_clip,\n\t METH_VARARGS|METH_KEYWORDS, doc_clip},\n\t{\"conj\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conj},\n\t{\"conjugate\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conjugate},\n\t{\"nonzero\", (PyCFunction)array_nonzero,\n\t METH_VARARGS, doc_nonzero},\n\t{\"std\", (PyCFunction)array_stddev,\n\t METH_VARARGS|METH_KEYWORDS, doc_stddev},\n\t{\"var\", (PyCFunction)array_variance,\n\t METH_VARARGS|METH_KEYWORDS, doc_variance},\n\t{\"sum\", (PyCFunction)array_sum,\n\t METH_VARARGS|METH_KEYWORDS, doc_sum},\n\t{\"cumsum\", (PyCFunction)array_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumsum},\n\t{\"prod\", (PyCFunction)array_prod,\n\t METH_VARARGS|METH_KEYWORDS, doc_prod},\n\t{\"cumprod\", (PyCFunction)array_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumprod},\n\t{\"all\", (PyCFunction)array_all,\n\t METH_VARARGS|METH_KEYWORDS, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS|METH_KEYWORDS, doc_any},\n\t{\"compress\", (PyCFunction)array_compress,\n\t METH_VARARGS|METH_KEYWORDS, doc_compress},\n\t{\"flatten\", (PyCFunction)array_flatten,\n\t METH_VARARGS, doc_flatten},\n\t{\"ravel\", (PyCFunction)array_ravel,\n\t METH_VARARGS, doc_ravel},\n\t{\"round\", (PyCFunction)array_round,\n\t METH_VARARGS|METH_KEYWORDS, doc_round},\n\t{\"setflags\", (PyCFunction)array_setflags,\n\t METH_VARARGS|METH_KEYWORDS, doc_setflags},\n\t{\"newbyteorder\", (PyCFunction)array_newbyteorder,\n\t METH_VARARGS, doc_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n#undef _ARET\n\n\n", + "methods": [ + { + "name": "array_take", + "long_name": "array_take( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_fill", + "long_name": "array_fill( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "args" + ], + "start_line": 28, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_put", + "long_name": "array_put( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 43, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_putmask", + "long_name": "array_putmask( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 58, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 34, + "complexity": 8, + "token_count": 176, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 78, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_squeeze", + "long_name": "array_squeeze( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 119, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_view", + "long_name": "array_view( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 19, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "args" + ], + "start_line": 128, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_argmax", + "long_name": "array_argmax( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 153, + "end_line": 164, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 169, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 185, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 201, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 218, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_swapaxes", + "long_name": "array_swapaxes( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 234, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetField", + "long_name": "PyArray_GetField( PyArrayObject * self , PyArray_Descr * typed , int offset)", + "filename": "arraymethods.c", + "nloc": 23, + "complexity": 4, + "token_count": 155, + "parameters": [ + "self", + "typed", + "offset" + ], + "start_line": 253, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_getfield", + "long_name": "array_getfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 280, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetField", + "long_name": "PyArray_SetField( PyArrayObject * self , PyArray_Descr * dtype , int offset , PyObject * val)", + "filename": "arraymethods.c", + "nloc": 25, + "complexity": 4, + "token_count": 184, + "parameters": [ + "self", + "dtype", + "offset", + "val" + ], + "start_line": 302, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_setfield", + "long_name": "array_setfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 331, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Byteswap", + "long_name": "PyArray_Byteswap( PyArrayObject * self , Bool inplace)", + "filename": "arraymethods.c", + "nloc": 37, + "complexity": 5, + "token_count": 226, + "parameters": [ + "self", + "inplace" + ], + "start_line": 353, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_byteswap", + "long_name": "array_byteswap( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 407, + "end_line": 415, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_tolist", + "long_name": "array_tolist( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 51, + "parameters": [ + "self", + "args" + ], + "start_line": 421, + "end_line": 431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_tostring", + "long_name": "array_tostring( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 437, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_tofile", + "long_name": "array_tofile( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 33, + "complexity": 7, + "token_count": 208, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 446, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "array_toscalar", + "long_name": "array_toscalar( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 4, + "token_count": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 486, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_cast", + "long_name": "array_cast( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 13, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "args" + ], + "start_line": 502, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_wraparray", + "long_name": "array_wraparray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 27, + "complexity": 4, + "token_count": 147, + "parameters": [ + "self", + "args" + ], + "start_line": 524, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_finalize", + "long_name": "array_finalize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "args" + ], + "start_line": 556, + "end_line": 560, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_getarray", + "long_name": "array_getarray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 38, + "complexity": 7, + "token_count": 218, + "parameters": [ + "self", + "args" + ], + "start_line": 566, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "array_copy", + "long_name": "array_copy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 618, + "end_line": 625, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 42, + "complexity": 12, + "token_count": 227, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 633, + "end_line": 675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_repeat", + "long_name": "array_repeat( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 683, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_choose", + "long_name": "array_choose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 703, + "end_line": 718, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_sort", + "long_name": "array_sort( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 723, + "end_line": 738, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_argsort", + "long_name": "array_argsort( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 745, + "end_line": 756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_searchsorted", + "long_name": "array_searchsorted( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 767, + "end_line": 774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_deepcopy", + "long_name": "array_deepcopy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 32, + "complexity": 7, + "token_count": 234, + "parameters": [ + "self", + "args" + ], + "start_line": 779, + "end_line": 812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_getobject_pkl", + "long_name": "_getobject_pkl( PyArrayObject * self)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 4, + "token_count": 128, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 835, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_setobject_pkl", + "long_name": "_setobject_pkl( PyArrayObject * self , PyObject * list)", + "filename": "arraymethods.c", + "nloc": 17, + "complexity": 3, + "token_count": 115, + "parameters": [ + "self", + "list" + ], + "start_line": 838, + "end_line": 856, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_reduce", + "long_name": "array_reduce( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 45, + "complexity": 7, + "token_count": 300, + "parameters": [ + "self", + "args" + ], + "start_line": 861, + "end_line": 924, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "array_setstate", + "long_name": "array_setstate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 99, + "complexity": 18, + "token_count": 585, + "parameters": [ + "self", + "args" + ], + "start_line": 942, + "end_line": 1056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dump", + "long_name": "PyArray_Dump( PyObject * self , PyObject * file , int protocol)", + "filename": "arraymethods.c", + "nloc": 20, + "complexity": 6, + "token_count": 132, + "parameters": [ + "self", + "file", + "protocol" + ], + "start_line": 1060, + "end_line": 1081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dumps", + "long_name": "PyArray_Dumps( PyObject * self , int protocol)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 70, + "parameters": [ + "self", + "protocol" + ], + "start_line": 1085, + "end_line": 1096, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dump", + "long_name": "array_dump( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1102, + "end_line": 1113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dumps", + "long_name": "array_dumps( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "args" + ], + "start_line": 1118, + "end_line": 1123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_transpose", + "long_name": "array_transpose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 5, + "token_count": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 1129, + "end_line": 1149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_mean", + "long_name": "array_mean( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1167, + "end_line": 1179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_sum", + "long_name": "array_sum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1206, + "end_line": 1218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumsum", + "long_name": "array_cumsum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1224, + "end_line": 1236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_prod", + "long_name": "array_prod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1241, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumprod", + "long_name": "array_cumprod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1259, + "end_line": 1271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_any", + "long_name": "array_any( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1277, + "end_line": 1288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1293, + "end_line": 1304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_stddev", + "long_name": "array_stddev( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1309, + "end_line": 1321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_variance", + "long_name": "array_variance( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1326, + "end_line": 1338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_compress", + "long_name": "array_compress( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1343, + "end_line": 1354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nonzero", + "long_name": "array_nonzero( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 1360, + "end_line": 1365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_trace", + "long_name": "array_trace( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1373, + "end_line": 1386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_clip", + "long_name": "array_clip( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1394, + "end_line": 1404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_conjugate", + "long_name": "array_conjugate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 1411, + "end_line": 1417, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_diagonal", + "long_name": "array_diagonal( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1423, + "end_line": 1433, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_flatten", + "long_name": "array_flatten( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1438, + "end_line": 1446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1451, + "end_line": 1459, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_round", + "long_name": "array_round( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1464, + "end_line": 1474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_setflags", + "long_name": "array_setflags( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 53, + "complexity": 10, + "token_count": 260, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1483, + "end_line": 1540, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "array_newbyteorder", + "long_name": "array_newbyteorder( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 1546, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "array_take", + "long_name": "array_take( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_fill", + "long_name": "array_fill( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "args" + ], + "start_line": 28, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_put", + "long_name": "array_put( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 43, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_putmask", + "long_name": "array_putmask( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 58, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 34, + "complexity": 8, + "token_count": 176, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 78, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_squeeze", + "long_name": "array_squeeze( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 119, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_view", + "long_name": "array_view( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 19, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "args" + ], + "start_line": 128, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_argmax", + "long_name": "array_argmax( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 153, + "end_line": 164, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 169, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 185, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 201, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 218, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_swapaxes", + "long_name": "array_swapaxes( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 234, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetField", + "long_name": "PyArray_GetField( PyArrayObject * self , PyArray_Descr * typed , int offset)", + "filename": "arraymethods.c", + "nloc": 23, + "complexity": 4, + "token_count": 155, + "parameters": [ + "self", + "typed", + "offset" + ], + "start_line": 253, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_getfield", + "long_name": "array_getfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 280, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetField", + "long_name": "PyArray_SetField( PyArrayObject * self , PyArray_Descr * dtype , int offset , PyObject * val)", + "filename": "arraymethods.c", + "nloc": 25, + "complexity": 4, + "token_count": 184, + "parameters": [ + "self", + "dtype", + "offset", + "val" + ], + "start_line": 302, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_setfield", + "long_name": "array_setfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 331, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Byteswap", + "long_name": "PyArray_Byteswap( PyArrayObject * self , Bool inplace)", + "filename": "arraymethods.c", + "nloc": 37, + "complexity": 5, + "token_count": 226, + "parameters": [ + "self", + "inplace" + ], + "start_line": 353, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_byteswap", + "long_name": "array_byteswap( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 407, + "end_line": 415, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_tolist", + "long_name": "array_tolist( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 51, + "parameters": [ + "self", + "args" + ], + "start_line": 421, + "end_line": 431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_tostring", + "long_name": "array_tostring( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 437, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_tofile", + "long_name": "array_tofile( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 33, + "complexity": 7, + "token_count": 208, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 446, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "array_toscalar", + "long_name": "array_toscalar( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 4, + "token_count": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 486, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_cast", + "long_name": "array_cast( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 13, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "args" + ], + "start_line": 502, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_wraparray", + "long_name": "array_wraparray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 27, + "complexity": 4, + "token_count": 147, + "parameters": [ + "self", + "args" + ], + "start_line": 524, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_finalize", + "long_name": "array_finalize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "args" + ], + "start_line": 556, + "end_line": 560, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_getarray", + "long_name": "array_getarray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 38, + "complexity": 7, + "token_count": 218, + "parameters": [ + "self", + "args" + ], + "start_line": 566, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "array_copy", + "long_name": "array_copy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 618, + "end_line": 625, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 42, + "complexity": 12, + "token_count": 227, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 633, + "end_line": 675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_repeat", + "long_name": "array_repeat( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 683, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_choose", + "long_name": "array_choose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 703, + "end_line": 718, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_sort", + "long_name": "array_sort( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 723, + "end_line": 738, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_argsort", + "long_name": "array_argsort( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 745, + "end_line": 756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_searchsorted", + "long_name": "array_searchsorted( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 767, + "end_line": 774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_deepcopy", + "long_name": "array_deepcopy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 32, + "complexity": 7, + "token_count": 234, + "parameters": [ + "self", + "args" + ], + "start_line": 779, + "end_line": 812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_getobject_pkl", + "long_name": "_getobject_pkl( PyArrayObject * self)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 4, + "token_count": 128, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 835, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_setobject_pkl", + "long_name": "_setobject_pkl( PyArrayObject * self , PyObject * list)", + "filename": "arraymethods.c", + "nloc": 17, + "complexity": 3, + "token_count": 115, + "parameters": [ + "self", + "list" + ], + "start_line": 838, + "end_line": 856, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_reduce", + "long_name": "array_reduce( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 46, + "complexity": 7, + "token_count": 313, + "parameters": [ + "self", + "args" + ], + "start_line": 861, + "end_line": 924, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "array_setstate", + "long_name": "array_setstate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 99, + "complexity": 18, + "token_count": 585, + "parameters": [ + "self", + "args" + ], + "start_line": 942, + "end_line": 1056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dump", + "long_name": "PyArray_Dump( PyObject * self , PyObject * file , int protocol)", + "filename": "arraymethods.c", + "nloc": 20, + "complexity": 6, + "token_count": 132, + "parameters": [ + "self", + "file", + "protocol" + ], + "start_line": 1060, + "end_line": 1081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dumps", + "long_name": "PyArray_Dumps( PyObject * self , int protocol)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 70, + "parameters": [ + "self", + "protocol" + ], + "start_line": 1085, + "end_line": 1096, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dump", + "long_name": "array_dump( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1102, + "end_line": 1113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dumps", + "long_name": "array_dumps( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "args" + ], + "start_line": 1118, + "end_line": 1123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_transpose", + "long_name": "array_transpose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 5, + "token_count": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 1129, + "end_line": 1149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_mean", + "long_name": "array_mean( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1167, + "end_line": 1179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_sum", + "long_name": "array_sum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1206, + "end_line": 1218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumsum", + "long_name": "array_cumsum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1224, + "end_line": 1236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_prod", + "long_name": "array_prod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1241, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumprod", + "long_name": "array_cumprod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1259, + "end_line": 1271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_any", + "long_name": "array_any( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1277, + "end_line": 1288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1293, + "end_line": 1304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_stddev", + "long_name": "array_stddev( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1309, + "end_line": 1321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_variance", + "long_name": "array_variance( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1326, + "end_line": 1338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_compress", + "long_name": "array_compress( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1343, + "end_line": 1354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nonzero", + "long_name": "array_nonzero( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 1360, + "end_line": 1365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_trace", + "long_name": "array_trace( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1373, + "end_line": 1386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_clip", + "long_name": "array_clip( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1394, + "end_line": 1404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_conjugate", + "long_name": "array_conjugate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 1411, + "end_line": 1417, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_diagonal", + "long_name": "array_diagonal( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1423, + "end_line": 1433, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_flatten", + "long_name": "array_flatten( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1438, + "end_line": 1446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1451, + "end_line": 1459, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_round", + "long_name": "array_round( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1464, + "end_line": 1474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_setflags", + "long_name": "array_setflags( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 53, + "complexity": 10, + "token_count": 260, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1483, + "end_line": 1540, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "array_newbyteorder", + "long_name": "array_newbyteorder( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 1546, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "array_reduce", + "long_name": "array_reduce( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 45, + "complexity": 7, + "token_count": 300, + "parameters": [ + "self", + "args" + ], + "start_line": 861, + "end_line": 924, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + } + ], + "nloc": 1336, + "complexity": 221, + "token_count": 8302, + "diff_parsed": { + "added": [ + "\t\t\t Py_BuildValue(\"ONc\",", + "\t\t\t\t /* dummy data-type */", + "\t\t\t\t 'b'));" + ], + "deleted": [ + "\t\t\t Py_BuildValue(\"ONN\",", + "\t\t\t\t PyObject_GetAttrString((PyObject *)(self->descr),", + "\t\t\t\t\t\t\t \"char\")));" + ] + } + }, + { + "old_path": "numpy/core/src/arrayobject.c", + "new_path": "numpy/core/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -8774,7 +8774,8 @@ arraydescr_setstate(PyArray_Descr *self, PyObject *args)\n \tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n \t\t\t &elsize, &alignment)) return NULL;\n \n-\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n+\tif (endian != '|' && \n+\t PyArray_IsNativeByteOrder(endian)) endian = '=';\n \n \tself->byteorder = endian;\n \tif (self->subarray) {\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": "/*\n Provide multidimensional arrays as a basic object type in python.\n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004\n\nHeavily modified in 2005 with inspiration from Numarray\n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University\n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by\nSpace Science Telescope Institute\n (J. Todd Miller, Perry Greenfield, Rick White)\n*/\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_)\n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear();\n priority = default_;\n }\n Py_XDECREF(ret);\n return priority;\n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a\n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int\ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides,\n\t intp *src_dimensions, int src_nd, int elsize,\n\t int copies) {\n intp i, j;\n\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1,\n dest_dimensions+1, dest_nd-1,\n src, src_strides,\n src_dimensions, src_nd,\n elsize, copies) == -1)\n return -1;\n }\n return 0;\n }\n\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError,\n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) &&\n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] !=\n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src)\n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\n dest_strides_ptr = dest_strides;\n\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1)\n return NULL;\n\n new_data = (char *)_pya_malloc(stride);\n\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions,\n dest_nd, src->data, src_strides,\n src_dimensions, src_nd, elsize, copies);\n\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *,\n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int\nPyArray_INCREF(PyArrayObject *mp)\n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL)\n return -1;\n }\n\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL)\n return -1;\n }\n\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap)\n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n\n\n if ((numitems == 1) || (itemsize == srcstrides))\n memcpy(d1, s1, itemsize*numitems);\n else {\n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n }\n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n#ifndef Py_UNICODE_WIDE\n#include \"ucsnarrow.c\"\n#endif\n\n\nstatic PyArray_Descr **userdescrs=NULL;\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\n\n/* Helper functions */\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t\tgoto finish;\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t\tgoto finish;\n\t}\n\n#if SIZEOF_INTP == SIZEOF_LONG\n\tdescr = &LONG_Descr;\n#elif SIZEOF_INTP == SIZEOF_INT\n\tdescr = &INT_Descr;\n#else\n\tdescr = &LONGLONG_DESCR;\n#endif\n\tarr = NULL;\n\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\tif (o->ob_type->tp_as_number != NULL &&\t\t\t\\\n\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n#if (SIZEOF_LONGLONG > SIZEOF_INTP)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t\tgoto finish;\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t\tgoto finish;\n\t}\n\n\tdescr = &INT_Descr;\n\tarr=NULL;\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\tif (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t}\n\telse if (o->ob_type->tp_as_number != NULL &&\t\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n#if (SIZEOF_LONG > SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i)\n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp\nPyArray_Size(PyObject *op)\n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n }\n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src\n will be cast to destination.\n*/\n\n/* Does a flat iterator-based copy.\n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however.\n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n\n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError,\n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError,\n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n\n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n }\n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int\nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)\n{\n PyArrayObject *src;\n int ret;\n\t\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n dest->descr, 0,\n dest->nd, FORTRAN_IF(dest), NULL);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d,\n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n#endif\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t} \n\treturn ret;\n}\n\n/* end old calls */\n\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, PyArray_ORDER fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(m1);\n \n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type,\n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd,\n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran,\n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\n return (PyObject *)ret;\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj;\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\tif (type_num == PyArray_BOOL)\n\t\tPyArrayScalar_RETURN_BOOL_FROM_LONG(*(Bool*)data);\n\telse if (type_num == PyArray_OBJECT) {\n\t\tPy_INCREF(*((PyObject **)data));\n\t\treturn *((PyObject **)data);\n\t}\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) {\n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED;\n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize >> 2;\n#ifndef Py_UNICODE_WIDE\n\t\t\tchar *buffer;\n\t\t\tint alloc=0;\n\t\t\tlength *= 2;\n#endif\n\t\t\t/* Need an extra slot and need to use\n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n#ifndef Py_UNICODE_WIDE\n\t\t\t/* need aligned data buffer */\n\t\t\tif (!PyArray_ISBEHAVED(base)) {\n\t\t\t\tbuffer = _pya_malloc(itemsize);\n\t\t\t\tif (buffer == NULL)\n\t\t\t\t\treturn PyErr_NoMemory();\n\t\t\t\talloc = 1;\n\t\t\t\tmemcpy(buffer, data, itemsize);\n\t\t\t\tif (!PyArray_ISNOTSWAPPED(base)) {\n\t\t\t\t\tbyte_swap_vector(buffer, itemsize >> 2, 4);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse buffer = data;\n\n /* Allocated enough for 2-characters per itemsize.\n\t\t\t Now convert from the data-buffer\n */\n\t\t\tlength = PyUCS2Buffer_FromUCS4(uni->str, (PyArray_UCS4 *)buffer,\n\t\t\t\t\t\t itemsize >> 2);\n\t\t\tif (alloc) _pya_free(buffer);\n\t\t\t/* Resize the unicode result */\n\t\t\tif (MyPyUnicode_Resize(uni, length) < 0) {\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treturn obj;\n#endif\n\t\t}\n\t\telse {\n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (descr->fields) {\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this.\n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag\n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp)\n{\n\n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (!PyArray_Check(mp)) return (PyObject *)mp;\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n\n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int\nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs,\n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/*\n copyies over from the old descr table for anything\n NULL or zero in what is given.\n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray,\n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format)\n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data,\n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError,\n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr,\n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element\"\\\n \" %d to file\",\n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj);\n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj),\n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\",\n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1)\n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self)\n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0)\n\t\treturn self->descr->f->getitem(self->data,self);\n\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n\n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void\narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an\n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE\n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n\n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic _int_or_ssize_t\narray_length(PyArrayObject *self)\n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i)\n{\n\tchar *item;\n\tPyArrayObject *r;\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1,\n\t\t\t\t\t\t self->dimensions+1,\n\t\t\t\t\t\t self->strides+1, item,\n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, _int_or_ssize_t i)\n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\nstatic int\narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v)\n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret;\n }\n\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if PY_VERSION_HEX < 0x02050000\n #if SIZEOF_INT == SIZEOF_INTP\n #define array_ass_item array_ass_big_item\n #endif\n#else\n #if SIZEOF_SIZE_T == SIZEOF_INTP\n #define array_ass_item array_ass_big_item\n #endif\n#endif\n#ifndef array_ass_item\nstatic int\narray_ass_item(PyArrayObject *self, _int_or_ssize_t i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int\nparse_index(PyArrayObject *self, PyObject *op,\n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError,\n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\n nd_old = nd_new = 0;\n\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError,\n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError,\n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is\n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of\n\t the broadcasted index array\n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the\n\t result\n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2)\n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call.\n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *, int, int);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type,\n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret))\n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST, NULL);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\nint\ncount_new_axes_0d(PyObject *tuple)\n{\n\tint i, argument_count;\n\tint ellipsis_count = 0;\n\tint newaxis_count = 0;\n\n\targument_count = PyTuple_GET_SIZE(tuple);\n\n\tfor (i = 0; i < argument_count; ++i) {\n\t\tPyObject *arg = PyTuple_GET_ITEM(tuple, i);\n\t\tif (arg == Py_Ellipsis && !ellipsis_count) ellipsis_count++;\n\t\telse if (arg == Py_None) newaxis_count++;\n\t\telse break;\n\t}\n\tif (i < argument_count) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can only use a single ()\"\n\t\t\t\t\" or a list of newaxes (and a single ...)\"\n\t\t\t\t\" as an index\");\n\t\treturn -1;\n\t}\n\tif (newaxis_count > MAX_DIMS) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"too many dimensions\");\n\t\treturn -1;\n\t}\n\treturn newaxis_count;\n}\n\nstatic PyObject *\nadd_new_axes_0d(PyArrayObject *arr, int newaxis_count)\n{\n\tPyArrayObject *other;\n\tintp dimensions[MAX_DIMS];\n\tint i;\n\tfor (i = 0; i < newaxis_count; ++i) {\n\t\tdimensions[i] = 1;\n\t}\n\tPy_INCREF(arr->descr);\n\tif ((other = (PyArrayObject *)\n\t PyArray_NewFromDescr(arr->ob_type, arr->descr,\n\t\t\t\t newaxis_count, dimensions,\n\t\t\t\t NULL, arr->data,\n\t\t\t\t arr->flags,\n\t\t\t\t (PyObject *)arr)) == NULL)\n\t\treturn NULL;\n\tother->base = (PyObject *)arr;\n\tPy_INCREF(arr);\n\treturn (PyObject *)other;\n}\n\n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0\n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* Called when treating array object like a mapping -- called first from\n Python when using a[object] unless object is a standard slice object\n (not an extended one).\n\n*/\n\n/* There are two situations:\n\n 1 - the subscript is a standard view and a reference to the\n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned.\n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *iter_subscript(PyArrayIterObject *, PyObject *);\n\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op)\n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, oned, fancy;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr,\n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n if (self->nd == 0) {\n\t\tif (op == Py_Ellipsis) {\n\t\t\t/* XXX: This leads to a small inconsistency\n\t\t\t XXX: with the nd>0 case where (x[...] is x)\n\t\t\t XXX: is false for nd>0 case. */\n\t\t\tPy_INCREF(self);\n\t\t\treturn (PyObject *)self;\n\t\t}\n\t\tif (op == Py_None)\n\t\t\treturn add_new_axes_0d(self, 1);\n\t\tif (PyTuple_Check(op)) {\n\t\t\tif (0 == PyTuple_GET_SIZE(op)) {\n\t\t\t\tPy_INCREF(self);\n\t\t\t\treturn (PyObject *)self;\n\t\t\t}\n\t\t\tif ((nd = count_new_axes_0d(op)) == -1)\n\t\t\t\treturn NULL;\n\t\t\treturn add_new_axes_0d(self, nd);\n\t\t}\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\n\tfancy = fancy_indexing_check(op);\n\n\tif (fancy != SOBJ_NOTFANCY) {\n\t\toned = ((self->nd == 1) && !(PyTuple_Check(op) &&\t\\\n\t\t\t\t\t PyTuple_GET_SIZE(op) > 1));\n\n\t\t/* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)\\\n\t\t\tPyArray_MapIterNew(op, oned, fancy);\n\t\tif (mit == NULL) return NULL;\n\t\tif (oned) {\n\t\t\tPyArrayIterObject *it;\n\t\t\tPyObject *rval;\n\t\t\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\t\t\tif (it == NULL) {Py_DECREF(mit); return NULL;}\n\t\t\trval = iter_subscript(it, mit->indexobj);\n\t\t\tPy_DECREF(it);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn rval;\n\t\t}\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset))\n == -1)\n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset,\n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL)\n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be\n used.\n*/\n\nstatic int iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *);\n\nstatic int\narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op)\n{\n int ret, oned, fancy;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr,\n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n if (self->nd == 0) {\n\t\tif (index == Py_Ellipsis || index == Py_None ||\t\t\\\n\t\t (PyTuple_Check(index) && (0 == PyTuple_GET_SIZE(index) || \\\n\t\t\t\t\t count_new_axes_0d(index) > 0)))\n\t\t\treturn self->descr->f->setitem(op, self->data, self);\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n\tfancy = fancy_indexing_check(index);\n\n\tif (fancy != SOBJ_NOTFANCY) {\n\t\toned = ((self->nd == 1) && !(PyTuple_Check(index) && \\\n\t\t\t\t\t PyTuple_GET_SIZE(index) > 1));\n\n\t\tmit = (PyArrayMapIterObject *)\t\t\t\\\n\t\t\tPyArray_MapIterNew(index, oned, fancy);\n\t\tif (mit == NULL) return -1;\n\t\tif (oned) {\n\t\t\tPyArrayIterObject *it;\n\t\t\tint rval;\n\t\t\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\t\t\tif (it == NULL) {Py_DECREF(mit); return -1;}\n\t\t\trval = iter_ass_subscript(it, mit->indexobj, op);\n\t\t\tPy_DECREF(it);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn rval;\n\t\t}\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1;\n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to\n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op)\n{\n\t/* The following is just a copy of PyArray_Return with an\n\t additional logic in the nd == 0 case. More efficient\n\t implementation may be possible by refactoring\n\t array_subscript */\n\n\tPyArrayObject *mp = (PyArrayObject *)array_subscript(self, op);\n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (!PyArray_Check(mp)) return (PyObject *)mp;\n\t\n\tif (mp->nd == 0) {\n\t\tBool noellipses = TRUE;\n\t\tif (op == Py_Ellipsis)\n\t\t\tnoellipses = FALSE;\n\t\telse if (PySequence_Check(op)) {\n\t\t\tint n, i;\n\t\t\tn = PySequence_Size(op);\n\t\t\tfor (i = 0; i < n; ++i) \n\t\t\t\tif (PySequence_GetItem(op, i) == Py_Ellipsis) {\n\t\t\t\t\tnoellipses = FALSE;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tif (noellipses) {\n\t\t\tPyObject *ret;\n\t\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\t\tPy_DECREF(mp);\n\t\t\treturn ret;\n\t\t}\n\t}\n\treturn (PyObject *)mp;\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)array_length,\t\t /*mp_length*/\n#else\n (inquiry)array_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic _int_or_ssize_t\narray_getsegcount(PyArrayObject *self, _int_or_ssize_t *lenp)\n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic _int_or_ssize_t\narray_getreadbuf(PyArrayObject *self, _int_or_ssize_t segment, void **ptrptr)\n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError,\n \"accessing non-existing array segment\");\n return -1;\n }\n\n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic _int_or_ssize_t\narray_getwritebuf(PyArrayObject *self, _int_or_ssize_t segment, void **ptrptr)\n{\n if (PyArray_CHKFLAGS(self, WRITEABLE))\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic _int_or_ssize_t\narray_getcharbuf(PyArrayObject *self, _int_or_ssize_t segment, const char **ptrptr)\n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError,\n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n#if PY_VERSION_HEX >= 0x02050000\n (readbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (writebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (segcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (charbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n#else\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n#endif\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n *square,\n *reciprocal,\n *ones_like,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum,\n\t\t*rint;\n} NumericOps;\n\nstatic NumericOps n_ops; /* NB: static objects inlitialized to zero */\n\n/* Dictionary can contain any of the numeric operations, by name.\n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n\n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint\nPyArray_SetNumericOps(PyObject *dict)\n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n SET(square);\n SET(reciprocal);\n SET(ones_like);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\n SET(true_divide);\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n\tSET(rint);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void)\n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL)\n\t\treturn NULL;\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n GET(square);\n GET(reciprocal);\n GET(ones_like);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide);\n GET(true_divide);\n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\tGET(rint);\n\treturn dict;\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE)\n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE)\n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1,\n\t\t\t\t PyObject *m2, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceUnaryFunction(PyArrayObject *m1, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OO\", m1, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2)\n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic int\narray_power_is_scalar(PyObject *o2, double* exp)\n{\n PyObject *temp;\n const int optimize_fpexps = 1;\n\n if (PyInt_Check(o2)) {\n\t *exp = (double)PyInt_AsLong(o2);\n\t return 1;\n }\n if (optimize_fpexps && PyFloat_Check(o2)) {\n\t *exp = PyFloat_AsDouble(o2);\n\t return 1;\n }\n if ((PyArray_IsZeroDim(o2) && \n\t ((PyArray_ISINTEGER(o2) || \n\t (optimize_fpexps && PyArray_ISFLOAT(o2))))) || \n\tPyArray_IsScalar(o2, Integer) || \n\t(optimize_fpexps && PyArray_IsScalar(o2, Floating))) {\n\t temp = o2->ob_type->tp_as_number->nb_float(o2);\n\t if (temp != NULL) {\n\t\t *exp = PyFloat_AsDouble(o2);\n\t\t Py_DECREF(temp);\n\t\t return 1;\n\t }\n }\n return 0;\n}\n\n/* optimize float array or complex array to a scalar power */\nstatic PyObject *\nfast_scalar_power(PyArrayObject *a1, PyObject *o2, int inplace) {\n\tdouble exp;\n\tif (PyArray_Check(a1) && (PyArray_ISFLOAT(a1) || \n\t\t\t\t PyArray_ISCOMPLEX(a1))) {\n\t\tif (array_power_is_scalar(o2, &exp)) {\n\t\t\tPyObject *fastop = NULL;\n\t\t\tif (exp == 1.0) {\n\t\t\t\t/* we have to do this one special, as the \n\t\t\t\t \"copy\" method of array objects isn't set \n\t\t\t\t up early enough to be added\n\t\t\t\t by PyArray_SetNumericOps.\n\t\t\t\t*/\n\t\t\t\tif (inplace) {\n\t\t\t\t\treturn (PyObject *)a1;\n\t\t\t\t} else {\n\t\t\t\t\treturn PyArray_Copy(a1);\n\t\t\t\t}\n\t\t\t} else if (exp == -1.0) {\n\t\t\t\tfastop = n_ops.reciprocal;\n\t\t\t} else if (exp == 0.0) {\n\t\t\t\tfastop = n_ops.ones_like;\n\t\t\t} else if (exp == 0.5) {\n\t\t\t\tfastop = n_ops.sqrt;\n\t\t\t} else if (exp == 2.0) {\n\t\t\t\tfastop = n_ops.square;\n\t\t\t} else {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (inplace) {\n\t\t\t\tPyArray_GenericInplaceUnaryFunction(a1, \n\t\t\t\t\t\t\t\t fastop);\n\t\t\t} else {\n\t\t\t\treturn PyArray_GenericUnaryFunction(a1, \n\t\t\t\t\t\t\t\t fastop);\n\t\t\t}\n\t\t}\n\t}\n\treturn NULL;\n}\n\nstatic PyObject *\narray_power(PyArrayObject *a1, PyObject *o2, PyObject *modulo)\n{\n\t/* modulo is ignored! */\n\tPyObject *value;\n\tvalue = fast_scalar_power(a1, o2, 0);\n\tif (!value) {\n\t\tvalue = PyArray_GenericBinaryFunction(a1, o2, n_ops.power);\n\t}\n\treturn value;\n}\n\n\nstatic PyObject *\narray_negative(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *a1, PyObject *o2, PyObject *modulo)\n{\n /* modulo is ignored! */\n PyObject *value;\n value = fast_scalar_power(a1, o2, 1);\n if (!value) {\n value = PyArray_GenericInplaceBinaryFunction(a1, o2, n_ops.power);\n }\n return value;\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2,\n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2,\n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int\narray_any_nonzero(PyArrayObject *mp)\n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2)\n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_float(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to a \"\\\n\t\t\t\t\"float; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_long(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/\n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected\n*/\n\n\nstatic PyObject *\narray_slice(PyArrayObject *self, _int_or_ssize_t ilow, \n\t _int_or_ssize_t ihigh)\n{\n PyArrayObject *r;\n _int_or_ssize_t l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n self->dimensions[0] = l;\n\tif (r == NULL) return NULL;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS);\n return (PyObject *)r;\n}\n\n\nstatic int\narray_ass_slice(PyArrayObject *self, _int_or_ssize_t ilow, \n\t\t_int_or_ssize_t ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res;\n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\nstatic PySequenceMethods array_as_sequence = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (ssizeargfunc)NULL,\n\t(ssizeargfunc)array_item_nice,\n\t(ssizessizeargfunc)array_slice,\n (ssizeobjargproc)array_ass_item,\t /*sq_ass_item*/\n (ssizessizeobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(ssizeargfunc)NULL,\n#else\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t /*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n#endif\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int\ndump_data(char **string, int *n, int *max_n, char *data, int nd,\n intp *dimensions, intp *strides, PyArrayObject* self)\n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\n if (nd == 0) {\n\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata,\n\t\t self->nd, self->dimensions,\n self->strides, self) < 0) {\n\t\t_pya_free(string); return NULL;\n\t}\n\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void\nPyArray_SetStringFunction(PyObject *op, int repr)\n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction);\n\t\t/* Add a reference to new callback */\n Py_XINCREF(op);\n\t\t/* Remember new callback */\n PyArray_ReprFunction = op;\n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction);\n\t\t/* Add a reference to new callback */\n Py_XINCREF(op);\n\t\t/* Remember new callback */\n PyArray_StrFunction = op;\n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self)\n{\n PyObject *s, *arglist;\n\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist);\n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self)\n{\n PyObject *s, *arglist;\n\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist);\n }\n return s;\n}\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)\n{\n PyObject *array_other, *result;\n\tint typenum;\n\n switch (cmp_op)\n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n\t\t\tif (other == Py_None) {\n\t\t\t\tPy_INCREF(Py_False);\n\t\t\t\treturn Py_False;\n\t\t\t}\n /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\ttypenum = self->descr->type_num;\n\t\t\t\tif (typenum != PyArray_OBJECT) {\n\t\t\t\t\ttypenum = PyArray_NOTYPE;\n\t\t\t\t}\n\t\t\t\tarray_other = PyArray_FromObject(other,\n typenum, 0, 0);\n\t\t\t\t/* If not successful, then return False\n\t\t\t\t This fixes code that used to\n\t\t\t\t allow equality comparisons between arrays\n\t\t\t\t and other objects which would give a result\n\t\t\t\t of False\n\t\t\t\t*/\n\t\t\t\tif ((array_other == NULL) ||\t\\\n\t\t\t\t (array_other == Py_None)) {\n\t\t\t\t\tPy_XDECREF(array_other);\n\t\t\t\t\tPyErr_Clear();\n\t\t\t\t\tPy_INCREF(Py_False);\n\t\t\t\t\treturn Py_False;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPy_INCREF(other);\n\t\t\t\tarray_other = other;\n\t\t\t}\n result = PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t array_other,\n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the\n\t\t\t two array objects can not be compared together so\n\t\t\t return zero\n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n\t\t\tif (other == Py_None) {\n\t\t\t\tPy_INCREF(Py_True);\n\t\t\t\treturn Py_True;\n\t\t\t}\n /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\ttypenum = self->descr->type_num;\n\t\t\t\tif (typenum != PyArray_OBJECT) {\n\t\t\t\t\ttypenum = PyArray_NOTYPE;\n\t\t\t\t}\n\t\t\t\tarray_other = PyArray_FromObject(other,\n typenum, 0, 0);\n\t\t\t\t/* If not successful, then objects cannot be\n\t\t\t\t compared and cannot be equal, therefore,\n\t\t\t\t return True;\n\t\t\t\t*/\n\t\t\t\tif ((array_other == NULL) ||\t\\\n\t\t\t\t (array_other == Py_None)) {\n\t\t\t\t\tPy_XDECREF(array_other);\n\t\t\t\t\tPyErr_Clear();\n\t\t\t\t\tPy_INCREF(Py_True);\n\t\t\t\t\treturn Py_True;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPy_INCREF(other);\n\t\t\t\tarray_other = other;\n\t\t\t}\n\t\t\tresult = PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t array_other,\n\t\t\t\t\t\t\t n_ops.not_equal);\n\t\t\tPy_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t other,\n\t\t\t\t\t\t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\tif (temp) *axis = PyArray_NDIM(temp)-1;\n\t\telse *axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_CheckFromAny((PyObject *)arr, NULL,\n 0, 0, flags, NULL);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; i= SIZEOF_INTP\n\t\tif (!(op = PyNumber_Int(seq))) return -1;\n#else\n\t\tif (!(op = PyNumber_Long(seq))) return -1;\n#endif\n\t\tnd = 1;\n#if SIZEOF_LONG >= SIZEOF_INTP\n\t\tvals[0] = (intp ) PyInt_AsLong(op);\n#else\n\t\tvals[0] = (intp ) PyLong_AsLongLong(op);\n#endif\n\t\tPy_DECREF(op);\n\t} else {\n\t\tfor(i=0; i < MIN(nd,maxvals); i++) {\n\t\t\top = PySequence_GetItem(seq, i);\n\t\t\tif (op == NULL) return -1;\n#if SIZEOF_LONG >= SIZEOF_INTP\n\t\t\tvals[i]=(intp )PyInt_AsLong(op);\n#else\n\t\t\tvals[i]=(intp )PyLong_AsLongLong(op);\n#endif\n\t\t\tPy_DECREF(op);\n\t\t\tif(PyErr_Occurred()) return -1;\n\t\t}\n\t}\n\treturn nd;\n}\n\n\n/* Check whether the given array is stored contiguously (row-wise) in\n memory. */\nstatic int\n_IsContiguous(PyArrayObject *ap)\n{\n\tregister intp sd;\n\tregister intp dim;\n\tregister int i;\n\n\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return (ap->dimensions[0] == 1 || \\\n\t\t\t\t sd == ap->strides[0]);\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\tdim = ap->dimensions[i];\n\t\t/* contiguous by definition */\n\t\tif (dim == 0) return 1;\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= dim;\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsFortranContiguous(PyArrayObject *ap)\n{\n\tregister intp sd;\n\tregister intp dim;\n\tregister int i;\n\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return (ap->dimensions[0] == 1 || \\\n\t\t\t\t sd == ap->strides[0]);\n\tfor (i=0; i< ap->nd; ++i) {\n\t\tdim = ap->dimensions[i];\n\t\t/* contiguous by definition */\n\t\tif (dim == 0) return 1;\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= dim;\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap)\n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object\n\t If it is a writeable array, then return TRUE\n\t If we can find an array object\n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable\n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA))\n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly\n\t and unpickled array can be set and reset writeable\n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t\telse ret->flags &= ~WRITEABLE;\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not\n ever be able to walk outside of the memory implied numbytes and offset.\n\n The available memory is assumed to start at -offset and proceed\n to numbytes-offset. The strides are checked to ensure\n that accessing memory using striding will not try to reach beyond\n this memory for any of the axes.\n\n If numbytes is 0 it will be calculated using the dimensions and\n element-size.\n\n This function checks for walking beyond the beginning and right-end\n of the buffer and therefore works for any integer stride (positive\n or negative).\n*/\n\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, intp offset,\n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\tintp byte_begin;\n\tintp begin;\n\tintp end;\n\n\tif (numbytes == 0)\n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\n\tbegin = -offset;\n\tend = numbytes - offset - elsize;\n\tfor (i=0; i end))\n\t\t\treturn FALSE;\n\t}\n\treturn TRUE;\n\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings\n depending on data and strides:\n\n If data is given, then flags is flags associated with data.\n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument\n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set).\n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired.\n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize,\n\t\t int inflag, int *objflags)\n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\n/* and update the dimensions and strides\n appropriately. Dimensions and strides are added\n to the end unless we have a FORTRAN array\n and then they are added to the beginning\n\n Strides are only added if given (because data is given).\n*/\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims,\n\t\t\t intp *newstrides, int oldnd, int isfortran)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\tint tuple;\n\n\told = *des;\n\t*des = old->subarray->base;\n\n\n\tmydim = newdims + oldnd;\n\ttuple = PyTuple_Check(old->subarray->shape);\n\tif (tuple) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t}\n\telse {\n\t\tnumnew = 1;\n\t}\n\n\n\tnewnd = oldnd + numnew;\n\tif (newnd > MAX_DIMS) goto finish;\n\tif (isfortran) {\n\t\tmemmove(newdims+numnew, newdims, oldnd*sizeof(intp));\n\t\tmydim = newdims;\n\t}\n\n\tif (tuple) {\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\tif (isfortran) {\n\t\t\tmemmove(newstrides+numnew, newstrides,\n\t\t\t\toldnd*sizeof(intp));\n\t\t\tmystrides = newstrides;\n\t\t}\n\t\t/* Make new strides -- alwasy C-contiguous */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\n finish:\n\tPy_INCREF(*des);\n\tPy_DECREF(old);\n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,\n\t\t intp *dims, intp *strides, void *data,\n\t\t int flags, PyObject *obj)\n{\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tint isfortran=0;\n\t\tisfortran = (data && (flags & FORTRAN) && !(flags & CONTIGUOUS)) || \\\n\t\t\t(!data && flags);\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims,\n\t\t\t\t\t\t newstrides, nd, isfortran);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims,\n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { \n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN;\n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse { /* we allow strides even when we create\n\t\t\t the memory, but be careful with this...\n\t\t */\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays\n\t\t e.g. shape=(0,) -- otherwise buffer exposure\n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = descr->elsize;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n /* which could also be sub-fields of a VOID array */\n\t\tif (descr->hasobject) {\n if (descr != &OBJECT_Descr) {\n PyErr_SetString(PyExc_TypeError,\n \"fields with object members \" \\\n \"not yet supported.\");\n goto fail;\n }\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in,\n\t\t\t\t\t this object won't own it\n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for\n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\n /* call the __array_finalize__\n\t method if a subtype.\n\t If obj is NULL, then call method with Py_None \n\t*/\n\tif ((subtype != &PyArray_Type)) {\n\t\tPyObject *res, *func, *args;\n\t\tstatic PyObject *str=NULL;\n\n\t\tif (str == NULL) {\n\t\t\tstr = PyString_InternFromString(\"__array_finalize__\");\n\t\t}\n\t\tif (strides != NULL) { /* did not allocate own data \n\t\t\t\t\t or funny strides */\n\t\t\t/* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tfunc = PyObject_GetAttr((PyObject *)self, str);\n\t\tif (func) {\n\t\t\targs = PyTuple_New(1);\n\t\t\tif (obj == NULL) obj=Py_None;\n\t\t\tPy_INCREF(obj);\n\t\t\tPyTuple_SET_ITEM(args, 0, obj);\n\t\t\tres = PyObject_Call(func, args, NULL);\n\t\t\tPy_DECREF(args);\n\t\t\tPy_DECREF(func);\n\t\t\tif (res == NULL) goto fail;\n\t\t\telse Py_DECREF(res);\n\t\t}\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(self);\n\treturn NULL;\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n If refcheck is 0, then the reference count is not checked\n and assumed to be 1.\n You still must own this data and have no weak-references and no base\n object.\n*/\nstatic PyObject *\nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,\n\t PyArray_ORDER fortran)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\n if (!PyArray_ISONESEGMENT(self)) {\n PyErr_SetString(PyExc_ValueError,\n \"resize only works on single-segment arrays\");\n return NULL;\n }\n\n\tif (fortran == PyArray_ANYORDER)\n\t\tfortran = PyArray_CORDER;\n \n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n oldsize = PyArray_SIZE(self);\n\n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (refcheck) refcnt = REFCOUNT(self);\n\t\telse refcnt = 1;\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (newsize == 0) sd = self->descr->elsize;\n\t\telse sd = newsize * self->descr->elsize;\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, sd);\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError,\n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n\n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) {\n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0,\n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n\n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n\n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError,\n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n self->flags, &(self->flags));\n\n\n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\n return Py_None;\n\n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED, NULL);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\tPyArray_FillWithScalarFunc* fillwithscalar =\n\t\t\tarr->descr->f->fillwithscalar;\n\t\tif (fillwithscalar && PyArray_ISALIGNED(arr)) {\n\t\t\tcopyswap(fromptr, NULL, swap, itemsize);\n\t\t\tfillwithscalar(toptr, size, fromptr, arr);\n\t\t}\n\t\telse {\n\t\t\twhile (size--) {\n\t\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\t\ttoptr += itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", /* XXX ? */\n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"order\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n PyArray_ORDER order=PyArray_CORDER;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL;\n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous\n\t array of a specific type and shape.\n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims,\n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter,\n &strides,\n &PyArray_OrderConverter,\n &order))\n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = 1;\n\n\tif (descr == NULL)\n\t\tdescr = PyArray_DescrFromType(PyArray_LONG);\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"data-type with unspecified variable length\");\n\t\tgoto fail;\n\t}\n\t\n\tif (strides.ptr != NULL) {\n\t\tintp nb, off;\n\t\tif (strides.len != dims.len) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"strides, if given, must be \"\t\\\n\t\t\t\t\t\"the same length as shape\");\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif (buffer.ptr == NULL) {\n\t\t\tnb = 0;\n\t\t\toff = 0;\n\t\t}\n\t\telse {\n\t\t\tnb = buffer.len;\n\t\t\toff = offset;\n\t\t}\n\t\t\n\n\t\tif (!PyArray_CheckStrides(itemsize, dims.len, \n\t\t\t\t\t nb, off,\n\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"strides is incompatible \"\t\\\n\t\t\t\t\t\"with shape of requested \"\t\\\n\t\t\t\t\t\"array and size of buffer\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\t\t\t\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len,\n\t\t\t\t\t dims.ptr,\n\t\t\t\t\t strides.ptr, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = (buffer.len-offset) / itemsize;\n }\n else if ((strides.ptr == NULL) && \\\n\t\t\t buffer.len < itemsize*\t\t\t\t\\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError,\n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t offset + (char *)buffer.ptr,\n\t\t\t\t\t buffer.flags, NULL);\n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base);\n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n\n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyArray_NewFlagsObject((PyObject *)self);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n\tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret),\n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret),\n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes=0;\n\tintp offset=0;\n\tint buf_len;\n\tchar *buf;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base && PyArray_Check(new->base)) {\n\t\tnew = (PyArrayObject *)(new->base);\n\t}\n\t/* Get the available memory through the buffer\n\t interface on new->base or if that fails\n\t from the current new */\n\tif (new->base && PyObject_AsReadBuffer(new->base,\n\t\t\t\t\t (const void **)&buf,\n\t\t\t\t\t &buf_len) >= 0) {\n\t\toffset = self->data - buf;\n\t\tnumbytes = buf_len + offset;\n\t}\n\telse {\n\t\tPyErr_Clear();\n \t\tnumbytes = PyArray_MultiplyList(new->dimensions,\n\t\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\toffset = self->data - new->data;\n\t}\n\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes,\n\t\t\t\t offset,\n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self))\n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self)\n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0,\n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf,\n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse\n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse\n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed.\n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid data-type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the\n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0)\n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n\telse if (newtype->elsize > self->descr->elsize) {\n\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update\n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\t/* We would decref newtype here --- temp will\n\t\t steal a reference to it */\n\t\ttemp = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tif (temp == NULL) return -1;\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tnewtype = temp->descr;\n\t\tPy_INCREF(temp->descr);\n\t\t/* Fool deallocator not to delete these*/\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype;\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"descr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n\n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA);\n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);\n\tif (new == NULL) return -1;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num -\n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type,\n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);\n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new);\n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int\narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode,\n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self), NULL);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr));\n memmove(selfit->dataptr, arrit->dataptr,\n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size)\n PyArray_ITER_RESET(arrit);\n }\n retval = 0;\n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size)\n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\",\n\t (getter)array_ndim_get,\n\t NULL,\n\t \"number of array dimensions\"},\n {\"flags\",\n\t (getter)array_flags_get,\n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\",\n\t (getter)array_shape_get,\n\t (setter)array_shape_set,\n\t \"tuple of array dimensions\"},\n {\"strides\",\n\t (getter)array_strides_get,\n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)array_data_get,\n\t (setter)array_data_set,\n\t \"pointer to start of data\"},\n {\"itemsize\",\n\t (getter)array_itemsize_get,\n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n\t{\"dtype\",\n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\",\n\t (getter)array_real_get,\n\t (setter)array_real_set,\n\t \"real part of array\"},\n {\"imag\",\n\t (getter)array_imag_get,\n\t (setter)array_imag_set,\n\t \"imaginary part of array\"},\n\t{\"flat\",\n\t (getter)array_flat_get,\n\t (setter)array_flat_set,\n\t \"a 1-d view of a contiguous array\"},\n\t{\"__array_data__\",\n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\",\n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n\t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */\n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] =\n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the numpy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the numpy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=int_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a numpy.dtype object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\nstatic PyTypeObject PyArray_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0,\t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n &array_as_sequence,\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str,\t /*tp_str*/\n\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n &array_as_buffer, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT\n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t /*tp_richcompare */\n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter,\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n array_alloc,\t /* tp_alloc */\n (newfunc)array_new,\t\t /* tp_new */\n _pya_free,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int\ndiscover_depth(PyObject *s, int max, int stop_at_string, int stop_at_tuple)\n{\n int d=0;\n PyObject *e;\n\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif (stop_at_tuple && PyTuple_Check(s)) return 0;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0)\n\t\treturn 1;\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string, stop_at_tuple);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize)\n{\n\tint n, r, i;\n\tPyObject *e;\n\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s)\n\t\t\t*itemsize = MAX(*itemsize, 4*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype ---\n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately\n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE &&\n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 4*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\nstatic PyArray_Descr *\n_array_find_python_scalar_type(PyObject *op)\n{\n if (PyFloat_Check(op)) {\n return PyArray_DescrFromType(PyArray_DOUBLE);\n } else if (PyComplex_Check(op)) {\n return PyArray_DescrFromType(PyArray_CDOUBLE);\n } else if (PyInt_Check(op)) {\n /* bools are a subclass of int */\n if (PyBool_Check(op)) {\n return PyArray_DescrFromType(PyArray_BOOL);\n } else {\n return PyArray_DescrFromType(PyArray_LONG);\n }\n } else if (PyLong_Check(op)) {\n /* if integer can fit into a longlong then return that\n */\n if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) {\n PyErr_Clear();\n return PyArray_DescrFromType(PyArray_OBJECT);\n }\n return PyArray_DescrFromType(PyArray_LONGLONG);\n }\n return NULL;\n}\n\n/* op is an object to be converted to an ndarray.\n\n minitype is the minimum type-descriptor needed.\n\n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n\n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\n\tif (minitype == NULL)\n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\n if (max < 0) goto deflt;\n\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n chktype = _array_find_python_scalar_type(op);\n if (chktype) {\n goto finish;\n }\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n\n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind,\n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n#ifndef Py_UNICODE_WIDE\n\t\tchktype->elsize <<= 1;\n#endif\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n }\n\n\tif (PyInstance_Check(op)) goto deflt;\n\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) {\n\t\t\tPyErr_Clear();\n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\n finish:\n\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype;\n}\n\nstatic int\nAssign_Array(PyArrayObject *self, PyObject *v)\n{\n PyObject *e;\n int l, r;\n\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\n l=PyObject_Length(v);\n if(l < 0) return -1;\n\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1;\n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */\n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode)\n{\n PyArrayObject *ret;\n\tint itemsize;\n\tint type;\n\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= 4;\n\n\t\tif (itemsize != typecode->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(typecode);\n\t\t\ttypecode->elsize = itemsize;\n\t\t}\n\t}\n\n ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL,\n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\tif (ret == NULL) return NULL;\n\tif (ret->nd > 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"shape-mismatch on array construction\");\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\n ret->descr->f->setitem(op, ret->data, ret);\n\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode */\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran,\n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint stop_at_tuple;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n\tstop_at_tuple = (type == PyArray_VOID && ((typecode->fields &&\t\\\n\t\t\t\t\t\t typecode->fields!=Py_None) \\\n\t\t\t\t\t\t || (typecode->subarray)));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string,\n\t\t\t\t stop_at_tuple)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"invalid input sequence\");\n\t\tgoto fail;\n }\n\n\tif (max_depth && PyTypeNum_ISOBJECT(type) && (nd > max_depth)) {\n\t\tnd = max_depth;\n\t}\n\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"invalid number of dimensions\");\n\t\tgoto fail;\n }\n\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) goto fail;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) goto fail;\n\t\tif (type == PyArray_UNICODE) itemsize*=4;\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n\n fail:\n\tPy_DECREF(typecode);\n\treturn NULL;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int\nPyArray_ValidType(int type)\n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in))\n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject *\nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize << 2;\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING)\n\t\t\tat->elsize = mpd->elsize >> 2;\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd,\n\t\t\t\t mp->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\n}\n\n/* The number of elements in out must be an integer multiple\n of the number of elements in mp.\n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1;\n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * mpsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr,\n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)\n{\n\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif ((flags & ENSURECOPY) || PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) && (!(arrflags & FORTRAN)))) \\\n\t\t\t|| ((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1)\n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse {\n if ((flags & ENSUREARRAY)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype,\n\t\t\t\t\t\t newtype,\n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr;\n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\n\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short))\n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong))\n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char))\n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short))\n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long))\n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t break;\n\tcase PyArray_STRINGLTR:\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase PyArray_UNICODELTR:\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize <<= 2;\n\t\tbreak;\n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap)\n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* OBJECT_API */\nstatic PyObject *\nPyArray_FromStructInterface(PyObject *input)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r;\n\tchar endian = PyArray_NATBYTE;\n\n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n return r;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromInterface(PyObject *input)\n{\n\tPyObject *attr=NULL, *item=NULL;\n PyObject *tstr=NULL, *shape=NULL;\n PyArrayObject *ret;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data,\n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr));\n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n\n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\treturn (PyObject *)ret;\n\n fail:\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* OBJECT_API*/\nstatic PyObject *\nPyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject *context)\n{\n PyObject *new;\n PyObject *array_meth;\n\n array_meth = PyObject_GetAttrString(op, \"__array__\");\n if (array_meth == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n if (context == NULL) {\n if (typecode == NULL) new = PyObject_CallFunction(array_meth, \n\t\t\t\t\t\t\t\t NULL);\n else new = PyObject_CallFunction(array_meth, \"O\", typecode);\n }\n else {\n if (typecode == NULL) {\n new = PyObject_CallFunction(array_meth, \"OO\", Py_None,\n\t\t\t\t\t\t context);\n if (new == NULL && \\\n\t\t\t PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", \n\t\t\t\t\t\t typecode, context);\n if (new == NULL && \\\n\t\t\t PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", \n\t\t\t\t\t\t\t typecode);\n }\n }\n }\n Py_DECREF(array_meth);\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError,\n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n return NULL;\n }\n return new;\n}\n\n/* Does not check for ENSURECOPY and NOTSWAPPED in flags */\n/* Steals a reference to newtype --- which can be NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth,\n int max_depth, int flags, PyObject *context)\n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op))\n\t\tr = PyArray_FromArray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t} else if (newtype == NULL &&\n (newtype = _array_find_python_scalar_type(op))) {\n r = Array_FromScalar(op, newtype);\n }\n else if (((r = PyArray_FromStructInterface(op))!=Py_NotImplemented)|| \\\n ((r = PyArray_FromInterface(op)) != Py_NotImplemented) || \\\n ((r = PyArray_FromArrayAttr(op, newtype, context)) \\\n != Py_NotImplemented)) {\n PyObject *new;\n if (r == NULL) return NULL;\n if (newtype != NULL || flags != 0) {\n new = PyArray_FromArray((PyArrayObject *)r, newtype, \n\t\t\t\t\t\tflags);\n Py_DECREF(r);\n r = new;\n }\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\n\t\t\tPy_INCREF(newtype);\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL) {\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n\t\t\t\tPyErr_Clear();\n\t\t\t}\n else {\n\t\t\t\tseq = TRUE;\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t}\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\n\t/* Be sure we succeed here */\n\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"internal error: PyArray_FromAny \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError,\n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError,\n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int\nPyArray_ObjectType(PyObject *op, int minimum_type)\n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of\n CONTIGUOUS,\n FORTRAN,\n ALIGNED,\n WRITEABLE,\n NOTSWAPPED,\n ENSURECOPY,\n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should\n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or\n not it has such features.\n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well.\n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n\n FORTRAN can be set in the FLAGS to request a FORTRAN array.\n Fortran arrays are always behaved (aligned,\n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d).\n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array.\n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe.\n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth,\n int max_depth, int requires, PyObject *context)\n{\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn PyArray_FromAny(op, descr, min_depth, max_depth,\n requires, context);\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0,\n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place\n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, ENSUREARRAY, NULL);\n Py_DECREF(op);\n return new;\n}\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int\nPyArray_CanCastSafely(int fromtype, int totype)\n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype))\n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize << 2 \\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode\n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\n\t\t*/\n\t}\n\treturn ret;\n}\n\n/*OBJECT_API\n See if array scalars can be cast.\n */\nstatic Bool\nPyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)\n{\n\tint fromtype;\n\tint totype;\n\n\tfromtype = _typenum_fromtypeobj((PyObject *)from, 0);\n\ttotype = _typenum_fromtypeobj((PyObject *)to, 0);\n\tif (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE) \n\t\treturn FALSE;\n\treturn (Bool) PyArray_CanCastSafely(fromtype, totype);\t\n}\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and numpy's arraymap ****/\n/* and Python's array iterator ***/\n\n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd;\n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\n return (PyObject *)it;\n}\n\n\n/*OBJECT_API\n Get Iterator that iterates over all but one axis (don't use this with\n PyArray_ITER_GOTO1D)\n*/\nstatic PyObject *\nPyArray_IterAllButAxis(PyObject *obj, int axis)\n{\n\tPyArrayIterObject *it;\n\tit = (PyArrayIterObject *)PyArray_IterNew(obj);\n\tif (it == NULL) return NULL;\n\n\t/* adjust so that will not iterate over axis */\n\tit->contiguous = 0;\n\tif (it->size != 0) {\n\t\tit->size /= PyArray_DIM(obj,axis);\n\t}\n\tit->dims_m1[axis] = 0;\n\tit->backstrides[axis] = 0;\n\n\t/* (won't fix factors so don't use\n\t PyArray_ITER_GOTO1D with this iterator) */\n\treturn (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic _int_or_ssize_t\niter_length(PyArrayIterObject *self)\n{\n return self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count,\n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr,\n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num,\n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\tif (PyTuple_Check(ind)) {\n\t\tint len;\n\t\tlen = PyTuple_GET_SIZE(ind);\n\t\tif (len > 1) goto fail;\n\t\tind = PyTuple_GET_ITEM(ind, 0);\n\t}\n\n\t/* Tuples >1d not accepted --- i.e. no newaxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps,\n\t\t\t\t self->size);\n\t\tif (start == -1)\n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"cannot use Ellipsis or newaxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t 1, &n_steps,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail;\n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tstart += step_size;\n\t\t\tPyArray_ITER_GOTO1D(self, start)\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (obj == NULL) goto fail;\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t}\n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0,\n FORCECAST | ALIGNED, NULL);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\n fail:\n\tif (!PyErr_Occurred())\n\t\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n\t\t\t\t itemsize);\n\t\t\tPyArray_ITER_NEXT(val);\n\t\t\tif (val->index==val->size)\n\t\t\t\tPyArray_ITER_RESET(val);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num,\n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size)\n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)\n{\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tretval = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn retval;\n\t}\n\n\tif (PyTuple_Check(ind)) {\n\t\tint len;\n\t\tlen = PyTuple_GET_SIZE(ind);\n\t\tif (len > 1) goto finish;\n\t\tind = PyTuple_GET_ITEM(ind, 0);\n\t}\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0, NULL);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps,\n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"cannot use Ellipsis or newaxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tstart += step_size;\n\t\t\tPyArray_ITER_GOTO1D(self, start)\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size)\n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t}\n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST, NULL);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_CheckFromAny(obj, indtype, 0, 0,\n FORCECAST | BEHAVED_NS_FLAGS, NULL);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)iter_length,\t\t /*mp_length*/\n#else\n (inquiry)iter_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op)\n{\n\n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options:\n 1) underlying array is contiguous\n -- return 1-d wrapper around it\n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type,\n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size,\n\t\t\t\t\t NULL, it->ao->data,\n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type,\n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r);\n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n\n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n {\"index\", T_INT, offsetof(PyArrayIterObject, index), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\niter_coords_get(PyArrayIterObject *self)\n{\n int nd;\n nd = self->ao->nd;\n if (self->contiguous) { /* coordinates not kept track of --- need to generate\n from index */\n intp val;\n int i;\n val = self->index;\n for (i=0;icoordinates[i] = val / self->factors[i];\n val = val % self->factors[i];\n }\n }\n return PyArray_IntTupleFromIntp(nd, self->coordinates);\n}\n\nstatic PyGetSetDef iter_getsets[] = {\n\t{\"coords\",\n\t (getter)iter_coords_get,\n\t NULL,\n\t \"An N-d tuple of current coordinates.\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &iter_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t\t /* tp_members */\n iter_getsets, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular\n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators\n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++)\n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already\n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1)\n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of\n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord,\n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so,\n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size.\n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere.\n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well.\n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\n\t/* no subspace iteration needed. Finish up and Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0\n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t/* But, be sure to do it with a true array.\n\t */\n\tif (PyArray_CheckExact(arr)) {\n\t\tsub = array_subscript(arr, mit->indexobj);\n\t}\n\telse {\n\t\tPy_INCREF(arr);\n\t\tobj = PyArray_EnsureArray((PyObject *)arr);\n\t\tif (obj == NULL) goto fail;\n\t\tsub = array_subscript((PyArrayObject *)obj, mit->indexobj);\n\t\tPy_DECREF(obj);\n\t}\n\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects\n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been\n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj))\n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj,\n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1;\n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1),\n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0,\n\t\t\t\t\t CARRAY_FLAGS, NULL);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n\tmit->index = 0;\n\tmit->ait = NULL;\n\tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY\n#undef SOBJ_ISFANCY\n#undef SOBJ_BADARRAY\n#undef SOBJ_TOOMANY\n#undef SOBJ_LISTTUP\n\n\tif (oned) return (PyObject *)mit;\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple\n\t (with at least 1 list or arrayobject or Bool object), */\n\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i,\n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing\n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n return (PyObject *)mit;\n\n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently that does not work.\n Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a);\n mapiter is equivalent to a[indexobj].flat but the latter gets to use\n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.mapiter\",\t\t\t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t\t /* tp_iter */\n (iternextfunc)0,\t /* tp_iternext */\n 0,\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\n\tint i, err=0;\n\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\n\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\n\tPyArray_MultiIter_RESET(multi);\n\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL)\n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\n return (PyObject *)multi;\n\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i,\n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\",\n\t (getter)arraymultiter_size_get,\n\t NULL,\n\t \"total size of broadcasted result\"},\n {\"index\",\n\t (getter)arraymultiter_index_get,\n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter),\n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.broadcast\",\t\t\t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods,\t /* tp_methods */\n arraymultiter_members,\t\t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types.\n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these\n builtins will be attempted leading to problems.\n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically\n allocated).\n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray,\n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless\n there is a reference-count problem\n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free((PyObject *)self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtype objects can be set.\n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"type\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"kind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"char\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"num\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n {\"hasobject\", T_UBYTE, offsetof(PyArray_Descr, hasobject), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base,\n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n char basic_=self->kind;\n char endian = self->byteorder;\n\tint size=self->elsize;\n\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n\tif (self->type_num == PyArray_UNICODE) {\n\t\tsize >>= 2;\n\t}\n return PyString_FromFormat(\"%c%c%d\", endian, basic_, size);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\tstatic int suffix_len=0;\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tif (suffix_len == 0)\n\t\t\tsuffix_len = strlen(\"scalar\");\n\t\tlen = strlen(typeobj->tp_name) - suffix_len;\n\t\tres = PyString_FromStringAndSize(typeobj->tp_name, len);\n\t}\n\tif (PyTypeNum_ISEXTENDED(self->type_num) && self->elsize != 0) {\n\t\tPyObject *p;\n\t\tp = PyString_FromFormat(\"%d\", self->elsize * 8);\n\t\tPyString_ConcatAndDel(&res, p);\n\t}\n\treturn res;\n}\n\nstatic PyObject *\narraydescr_base_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(self);\n return (PyObject *)self;\n\t}\n Py_INCREF(self->subarray->base);\n return (PyObject *)(self->subarray->base);\n}\n\nstatic PyObject *\narraydescr_shape_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n return Py_BuildValue(\"(N)\", PyInt_FromLong(1));\n\t}\n Py_INCREF(self->subarray->shape);\n return (PyObject *)(self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_numpy_internal, \"_array_descr\",\n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self)\n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyObject *\narraydescr_fields_get(PyArray_Descr *self)\n{\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyDictProxy_New(self->fields);\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdtype\",\n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"descr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"str\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n {\"name\",\n (getter)arraydescr_typename_get,\n NULL,\n \"The name of the true data-type\"},\n\t{\"base\",\n\t (getter)arraydescr_base_get,\n\t NULL,\n\t \"The base data-type or self if no subdtype\"},\n {\"shape\",\n (getter)arraydescr_shape_get,\n NULL,\n \"The shape of the subdtype or (1,)\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{\"fields\",\n\t (getter)arraydescr_fields_get,\n\t NULL,\n\t NULL},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\tstatic char *kwlist[] = {\"dtype\", \"align\", \"copy\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\",\n\t\t\t\t\t kwlist, &odescr, &align,\n\t\t\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr)\n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr)\n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv))\n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"numpy.core.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtype\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\telsize = self->elsize;\n\t\tif (self->type_num == PyArray_UNICODE) {\n\t\t\telsize >>= 2;\n\t\t}\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\n\t/* Now return the state which is at least\n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize\n and alignment for EXTENDED arrays\n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\n\tif (endian != '|' && \n\t PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are:\n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtype object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtype object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args)\n{\n\tchar endian=PyArray_SWAP;\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS,\n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_str(PyArray_Descr *self)\n{\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) {\n\t\t\tsub = PyString_FromString(\"\");\n\t\t\tPyErr_Clear();\n\t\t}\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse if (self->subarray) {\n\t\tPyObject *p;\n\t\tPyObject *t = PyString_FromString(\"(\");\n\t\tp = arraydescr_str(self->subarray->base);\n\t\tPyString_ConcatAndDel(&t, p);\n\t\tPyString_ConcatAndDel(&t, PyString_FromString(\",\"));\n\t\tPyString_ConcatAndDel(&t, PyObject_Str(self->subarray->shape));\n\t\tPyString_ConcatAndDel(&t, PyString_FromString(\")\"));\n\t\tsub = t;\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\treturn sub;\n}\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *sub, *s;\n\ts = PyString_FromString(\"dtype(\");\n sub = arraydescr_str(self);\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic int\narraydescr_compare(PyArray_Descr *self, PyObject *other)\n{\n\tif (!PyArray_DescrCheck(other)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"not a dtype object.\");\n\t\treturn -1;\n\t}\n\tif (PyArray_EquivTypes(self, (PyArray_Descr *)other)) return 0;\n\tif (PyArray_CanCastTo(self, (PyArray_Descr *)other)) return -1;\n\treturn 1;\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic _int_or_ssize_t\ndescr_length(PyArray_Descr *self)\n{\n\n\tif (self->fields && self->fields != Py_None)\n\t\t/* Remove the last entry (root) */\n\t\treturn PyDict_Size(self->fields) - 1;\n\telse return 0;\n}\n\nstatic PyObject *\ndescr_subscript(PyArray_Descr *self, PyObject *op)\n{\n\n\tif (self->fields) {\n\t\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyObject *descr;\n\t\t\t\tdescr = PyTuple_GET_ITEM(obj, 0);\n\t\t\t\tPy_INCREF(descr);\n\t\t\t\treturn descr;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPyErr_Format(PyExc_KeyError,\n\t\t\t\t\t \"field named \\'%s\\' not found.\",\n\t\t\t\t\t PyString_AsString(op));\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t PyErr_SetString(PyExc_ValueError,\n\t\t\t\t \"only strings or unicode values allowed \" \\\n\t\t\t\t \"for getting fields.\");\n\t\t}\n\t}\n\telse {\n\t\tPyErr_Format(PyExc_KeyError,\n\t\t\t \"there are no fields in dtype %s.\",\n\t\t\t PyString_AsString(arraydescr_str(self)));\n\t}\n\treturn NULL;\n}\n\nstatic PyMappingMethods descr_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)descr_length,\t\t /*mp_length*/\n#else\n (inquiry)descr_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)descr_subscript,\t /*mp_subscript*/\n (objobjargproc)NULL,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.dtype\",\t\t\t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n\t(cmpfunc)arraydescr_compare,\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &descr_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_str, /* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n 0,\t\t/* tp_iternext */\n arraydescr_methods,\t\t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n\n/** Array Flags Object **/\n\ntypedef struct PyArrayFlagsObject {\n PyObject_HEAD\n PyObject *arr;\n int flags;\n} PyArrayFlagsObject;\n\n/*OBJECT_API\n Get New ArrayFlagsObject\n*/\nstatic PyObject *\nPyArray_NewFlagsObject(PyObject *obj)\n{\n PyObject *flagobj;\n int flags;\n if (obj == NULL) {\n flags = CONTIGUOUS | OWNDATA | FORTRAN | ALIGNED;\n }\n else {\n flags = PyArray_FLAGS(obj);\n }\n flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0);\n if (flagobj == NULL) return NULL;\n Py_XINCREF(obj);\n ((PyArrayFlagsObject *)flagobj)->arr = obj;\n ((PyArrayFlagsObject *)flagobj)->flags = flags;\n\n return flagobj;\n}\n\nstatic void\narrayflags_dealloc(PyArrayFlagsObject *self)\n{\n\tPy_XDECREF(self->arr);\n\tself->ob_type->tp_free((PyObject *)self);\n}\n\n\n#define _define_get(UPPER, lower) \\\nstatic PyObject * \\\narrayflags_ ## lower ## _get(PyArrayFlagsObject *self) \\\n{ \\\n PyObject *item; \\\n item = ((self->flags & (UPPER)) == (UPPER)) ? Py_True : Py_False; \\\n Py_INCREF(item); \\\n return item; \\\n}\n\n_define_get(CONTIGUOUS, contiguous)\n_define_get(FORTRAN, fortran)\n_define_get(UPDATEIFCOPY, updateifcopy)\n_define_get(OWNDATA, owndata)\n_define_get(ALIGNED, aligned)\n_define_get(WRITEABLE, writeable)\n\n_define_get(ALIGNED|WRITEABLE, behaved)\n_define_get(ALIGNED|WRITEABLE|CONTIGUOUS, carray)\n\nstatic PyObject *\narrayflags_forc_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & FORTRAN) == FORTRAN) ||\n ((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_fnc_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & FORTRAN) == FORTRAN) &&\n !((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_farray_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & (ALIGNED|WRITEABLE|FORTRAN)) == \\\n (ALIGNED|WRITEABLE|FORTRAN)) &&\n !((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_num_get(PyArrayFlagsObject *self)\n{\n return PyInt_FromLong(self->flags);\n}\n\n/* relies on setflags order being write, align, uic */\nstatic int\narrayflags_updateifcopy_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", Py_None, Py_None, \n (PyObject_IsTrue(obj) ? Py_True : Py_False));\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\nstatic int\narrayflags_aligned_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", Py_None, \n (PyObject_IsTrue(obj) ? Py_True : Py_False),\n Py_None);\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\nstatic int\narrayflags_writeable_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", \n (PyObject_IsTrue(obj) ? Py_True : Py_False),\n Py_None, Py_None);\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\n\nstatic PyGetSetDef arrayflags_getsets[] = {\n\t{\"contiguous\",\n\t (getter)arrayflags_contiguous_get,\n\t NULL,\n\t \"\"},\n {\"fortran\",\n (getter)arrayflags_fortran_get,\n NULL,\n \"\"},\n {\"updateifcopy\",\n (getter)arrayflags_updateifcopy_get,\n (setter)arrayflags_updateifcopy_set,\n \"\"},\n {\"owndata\",\n (getter)arrayflags_owndata_get,\n NULL,\n \"\"},\n {\"aligned\",\n (getter)arrayflags_aligned_get,\n (setter)arrayflags_aligned_set,\n \"\"},\n {\"writeable\",\n (getter)arrayflags_writeable_get,\n (setter)arrayflags_writeable_set,\n \"\"},\n {\"fnc\",\n (getter)arrayflags_fnc_get,\n NULL,\n \"\"},\n {\"forc\",\n (getter)arrayflags_forc_get,\n NULL,\n \"\"},\n {\"behaved\",\n (getter)arrayflags_behaved_get,\n NULL,\n \"\"},\n {\"carray\",\n (getter)arrayflags_carray_get,\n NULL,\n \"\"},\n {\"farray\",\n (getter)arrayflags_farray_get,\n NULL,\n \"\"},\n {\"num\",\n (getter)arrayflags_num_get,\n NULL,\n \"\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyObject *\narrayflags_getitem(PyArrayFlagsObject *self, PyObject *ind)\n{\n char *key;\n int n;\n if (!PyString_Check(ind)) goto fail;\n key = PyString_AS_STRING(ind);\n n = PyString_GET_SIZE(ind);\n\tswitch(n) {\n\tcase 1:\n\t\tswitch(key[0]) {\n\t\tcase 'C':\n\t\t\treturn arrayflags_contiguous_get(self);\n\t\tcase 'F':\n\t\t\treturn arrayflags_fortran_get(self);\n\t\tcase 'W':\n\t\t\treturn arrayflags_writeable_get(self);\n\t\tcase 'B':\n\t\t\treturn arrayflags_behaved_get(self);\n\t\tcase 'O':\n\t\t\treturn arrayflags_owndata_get(self);\n\t\tcase 'A':\n\t\t\treturn arrayflags_aligned_get(self);\n\t\tcase 'U':\n\t\t\treturn arrayflags_updateifcopy_get(self);\n\t\tdefault:\n\t\t\tgoto fail;\n\t\t}\n\t\tbreak;\n\tcase 2:\n\t\tif (strncmp(key, \"CA\", n)==0)\n\t\t\treturn arrayflags_carray_get(self);\n\t\tif (strncmp(key, \"FA\", n)==0)\n\t\t\treturn arrayflags_farray_get(self);\n\t\tbreak;\n\tcase 3:\n\t\tif (strncmp(key, \"FNC\", n)==0)\n\t\t\treturn arrayflags_fnc_get(self);\n\t\tbreak;\n\tcase 4:\n\t\tif (strncmp(key, \"FORC\", n)==0)\n\t\t\treturn arrayflags_forc_get(self);\n\t\tbreak;\n\tcase 6:\n\t\tif (strncmp(key, \"CARRAY\", n)==0)\n\t\t\treturn arrayflags_carray_get(self);\n\t\tif (strncmp(key, \"FARRAY\", n)==0)\n\t\t\treturn arrayflags_farray_get(self);\n\t\tbreak;\n\tcase 7:\n\t\tif (strncmp(key,\"FORTRAN\",n)==0)\n\t\t\treturn arrayflags_fortran_get(self);\n\t\tif (strncmp(key,\"BEHAVED\",n)==0)\n\t\t\treturn arrayflags_behaved_get(self);\n\t\tif (strncmp(key,\"OWNDATA\",n)==0)\n\t\t\treturn arrayflags_owndata_get(self);\n\t\tif (strncmp(key,\"ALIGNED\",n)==0)\n\t\t\treturn arrayflags_aligned_get(self);\n\t\tbreak;\n\tcase 9:\t\n\t\tif (strncmp(key,\"WRITEABLE\",n)==0)\n\t\t\treturn arrayflags_writeable_get(self);\n\t\tbreak;\n\tcase 10:\n\t\tif (strncmp(key,\"CONTIGUOUS\",n)==0)\n\t\t\treturn arrayflags_contiguous_get(self);\n\t\tbreak;\n\tcase 12:\n\t\tif (strncmp(key, \"UPDATEIFCOPY\", n)==0)\n\t\t\treturn arrayflags_updateifcopy_get(self);\n\t\tbreak;\n\t}\n\n fail:\n PyErr_SetString(PyExc_KeyError, \"Unknown flag\");\n return NULL;\n}\n\nstatic int\narrayflags_setitem(PyArrayFlagsObject *self, PyObject *ind, PyObject *item)\n{ \n char *key;\n int n;\n if (!PyString_Check(ind)) goto fail;\n key = PyString_AS_STRING(ind);\n n = PyString_GET_SIZE(ind);\n if (((n==9) && (strncmp(key, \"WRITEABLE\", n)==0)) ||\n\t ((n==1) && (strncmp(key, \"W\", n)==0)))\n return arrayflags_writeable_set(self, item);\n else if (((n==7) && (strncmp(key, \"ALIGNED\", n)==0)) || \n ((n==1) && (strncmp(key, \"A\", n)==0)))\n return arrayflags_aligned_set(self, item);\n else if (((n==12) && (strncmp(key, \"UPDATEIFCOPY\", n)==0)) ||\n ((n==1) && (strncmp(key, \"U\", n)==0)))\n return arrayflags_updateifcopy_set(self, item); \n\nfail:\n PyErr_SetString(PyExc_KeyError, \"Unknown flag\");\n return -1;\n}\n\nstatic char *\n_torf_(int flags, int val)\n{\n if ((flags & val) == val) return \"True\";\n else return \"False\"; \n}\n\nstatic PyObject *\narrayflags_print(PyArrayFlagsObject *self)\n{\n int fl = self->flags;\n \n return PyString_FromFormat(\" %s : %s\\n %s : %s\\n %s : %s\\n\"\\\n \" %s : %s\\n %s : %s\\n %s : %s\",\n \"CONTIGUOUS\", _torf_(fl, CONTIGUOUS),\n \"FORTRAN\", _torf_(fl, FORTRAN),\n \"OWNDATA\", _torf_(fl, OWNDATA),\n \"WRITEABLE\", _torf_(fl, WRITEABLE),\n \"ALIGNED\", _torf_(fl, ALIGNED),\n \"UPDATEIFCOPY\", _torf_(fl, UPDATEIFCOPY));\n}\n\n\nstatic PyMappingMethods arrayflags_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)NULL, \t\t /*mp_length*/\n#else\n (inquiry)NULL, \t\t /*mp_length*/\n#endif\n (binaryfunc)arrayflags_getitem,\t /*mp_subscript*/\n (objobjargproc)arrayflags_setitem, /*mp_ass_subscript*/\n};\n\n\nstatic PyObject *\narrayflags_new(PyTypeObject *self, PyObject *args, PyObject *kwds)\n{\n PyObject *arg=NULL;\n if (!PyArg_UnpackTuple(args, \"flagsobj\", 0, 1, &arg))\n return NULL;\n\n if ((arg != NULL) && PyArray_Check(arg)) {\n return PyArray_NewFlagsObject(arg);\n }\n else {\n return PyArray_NewFlagsObject(NULL);\n }\n}\n\nstatic PyTypeObject PyArrayFlags_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\n \"numpy.flagsobj\",\n sizeof(PyArrayFlagsObject),\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayflags_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n\t0,\t\t /* tp_compare */\n (reprfunc)arrayflags_print, /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &arrayflags_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arrayflags_print, /* tp_str */\n 0,\t \t /* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n 0,\t\t /* tp_iternext */\n 0,\t \t /* tp_methods */\n 0,\t /* tp_members */\n arrayflags_getsets, /* tp_getset */\n 0,\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t /* tp_init */\n 0,\t /* tp_alloc */\n arrayflags_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "source_code_before": "/*\n Provide multidimensional arrays as a basic object type in python.\n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004\n\nHeavily modified in 2005 with inspiration from Numarray\n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University\n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by\nSpace Science Telescope Institute\n (J. Todd Miller, Perry Greenfield, Rick White)\n*/\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_)\n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear();\n priority = default_;\n }\n Py_XDECREF(ret);\n return priority;\n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a\n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n }\n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int\ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides,\n\t intp *src_dimensions, int src_nd, int elsize,\n\t int copies) {\n intp i, j;\n\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1,\n dest_dimensions+1, dest_nd-1,\n src, src_strides,\n src_dimensions, src_nd,\n elsize, copies) == -1)\n return -1;\n }\n return 0;\n }\n\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError,\n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) &&\n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] !=\n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src)\n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\n dest_strides_ptr = dest_strides;\n\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1)\n return NULL;\n\n new_data = (char *)_pya_malloc(stride);\n\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions,\n dest_nd, src->data, src_strides,\n src_dimensions, src_nd, elsize, copies);\n\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *,\n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int\nPyArray_INCREF(PyArrayObject *mp)\n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL)\n return -1;\n }\n\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL)\n return -1;\n }\n\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap)\n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n\n\n if ((numitems == 1) || (itemsize == srcstrides))\n memcpy(d1, s1, itemsize*numitems);\n else {\n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n }\n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\n\n#ifndef Py_UNICODE_WIDE\n#include \"ucsnarrow.c\"\n#endif\n\n\nstatic PyArray_Descr **userdescrs=NULL;\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\n\n/* Helper functions */\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t\tgoto finish;\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t\tgoto finish;\n\t}\n\n#if SIZEOF_INTP == SIZEOF_LONG\n\tdescr = &LONG_Descr;\n#elif SIZEOF_INTP == SIZEOF_INT\n\tdescr = &INT_Descr;\n#else\n\tdescr = &LONGLONG_DESCR;\n#endif\n\tarr = NULL;\n\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\tif (o->ob_type->tp_as_number != NULL &&\t\t\t\\\n\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n#if (SIZEOF_LONGLONG > SIZEOF_INTP)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t\tgoto finish;\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t\tgoto finish;\n\t}\n\n\tdescr = &INT_Descr;\n\tarr=NULL;\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tPy_INCREF(descr);\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\tif (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t}\n\telse if (o->ob_type->tp_as_number != NULL &&\t\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\n#if (SIZEOF_LONG > SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i)\n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp\nPyArray_Size(PyObject *op)\n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n }\n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src\n will be cast to destination.\n*/\n\n/* Does a flat iterator-based copy.\n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however.\n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n\n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError,\n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError,\n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n\n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n }\n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int\nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)\n{\n PyArrayObject *src;\n int ret;\n\t\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n dest->descr, 0,\n dest->nd, FORTRAN_IF(dest), NULL);\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d,\n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n#endif\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\n#if SIZEOF_INTP != SIZEOF_INT\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t} \n\treturn ret;\n}\n\n/* end old calls */\n\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, PyArray_ORDER fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(m1);\n \n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type,\n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd,\n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran,\n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\n return (PyObject *)ret;\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj;\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\tif (type_num == PyArray_BOOL)\n\t\tPyArrayScalar_RETURN_BOOL_FROM_LONG(*(Bool*)data);\n\telse if (type_num == PyArray_OBJECT) {\n\t\tPy_INCREF(*((PyObject **)data));\n\t\treturn *((PyObject **)data);\n\t}\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) {\n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED;\n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize >> 2;\n#ifndef Py_UNICODE_WIDE\n\t\t\tchar *buffer;\n\t\t\tint alloc=0;\n\t\t\tlength *= 2;\n#endif\n\t\t\t/* Need an extra slot and need to use\n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n#ifndef Py_UNICODE_WIDE\n\t\t\t/* need aligned data buffer */\n\t\t\tif (!PyArray_ISBEHAVED(base)) {\n\t\t\t\tbuffer = _pya_malloc(itemsize);\n\t\t\t\tif (buffer == NULL)\n\t\t\t\t\treturn PyErr_NoMemory();\n\t\t\t\talloc = 1;\n\t\t\t\tmemcpy(buffer, data, itemsize);\n\t\t\t\tif (!PyArray_ISNOTSWAPPED(base)) {\n\t\t\t\t\tbyte_swap_vector(buffer, itemsize >> 2, 4);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse buffer = data;\n\n /* Allocated enough for 2-characters per itemsize.\n\t\t\t Now convert from the data-buffer\n */\n\t\t\tlength = PyUCS2Buffer_FromUCS4(uni->str, (PyArray_UCS4 *)buffer,\n\t\t\t\t\t\t itemsize >> 2);\n\t\t\tif (alloc) _pya_free(buffer);\n\t\t\t/* Resize the unicode result */\n\t\t\tif (MyPyUnicode_Resize(uni, length) < 0) {\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treturn obj;\n#endif\n\t\t}\n\t\telse {\n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (descr->fields) {\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this.\n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag\n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp)\n{\n\n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (!PyArray_Check(mp)) return (PyObject *)mp;\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n\n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int\nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs,\n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/*\n copyies over from the old descr table for anything\n NULL or zero in what is given.\n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray,\n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format)\n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data,\n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError,\n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr,\n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element\"\\\n \" %d to file\",\n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj);\n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj),\n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\",\n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1)\n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self)\n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0)\n\t\treturn self->descr->f->getitem(self->data,self);\n\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n\n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void\narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an\n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE\n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n\n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic _int_or_ssize_t\narray_length(PyArrayObject *self)\n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i)\n{\n\tchar *item;\n\tPyArrayObject *r;\n\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1,\n\t\t\t\t\t\t self->dimensions+1,\n\t\t\t\t\t\t self->strides+1, item,\n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, _int_or_ssize_t i)\n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\nstatic int\narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v)\n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret;\n }\n\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if PY_VERSION_HEX < 0x02050000\n #if SIZEOF_INT == SIZEOF_INTP\n #define array_ass_item array_ass_big_item\n #endif\n#else\n #if SIZEOF_SIZE_T == SIZEOF_INTP\n #define array_ass_item array_ass_big_item\n #endif\n#endif\n#ifndef array_ass_item\nstatic int\narray_ass_item(PyArrayObject *self, _int_or_ssize_t i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int\nparse_index(PyArrayObject *self, PyObject *op,\n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError,\n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\n nd_old = nd_new = 0;\n\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError,\n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError,\n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is\n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of\n\t the broadcasted index array\n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the\n\t result\n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2)\n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call.\n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *, int, int);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type,\n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret))\n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST, NULL);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\nint\ncount_new_axes_0d(PyObject *tuple)\n{\n\tint i, argument_count;\n\tint ellipsis_count = 0;\n\tint newaxis_count = 0;\n\n\targument_count = PyTuple_GET_SIZE(tuple);\n\n\tfor (i = 0; i < argument_count; ++i) {\n\t\tPyObject *arg = PyTuple_GET_ITEM(tuple, i);\n\t\tif (arg == Py_Ellipsis && !ellipsis_count) ellipsis_count++;\n\t\telse if (arg == Py_None) newaxis_count++;\n\t\telse break;\n\t}\n\tif (i < argument_count) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"0-d arrays can only use a single ()\"\n\t\t\t\t\" or a list of newaxes (and a single ...)\"\n\t\t\t\t\" as an index\");\n\t\treturn -1;\n\t}\n\tif (newaxis_count > MAX_DIMS) {\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"too many dimensions\");\n\t\treturn -1;\n\t}\n\treturn newaxis_count;\n}\n\nstatic PyObject *\nadd_new_axes_0d(PyArrayObject *arr, int newaxis_count)\n{\n\tPyArrayObject *other;\n\tintp dimensions[MAX_DIMS];\n\tint i;\n\tfor (i = 0; i < newaxis_count; ++i) {\n\t\tdimensions[i] = 1;\n\t}\n\tPy_INCREF(arr->descr);\n\tif ((other = (PyArrayObject *)\n\t PyArray_NewFromDescr(arr->ob_type, arr->descr,\n\t\t\t\t newaxis_count, dimensions,\n\t\t\t\t NULL, arr->data,\n\t\t\t\t arr->flags,\n\t\t\t\t (PyObject *)arr)) == NULL)\n\t\treturn NULL;\n\tother->base = (PyObject *)arr;\n\tPy_INCREF(arr);\n\treturn (PyObject *)other;\n}\n\n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0\n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* Called when treating array object like a mapping -- called first from\n Python when using a[object] unless object is a standard slice object\n (not an extended one).\n\n*/\n\n/* There are two situations:\n\n 1 - the subscript is a standard view and a reference to the\n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned.\n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *iter_subscript(PyArrayIterObject *, PyObject *);\n\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op)\n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd, oned, fancy;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr,\n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n if (self->nd == 0) {\n\t\tif (op == Py_Ellipsis) {\n\t\t\t/* XXX: This leads to a small inconsistency\n\t\t\t XXX: with the nd>0 case where (x[...] is x)\n\t\t\t XXX: is false for nd>0 case. */\n\t\t\tPy_INCREF(self);\n\t\t\treturn (PyObject *)self;\n\t\t}\n\t\tif (op == Py_None)\n\t\t\treturn add_new_axes_0d(self, 1);\n\t\tif (PyTuple_Check(op)) {\n\t\t\tif (0 == PyTuple_GET_SIZE(op)) {\n\t\t\t\tPy_INCREF(self);\n\t\t\t\treturn (PyObject *)self;\n\t\t\t}\n\t\t\tif ((nd = count_new_axes_0d(op)) == -1)\n\t\t\t\treturn NULL;\n\t\t\treturn add_new_axes_0d(self, nd);\n\t\t}\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\n\tfancy = fancy_indexing_check(op);\n\n\tif (fancy != SOBJ_NOTFANCY) {\n\t\toned = ((self->nd == 1) && !(PyTuple_Check(op) &&\t\\\n\t\t\t\t\t PyTuple_GET_SIZE(op) > 1));\n\n\t\t/* wrap arguments into a mapiter object */\n\t\tmit = (PyArrayMapIterObject *)\\\n\t\t\tPyArray_MapIterNew(op, oned, fancy);\n\t\tif (mit == NULL) return NULL;\n\t\tif (oned) {\n\t\t\tPyArrayIterObject *it;\n\t\t\tPyObject *rval;\n\t\t\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\t\t\tif (it == NULL) {Py_DECREF(mit); return NULL;}\n\t\t\trval = iter_subscript(it, mit->indexobj);\n\t\t\tPy_DECREF(it);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn rval;\n\t\t}\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset))\n == -1)\n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset,\n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL)\n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be\n used.\n*/\n\nstatic int iter_ass_subscript(PyArrayIterObject *, PyObject *, PyObject *);\n\nstatic int\narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op)\n{\n int ret, oned, fancy;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr,\n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n if (self->nd == 0) {\n\t\tif (index == Py_Ellipsis || index == Py_None ||\t\t\\\n\t\t (PyTuple_Check(index) && (0 == PyTuple_GET_SIZE(index) || \\\n\t\t\t\t\t count_new_axes_0d(index) > 0)))\n\t\t\treturn self->descr->f->setitem(op, self->data, self);\n PyErr_SetString(PyExc_IndexError,\n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n\tfancy = fancy_indexing_check(index);\n\n\tif (fancy != SOBJ_NOTFANCY) {\n\t\toned = ((self->nd == 1) && !(PyTuple_Check(index) && \\\n\t\t\t\t\t PyTuple_GET_SIZE(index) > 1));\n\n\t\tmit = (PyArrayMapIterObject *)\t\t\t\\\n\t\t\tPyArray_MapIterNew(index, oned, fancy);\n\t\tif (mit == NULL) return -1;\n\t\tif (oned) {\n\t\t\tPyArrayIterObject *it;\n\t\t\tint rval;\n\t\t\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\t\t\tif (it == NULL) {Py_DECREF(mit); return -1;}\n\t\t\trval = iter_ass_subscript(it, mit->indexobj, op);\n\t\t\tPy_DECREF(it);\n\t\t\tPy_DECREF(mit);\n\t\t\treturn rval;\n\t\t}\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1;\n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to\n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op)\n{\n\t/* The following is just a copy of PyArray_Return with an\n\t additional logic in the nd == 0 case. More efficient\n\t implementation may be possible by refactoring\n\t array_subscript */\n\n\tPyArrayObject *mp = (PyArrayObject *)array_subscript(self, op);\n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (!PyArray_Check(mp)) return (PyObject *)mp;\n\t\n\tif (mp->nd == 0) {\n\t\tBool noellipses = TRUE;\n\t\tif (op == Py_Ellipsis)\n\t\t\tnoellipses = FALSE;\n\t\telse if (PySequence_Check(op)) {\n\t\t\tint n, i;\n\t\t\tn = PySequence_Size(op);\n\t\t\tfor (i = 0; i < n; ++i) \n\t\t\t\tif (PySequence_GetItem(op, i) == Py_Ellipsis) {\n\t\t\t\t\tnoellipses = FALSE;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tif (noellipses) {\n\t\t\tPyObject *ret;\n\t\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\t\tPy_DECREF(mp);\n\t\t\treturn ret;\n\t\t}\n\t}\n\treturn (PyObject *)mp;\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)array_length,\t\t /*mp_length*/\n#else\n (inquiry)array_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic _int_or_ssize_t\narray_getsegcount(PyArrayObject *self, _int_or_ssize_t *lenp)\n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic _int_or_ssize_t\narray_getreadbuf(PyArrayObject *self, _int_or_ssize_t segment, void **ptrptr)\n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError,\n \"accessing non-existing array segment\");\n return -1;\n }\n\n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic _int_or_ssize_t\narray_getwritebuf(PyArrayObject *self, _int_or_ssize_t segment, void **ptrptr)\n{\n if (PyArray_CHKFLAGS(self, WRITEABLE))\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic _int_or_ssize_t\narray_getcharbuf(PyArrayObject *self, _int_or_ssize_t segment, const char **ptrptr)\n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError,\n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n#if PY_VERSION_HEX >= 0x02050000\n (readbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (writebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (segcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (charbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n#else\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n#endif\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n *square,\n *reciprocal,\n *ones_like,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum,\n\t\t*rint;\n} NumericOps;\n\nstatic NumericOps n_ops; /* NB: static objects inlitialized to zero */\n\n/* Dictionary can contain any of the numeric operations, by name.\n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n\n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint\nPyArray_SetNumericOps(PyObject *dict)\n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n SET(square);\n SET(reciprocal);\n SET(ones_like);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\n SET(true_divide);\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n\tSET(rint);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void)\n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL)\n\t\treturn NULL;\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n GET(square);\n GET(reciprocal);\n GET(ones_like);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide);\n GET(true_divide);\n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\tGET(rint);\n\treturn dict;\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE)\n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE)\n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1,\n\t\t\t\t PyObject *m2, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceUnaryFunction(PyArrayObject *m1, PyObject *op)\n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented;\n }\n return PyObject_CallFunction(op, \"OO\", m1, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2)\n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic int\narray_power_is_scalar(PyObject *o2, double* exp)\n{\n PyObject *temp;\n const int optimize_fpexps = 1;\n\n if (PyInt_Check(o2)) {\n\t *exp = (double)PyInt_AsLong(o2);\n\t return 1;\n }\n if (optimize_fpexps && PyFloat_Check(o2)) {\n\t *exp = PyFloat_AsDouble(o2);\n\t return 1;\n }\n if ((PyArray_IsZeroDim(o2) && \n\t ((PyArray_ISINTEGER(o2) || \n\t (optimize_fpexps && PyArray_ISFLOAT(o2))))) || \n\tPyArray_IsScalar(o2, Integer) || \n\t(optimize_fpexps && PyArray_IsScalar(o2, Floating))) {\n\t temp = o2->ob_type->tp_as_number->nb_float(o2);\n\t if (temp != NULL) {\n\t\t *exp = PyFloat_AsDouble(o2);\n\t\t Py_DECREF(temp);\n\t\t return 1;\n\t }\n }\n return 0;\n}\n\n/* optimize float array or complex array to a scalar power */\nstatic PyObject *\nfast_scalar_power(PyArrayObject *a1, PyObject *o2, int inplace) {\n\tdouble exp;\n\tif (PyArray_Check(a1) && (PyArray_ISFLOAT(a1) || \n\t\t\t\t PyArray_ISCOMPLEX(a1))) {\n\t\tif (array_power_is_scalar(o2, &exp)) {\n\t\t\tPyObject *fastop = NULL;\n\t\t\tif (exp == 1.0) {\n\t\t\t\t/* we have to do this one special, as the \n\t\t\t\t \"copy\" method of array objects isn't set \n\t\t\t\t up early enough to be added\n\t\t\t\t by PyArray_SetNumericOps.\n\t\t\t\t*/\n\t\t\t\tif (inplace) {\n\t\t\t\t\treturn (PyObject *)a1;\n\t\t\t\t} else {\n\t\t\t\t\treturn PyArray_Copy(a1);\n\t\t\t\t}\n\t\t\t} else if (exp == -1.0) {\n\t\t\t\tfastop = n_ops.reciprocal;\n\t\t\t} else if (exp == 0.0) {\n\t\t\t\tfastop = n_ops.ones_like;\n\t\t\t} else if (exp == 0.5) {\n\t\t\t\tfastop = n_ops.sqrt;\n\t\t\t} else if (exp == 2.0) {\n\t\t\t\tfastop = n_ops.square;\n\t\t\t} else {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (inplace) {\n\t\t\t\tPyArray_GenericInplaceUnaryFunction(a1, \n\t\t\t\t\t\t\t\t fastop);\n\t\t\t} else {\n\t\t\t\treturn PyArray_GenericUnaryFunction(a1, \n\t\t\t\t\t\t\t\t fastop);\n\t\t\t}\n\t\t}\n\t}\n\treturn NULL;\n}\n\nstatic PyObject *\narray_power(PyArrayObject *a1, PyObject *o2, PyObject *modulo)\n{\n\t/* modulo is ignored! */\n\tPyObject *value;\n\tvalue = fast_scalar_power(a1, o2, 0);\n\tif (!value) {\n\t\tvalue = PyArray_GenericBinaryFunction(a1, o2, n_ops.power);\n\t}\n\treturn value;\n}\n\n\nstatic PyObject *\narray_negative(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1)\n{\n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *a1, PyObject *o2, PyObject *modulo)\n{\n /* modulo is ignored! */\n PyObject *value;\n value = fast_scalar_power(a1, o2, 1);\n if (!value) {\n value = PyArray_GenericInplaceBinaryFunction(a1, o2, n_ops.power);\n }\n return value;\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2,\n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2)\n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2,\n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int\narray_any_nonzero(PyArrayObject *mp)\n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2)\n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_float(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to a \"\\\n\t\t\t\t\"float; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_long(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v)\n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/\n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected\n*/\n\n\nstatic PyObject *\narray_slice(PyArrayObject *self, _int_or_ssize_t ilow, \n\t _int_or_ssize_t ihigh)\n{\n PyArrayObject *r;\n _int_or_ssize_t l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n self->dimensions[0] = l;\n\tif (r == NULL) return NULL;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS);\n return (PyObject *)r;\n}\n\n\nstatic int\narray_ass_slice(PyArrayObject *self, _int_or_ssize_t ilow, \n\t\t_int_or_ssize_t ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError,\n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res;\n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\nstatic PySequenceMethods array_as_sequence = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (ssizeargfunc)NULL,\n\t(ssizeargfunc)array_item_nice,\n\t(ssizessizeargfunc)array_slice,\n (ssizeobjargproc)array_ass_item,\t /*sq_ass_item*/\n (ssizessizeobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(ssizeargfunc)NULL,\n#else\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t /*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n#endif\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int\ndump_data(char **string, int *n, int *max_n, char *data, int nd,\n intp *dimensions, intp *strides, PyArrayObject* self)\n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\n if (nd == 0) {\n\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata,\n\t\t self->nd, self->dimensions,\n self->strides, self) < 0) {\n\t\t_pya_free(string); return NULL;\n\t}\n\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void\nPyArray_SetStringFunction(PyObject *op, int repr)\n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction);\n\t\t/* Add a reference to new callback */\n Py_XINCREF(op);\n\t\t/* Remember new callback */\n PyArray_ReprFunction = op;\n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction);\n\t\t/* Add a reference to new callback */\n Py_XINCREF(op);\n\t\t/* Remember new callback */\n PyArray_StrFunction = op;\n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self)\n{\n PyObject *s, *arglist;\n\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist);\n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self)\n{\n PyObject *s, *arglist;\n\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist);\n }\n return s;\n}\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)\n{\n PyObject *array_other, *result;\n\tint typenum;\n\n switch (cmp_op)\n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n\t\t\tif (other == Py_None) {\n\t\t\t\tPy_INCREF(Py_False);\n\t\t\t\treturn Py_False;\n\t\t\t}\n /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\ttypenum = self->descr->type_num;\n\t\t\t\tif (typenum != PyArray_OBJECT) {\n\t\t\t\t\ttypenum = PyArray_NOTYPE;\n\t\t\t\t}\n\t\t\t\tarray_other = PyArray_FromObject(other,\n typenum, 0, 0);\n\t\t\t\t/* If not successful, then return False\n\t\t\t\t This fixes code that used to\n\t\t\t\t allow equality comparisons between arrays\n\t\t\t\t and other objects which would give a result\n\t\t\t\t of False\n\t\t\t\t*/\n\t\t\t\tif ((array_other == NULL) ||\t\\\n\t\t\t\t (array_other == Py_None)) {\n\t\t\t\t\tPy_XDECREF(array_other);\n\t\t\t\t\tPyErr_Clear();\n\t\t\t\t\tPy_INCREF(Py_False);\n\t\t\t\t\treturn Py_False;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPy_INCREF(other);\n\t\t\t\tarray_other = other;\n\t\t\t}\n result = PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t array_other,\n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the\n\t\t\t two array objects can not be compared together so\n\t\t\t return zero\n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n\t\t\tif (other == Py_None) {\n\t\t\t\tPy_INCREF(Py_True);\n\t\t\t\treturn Py_True;\n\t\t\t}\n /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\ttypenum = self->descr->type_num;\n\t\t\t\tif (typenum != PyArray_OBJECT) {\n\t\t\t\t\ttypenum = PyArray_NOTYPE;\n\t\t\t\t}\n\t\t\t\tarray_other = PyArray_FromObject(other,\n typenum, 0, 0);\n\t\t\t\t/* If not successful, then objects cannot be\n\t\t\t\t compared and cannot be equal, therefore,\n\t\t\t\t return True;\n\t\t\t\t*/\n\t\t\t\tif ((array_other == NULL) ||\t\\\n\t\t\t\t (array_other == Py_None)) {\n\t\t\t\t\tPy_XDECREF(array_other);\n\t\t\t\t\tPyErr_Clear();\n\t\t\t\t\tPy_INCREF(Py_True);\n\t\t\t\t\treturn Py_True;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPy_INCREF(other);\n\t\t\t\tarray_other = other;\n\t\t\t}\n\t\t\tresult = PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t array_other,\n\t\t\t\t\t\t\t n_ops.not_equal);\n\t\t\tPy_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other,\n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self,\n\t\t\t\t\t\t\t other,\n\t\t\t\t\t\t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\tif (temp) *axis = PyArray_NDIM(temp)-1;\n\t\telse *axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_CheckFromAny((PyObject *)arr, NULL,\n 0, 0, flags, NULL);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; i= SIZEOF_INTP\n\t\tif (!(op = PyNumber_Int(seq))) return -1;\n#else\n\t\tif (!(op = PyNumber_Long(seq))) return -1;\n#endif\n\t\tnd = 1;\n#if SIZEOF_LONG >= SIZEOF_INTP\n\t\tvals[0] = (intp ) PyInt_AsLong(op);\n#else\n\t\tvals[0] = (intp ) PyLong_AsLongLong(op);\n#endif\n\t\tPy_DECREF(op);\n\t} else {\n\t\tfor(i=0; i < MIN(nd,maxvals); i++) {\n\t\t\top = PySequence_GetItem(seq, i);\n\t\t\tif (op == NULL) return -1;\n#if SIZEOF_LONG >= SIZEOF_INTP\n\t\t\tvals[i]=(intp )PyInt_AsLong(op);\n#else\n\t\t\tvals[i]=(intp )PyLong_AsLongLong(op);\n#endif\n\t\t\tPy_DECREF(op);\n\t\t\tif(PyErr_Occurred()) return -1;\n\t\t}\n\t}\n\treturn nd;\n}\n\n\n/* Check whether the given array is stored contiguously (row-wise) in\n memory. */\nstatic int\n_IsContiguous(PyArrayObject *ap)\n{\n\tregister intp sd;\n\tregister intp dim;\n\tregister int i;\n\n\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return (ap->dimensions[0] == 1 || \\\n\t\t\t\t sd == ap->strides[0]);\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\tdim = ap->dimensions[i];\n\t\t/* contiguous by definition */\n\t\tif (dim == 0) return 1;\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= dim;\n\t}\n\treturn 1;\n}\n\n\nstatic int\n_IsFortranContiguous(PyArrayObject *ap)\n{\n\tregister intp sd;\n\tregister intp dim;\n\tregister int i;\n\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return (ap->dimensions[0] == 1 || \\\n\t\t\t\t sd == ap->strides[0]);\n\tfor (i=0; i< ap->nd; ++i) {\n\t\tdim = ap->dimensions[i];\n\t\t/* contiguous by definition */\n\t\tif (dim == 0) return 1;\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= dim;\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap)\n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object\n\t If it is a writeable array, then return TRUE\n\t If we can find an array object\n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable\n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA))\n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly\n\t and unpickled array can be set and reset writeable\n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t\telse ret->flags &= ~WRITEABLE;\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not\n ever be able to walk outside of the memory implied numbytes and offset.\n\n The available memory is assumed to start at -offset and proceed\n to numbytes-offset. The strides are checked to ensure\n that accessing memory using striding will not try to reach beyond\n this memory for any of the axes.\n\n If numbytes is 0 it will be calculated using the dimensions and\n element-size.\n\n This function checks for walking beyond the beginning and right-end\n of the buffer and therefore works for any integer stride (positive\n or negative).\n*/\n\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, intp offset,\n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\tintp byte_begin;\n\tintp begin;\n\tintp end;\n\n\tif (numbytes == 0)\n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\n\tbegin = -offset;\n\tend = numbytes - offset - elsize;\n\tfor (i=0; i end))\n\t\t\treturn FALSE;\n\t}\n\treturn TRUE;\n\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings\n depending on data and strides:\n\n If data is given, then flags is flags associated with data.\n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument\n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set).\n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired.\n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize,\n\t\t int inflag, int *objflags)\n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\n/* and update the dimensions and strides\n appropriately. Dimensions and strides are added\n to the end unless we have a FORTRAN array\n and then they are added to the beginning\n\n Strides are only added if given (because data is given).\n*/\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims,\n\t\t\t intp *newstrides, int oldnd, int isfortran)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\tint tuple;\n\n\told = *des;\n\t*des = old->subarray->base;\n\n\n\tmydim = newdims + oldnd;\n\ttuple = PyTuple_Check(old->subarray->shape);\n\tif (tuple) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t}\n\telse {\n\t\tnumnew = 1;\n\t}\n\n\n\tnewnd = oldnd + numnew;\n\tif (newnd > MAX_DIMS) goto finish;\n\tif (isfortran) {\n\t\tmemmove(newdims+numnew, newdims, oldnd*sizeof(intp));\n\t\tmydim = newdims;\n\t}\n\n\tif (tuple) {\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\tif (isfortran) {\n\t\t\tmemmove(newstrides+numnew, newstrides,\n\t\t\t\toldnd*sizeof(intp));\n\t\t\tmystrides = newstrides;\n\t\t}\n\t\t/* Make new strides -- alwasy C-contiguous */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\n finish:\n\tPy_INCREF(*des);\n\tPy_DECREF(old);\n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd,\n\t\t intp *dims, intp *strides, void *data,\n\t\t int flags, PyObject *obj)\n{\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tint isfortran=0;\n\t\tisfortran = (data && (flags & FORTRAN) && !(flags & CONTIGUOUS)) || \\\n\t\t\t(!data && flags);\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims,\n\t\t\t\t\t\t newstrides, nd, isfortran);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims,\n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { \n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN;\n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse { /* we allow strides even when we create\n\t\t\t the memory, but be careful with this...\n\t\t */\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays\n\t\t e.g. shape=(0,) -- otherwise buffer exposure\n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = descr->elsize;\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n /* which could also be sub-fields of a VOID array */\n\t\tif (descr->hasobject) {\n if (descr != &OBJECT_Descr) {\n PyErr_SetString(PyExc_TypeError,\n \"fields with object members \" \\\n \"not yet supported.\");\n goto fail;\n }\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in,\n\t\t\t\t\t this object won't own it\n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for\n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\n /* call the __array_finalize__\n\t method if a subtype.\n\t If obj is NULL, then call method with Py_None \n\t*/\n\tif ((subtype != &PyArray_Type)) {\n\t\tPyObject *res, *func, *args;\n\t\tstatic PyObject *str=NULL;\n\n\t\tif (str == NULL) {\n\t\t\tstr = PyString_InternFromString(\"__array_finalize__\");\n\t\t}\n\t\tif (strides != NULL) { /* did not allocate own data \n\t\t\t\t\t or funny strides */\n\t\t\t/* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tfunc = PyObject_GetAttr((PyObject *)self, str);\n\t\tif (func) {\n\t\t\targs = PyTuple_New(1);\n\t\t\tif (obj == NULL) obj=Py_None;\n\t\t\tPy_INCREF(obj);\n\t\t\tPyTuple_SET_ITEM(args, 0, obj);\n\t\t\tres = PyObject_Call(func, args, NULL);\n\t\t\tPy_DECREF(args);\n\t\t\tPy_DECREF(func);\n\t\t\tif (res == NULL) goto fail;\n\t\t\telse Py_DECREF(res);\n\t\t}\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(self);\n\treturn NULL;\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n If refcheck is 0, then the reference count is not checked\n and assumed to be 1.\n You still must own this data and have no weak-references and no base\n object.\n*/\nstatic PyObject *\nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,\n\t PyArray_ORDER fortran)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\n if (!PyArray_ISONESEGMENT(self)) {\n PyErr_SetString(PyExc_ValueError,\n \"resize only works on single-segment arrays\");\n return NULL;\n }\n\n\tif (fortran == PyArray_ANYORDER)\n\t\tfortran = PyArray_CORDER;\n \n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n oldsize = PyArray_SIZE(self);\n\n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (refcheck) refcnt = REFCOUNT(self);\n\t\telse refcnt = 1;\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (newsize == 0) sd = self->descr->elsize;\n\t\telse sd = newsize * self->descr->elsize;\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, sd);\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError,\n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n\n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) {\n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0,\n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n\n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n\n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError,\n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n self->flags, &(self->flags));\n\n\n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\n return Py_None;\n\n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED, NULL);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\tPyArray_FillWithScalarFunc* fillwithscalar =\n\t\t\tarr->descr->f->fillwithscalar;\n\t\tif (fillwithscalar && PyArray_ISALIGNED(arr)) {\n\t\t\tcopyswap(fromptr, NULL, swap, itemsize);\n\t\t\tfillwithscalar(toptr, size, fromptr, arr);\n\t\t}\n\t\telse {\n\t\t\twhile (size--) {\n\t\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\t\ttoptr += itemsize;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", /* XXX ? */\n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"order\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n PyArray_ORDER order=PyArray_CORDER;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL;\n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous\n\t array of a specific type and shape.\n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims,\n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter,\n &strides,\n &PyArray_OrderConverter,\n &order))\n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = 1;\n\n\tif (descr == NULL)\n\t\tdescr = PyArray_DescrFromType(PyArray_LONG);\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"data-type with unspecified variable length\");\n\t\tgoto fail;\n\t}\n\t\n\tif (strides.ptr != NULL) {\n\t\tintp nb, off;\n\t\tif (strides.len != dims.len) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"strides, if given, must be \"\t\\\n\t\t\t\t\t\"the same length as shape\");\n\t\t\tgoto fail;\n\t\t}\n\n\t\tif (buffer.ptr == NULL) {\n\t\t\tnb = 0;\n\t\t\toff = 0;\n\t\t}\n\t\telse {\n\t\t\tnb = buffer.len;\n\t\t\toff = offset;\n\t\t}\n\t\t\n\n\t\tif (!PyArray_CheckStrides(itemsize, dims.len, \n\t\t\t\t\t nb, off,\n\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"strides is incompatible \"\t\\\n\t\t\t\t\t\"with shape of requested \"\t\\\n\t\t\t\t\t\"array and size of buffer\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\t\t\t\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len,\n\t\t\t\t\t dims.ptr,\n\t\t\t\t\t strides.ptr, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = (buffer.len-offset) / itemsize;\n }\n else if ((strides.ptr == NULL) && \\\n\t\t\t buffer.len < itemsize*\t\t\t\t\\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError,\n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t offset + (char *)buffer.ptr,\n\t\t\t\t\t buffer.flags, NULL);\n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base);\n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n\n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyArray_NewFlagsObject((PyObject *)self);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n\tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret),\n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret),\n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes=0;\n\tintp offset=0;\n\tint buf_len;\n\tchar *buf;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base && PyArray_Check(new->base)) {\n\t\tnew = (PyArrayObject *)(new->base);\n\t}\n\t/* Get the available memory through the buffer\n\t interface on new->base or if that fails\n\t from the current new */\n\tif (new->base && PyObject_AsReadBuffer(new->base,\n\t\t\t\t\t (const void **)&buf,\n\t\t\t\t\t &buf_len) >= 0) {\n\t\toffset = self->data - buf;\n\t\tnumbytes = buf_len + offset;\n\t}\n\telse {\n\t\tPyErr_Clear();\n \t\tnumbytes = PyArray_MultiplyList(new->dimensions,\n\t\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\toffset = self->data - new->data;\n\t}\n\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes,\n\t\t\t\t offset,\n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self))\n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self)\n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0,\n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf,\n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError,\n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse\n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse\n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self)\n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed.\n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid data-type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the\n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0)\n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n\telse if (newtype->elsize > self->descr->elsize) {\n\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update\n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\t/* We would decref newtype here --- temp will\n\t\t steal a reference to it */\n\t\ttemp = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tif (temp == NULL) return -1;\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tnewtype = temp->descr;\n\t\tPy_INCREF(temp->descr);\n\t\t/* Fool deallocator not to delete these*/\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype;\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"descr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n\n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA);\n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);\n\tif (new == NULL) return -1;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num -\n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type,\n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);\n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new);\n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int\narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode,\n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self), NULL);\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr));\n memmove(selfit->dataptr, arrit->dataptr,\n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size)\n PyArray_ITER_RESET(arrit);\n }\n retval = 0;\n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size)\n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\",\n\t (getter)array_ndim_get,\n\t NULL,\n\t \"number of array dimensions\"},\n {\"flags\",\n\t (getter)array_flags_get,\n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\",\n\t (getter)array_shape_get,\n\t (setter)array_shape_set,\n\t \"tuple of array dimensions\"},\n {\"strides\",\n\t (getter)array_strides_get,\n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)array_data_get,\n\t (setter)array_data_set,\n\t \"pointer to start of data\"},\n {\"itemsize\",\n\t (getter)array_itemsize_get,\n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n\t{\"dtype\",\n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\",\n\t (getter)array_real_get,\n\t (setter)array_real_set,\n\t \"real part of array\"},\n {\"imag\",\n\t (getter)array_imag_get,\n\t (setter)array_imag_set,\n\t \"imaginary part of array\"},\n\t{\"flat\",\n\t (getter)array_flat_get,\n\t (setter)array_flat_set,\n\t \"a 1-d view of a contiguous array\"},\n\t{\"__array_data__\",\n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\",\n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n\t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */\n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] =\n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the numpy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the numpy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=int_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a numpy.dtype object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\nstatic PyTypeObject PyArray_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0,\t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n &array_as_sequence,\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str,\t /*tp_str*/\n\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n &array_as_buffer, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT\n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t /*tp_richcompare */\n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter,\t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n array_alloc,\t /* tp_alloc */\n (newfunc)array_new,\t\t /* tp_new */\n _pya_free,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int\ndiscover_depth(PyObject *s, int max, int stop_at_string, int stop_at_tuple)\n{\n int d=0;\n PyObject *e;\n\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif (stop_at_tuple && PyTuple_Check(s)) return 0;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0)\n\t\treturn 1;\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string, stop_at_tuple);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize)\n{\n\tint n, r, i;\n\tPyObject *e;\n\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s)\n\t\t\t*itemsize = MAX(*itemsize, 4*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype ---\n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately\n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE &&\n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 4*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\nstatic PyArray_Descr *\n_array_find_python_scalar_type(PyObject *op)\n{\n if (PyFloat_Check(op)) {\n return PyArray_DescrFromType(PyArray_DOUBLE);\n } else if (PyComplex_Check(op)) {\n return PyArray_DescrFromType(PyArray_CDOUBLE);\n } else if (PyInt_Check(op)) {\n /* bools are a subclass of int */\n if (PyBool_Check(op)) {\n return PyArray_DescrFromType(PyArray_BOOL);\n } else {\n return PyArray_DescrFromType(PyArray_LONG);\n }\n } else if (PyLong_Check(op)) {\n /* if integer can fit into a longlong then return that\n */\n if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) {\n PyErr_Clear();\n return PyArray_DescrFromType(PyArray_OBJECT);\n }\n return PyArray_DescrFromType(PyArray_LONGLONG);\n }\n return NULL;\n}\n\n/* op is an object to be converted to an ndarray.\n\n minitype is the minimum type-descriptor needed.\n\n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n\n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\n\tif (minitype == NULL)\n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\n if (max < 0) goto deflt;\n\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n chktype = _array_find_python_scalar_type(op);\n if (chktype) {\n goto finish;\n }\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n\n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind,\n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n#ifndef Py_UNICODE_WIDE\n\t\tchktype->elsize <<= 1;\n#endif\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n }\n\n\tif (PyInstance_Check(op)) goto deflt;\n\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) {\n\t\t\tPyErr_Clear();\n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\n finish:\n\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype;\n}\n\nstatic int\nAssign_Array(PyArrayObject *self, PyObject *v)\n{\n PyObject *e;\n int l, r;\n\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\n l=PyObject_Length(v);\n if(l < 0) return -1;\n\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1;\n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */\n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode)\n{\n PyArrayObject *ret;\n\tint itemsize;\n\tint type;\n\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= 4;\n\n\t\tif (itemsize != typecode->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(typecode);\n\t\t\ttypecode->elsize = itemsize;\n\t\t}\n\t}\n\n ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL,\n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\tif (ret == NULL) return NULL;\n\tif (ret->nd > 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"shape-mismatch on array construction\");\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\n ret->descr->f->setitem(op, ret->data, ret);\n\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode */\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran,\n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint stop_at_tuple;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n\tstop_at_tuple = (type == PyArray_VOID && ((typecode->fields &&\t\\\n\t\t\t\t\t\t typecode->fields!=Py_None) \\\n\t\t\t\t\t\t || (typecode->subarray)));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string,\n\t\t\t\t stop_at_tuple)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"invalid input sequence\");\n\t\tgoto fail;\n }\n\n\tif (max_depth && PyTypeNum_ISOBJECT(type) && (nd > max_depth)) {\n\t\tnd = max_depth;\n\t}\n\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"invalid number of dimensions\");\n\t\tgoto fail;\n }\n\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) goto fail;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) goto fail;\n\t\tif (type == PyArray_UNICODE) itemsize*=4;\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\n if(!r) return NULL;\n if(Assign_Array(r,s) == -1) {\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n\n fail:\n\tPy_DECREF(typecode);\n\treturn NULL;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int\nPyArray_ValidType(int type)\n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in))\n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject *\nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize << 2;\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING)\n\t\t\tat->elsize = mpd->elsize >> 2;\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd,\n\t\t\t\t mp->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\n\tPy_DECREF(out);\n\treturn NULL;\n\n}\n\n/* The number of elements in out must be an integer multiple\n of the number of elements in mp.\n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1;\n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * mpsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr,\n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags)\n{\n\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif ((flags & ENSURECOPY) || PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) && (!(arrflags & FORTRAN)))) \\\n\t\t\t|| ((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1)\n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse {\n if ((flags & ENSUREARRAY)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype,\n\t\t\t\t\t\t newtype,\n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr;\n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\n\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short))\n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong))\n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char))\n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short))\n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long))\n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t break;\n\tcase PyArray_STRINGLTR:\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase PyArray_UNICODELTR:\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize <<= 2;\n\t\tbreak;\n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap)\n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* OBJECT_API */\nstatic PyObject *\nPyArray_FromStructInterface(PyObject *input)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r;\n\tchar endian = PyArray_NATBYTE;\n\n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n return r;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromInterface(PyObject *input)\n{\n\tPyObject *attr=NULL, *item=NULL;\n PyObject *tstr=NULL, *shape=NULL;\n PyArrayObject *ret;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n\n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data,\n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr));\n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n\n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\treturn (PyObject *)ret;\n\n fail:\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* OBJECT_API*/\nstatic PyObject *\nPyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject *context)\n{\n PyObject *new;\n PyObject *array_meth;\n\n array_meth = PyObject_GetAttrString(op, \"__array__\");\n if (array_meth == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n if (context == NULL) {\n if (typecode == NULL) new = PyObject_CallFunction(array_meth, \n\t\t\t\t\t\t\t\t NULL);\n else new = PyObject_CallFunction(array_meth, \"O\", typecode);\n }\n else {\n if (typecode == NULL) {\n new = PyObject_CallFunction(array_meth, \"OO\", Py_None,\n\t\t\t\t\t\t context);\n if (new == NULL && \\\n\t\t\t PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", \n\t\t\t\t\t\t typecode, context);\n if (new == NULL && \\\n\t\t\t PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", \n\t\t\t\t\t\t\t typecode);\n }\n }\n }\n Py_DECREF(array_meth);\n if (new == NULL) return NULL;\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError,\n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n return NULL;\n }\n return new;\n}\n\n/* Does not check for ENSURECOPY and NOTSWAPPED in flags */\n/* Steals a reference to newtype --- which can be NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth,\n int max_depth, int flags, PyObject *context)\n{\n /* This is the main code to make a NumPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op))\n\t\tr = PyArray_FromArray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t} else if (newtype == NULL &&\n (newtype = _array_find_python_scalar_type(op))) {\n r = Array_FromScalar(op, newtype);\n }\n else if (((r = PyArray_FromStructInterface(op))!=Py_NotImplemented)|| \\\n ((r = PyArray_FromInterface(op)) != Py_NotImplemented) || \\\n ((r = PyArray_FromArrayAttr(op, newtype, context)) \\\n != Py_NotImplemented)) {\n PyObject *new;\n if (r == NULL) return NULL;\n if (newtype != NULL || flags != 0) {\n new = PyArray_FromArray((PyArrayObject *)r, newtype, \n\t\t\t\t\t\tflags);\n Py_DECREF(r);\n r = new;\n }\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\n\t\t\tPy_INCREF(newtype);\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL) {\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n\t\t\t\tPyErr_Clear();\n\t\t\t}\n else {\n\t\t\t\tseq = TRUE;\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t}\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\n\t/* Be sure we succeed here */\n\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"internal error: PyArray_FromAny \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError,\n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError,\n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int\nPyArray_ObjectType(PyObject *op, int minimum_type)\n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of\n CONTIGUOUS,\n FORTRAN,\n ALIGNED,\n WRITEABLE,\n NOTSWAPPED,\n ENSURECOPY,\n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should\n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or\n not it has such features.\n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well.\n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n\n FORTRAN can be set in the FLAGS to request a FORTRAN array.\n Fortran arrays are always behaved (aligned,\n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d).\n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array.\n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe.\n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth,\n int max_depth, int requires, PyObject *context)\n{\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn PyArray_FromAny(op, descr, min_depth, max_depth,\n requires, context);\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0,\n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place\n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op)) return op;\n\n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FromAny(op, NULL, 0, 0, ENSUREARRAY, NULL);\n Py_DECREF(op);\n return new;\n}\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int\nPyArray_CanCastSafely(int fromtype, int totype)\n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype))\n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize << 2 \\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode\n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\n\t\t*/\n\t}\n\treturn ret;\n}\n\n/*OBJECT_API\n See if array scalars can be cast.\n */\nstatic Bool\nPyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)\n{\n\tint fromtype;\n\tint totype;\n\n\tfromtype = _typenum_fromtypeobj((PyObject *)from, 0);\n\ttotype = _typenum_fromtypeobj((PyObject *)to, 0);\n\tif (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE) \n\t\treturn FALSE;\n\treturn (Bool) PyArray_CanCastSafely(fromtype, totype);\t\n}\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and numpy's arraymap ****/\n/* and Python's array iterator ***/\n\n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd;\n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\n return (PyObject *)it;\n}\n\n\n/*OBJECT_API\n Get Iterator that iterates over all but one axis (don't use this with\n PyArray_ITER_GOTO1D)\n*/\nstatic PyObject *\nPyArray_IterAllButAxis(PyObject *obj, int axis)\n{\n\tPyArrayIterObject *it;\n\tit = (PyArrayIterObject *)PyArray_IterNew(obj);\n\tif (it == NULL) return NULL;\n\n\t/* adjust so that will not iterate over axis */\n\tit->contiguous = 0;\n\tif (it->size != 0) {\n\t\tit->size /= PyArray_DIM(obj,axis);\n\t}\n\tit->dims_m1[axis] = 0;\n\tit->backstrides[axis] = 0;\n\n\t/* (won't fix factors so don't use\n\t PyArray_ITER_GOTO1D with this iterator) */\n\treturn (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic _int_or_ssize_t\niter_length(PyArrayIterObject *self)\n{\n return self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count,\n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr,\n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num,\n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\tif (PyTuple_Check(ind)) {\n\t\tint len;\n\t\tlen = PyTuple_GET_SIZE(ind);\n\t\tif (len > 1) goto fail;\n\t\tind = PyTuple_GET_ITEM(ind, 0);\n\t}\n\n\t/* Tuples >1d not accepted --- i.e. no newaxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps,\n\t\t\t\t self->size);\n\t\tif (start == -1)\n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"cannot use Ellipsis or newaxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t 1, &n_steps,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail;\n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tstart += step_size;\n\t\t\tPyArray_ITER_GOTO1D(self, start)\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (obj == NULL) goto fail;\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t}\n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0,\n FORCECAST | ALIGNED, NULL);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\n fail:\n\tif (!PyErr_Occurred())\n\t\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n\t\t\t\t itemsize);\n\t\t\tPyArray_ITER_NEXT(val);\n\t\t\tif (val->index==val->size)\n\t\t\t\tPyArray_ITER_RESET(val);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num,\n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size)\n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val)\n{\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tretval = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn retval;\n\t}\n\n\tif (PyTuple_Check(ind)) {\n\t\tint len;\n\t\tlen = PyTuple_GET_SIZE(ind);\n\t\tif (len > 1) goto finish;\n\t\tind = PyTuple_GET_ITEM(ind, 0);\n\t}\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0, NULL);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps,\n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"cannot use Ellipsis or newaxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tstart += step_size;\n\t\t\tPyArray_ITER_GOTO1D(self, start)\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size)\n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t}\n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST, NULL);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_CheckFromAny(obj, indtype, 0, 0,\n FORCECAST | BEHAVED_NS_FLAGS, NULL);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)iter_length,\t\t /*mp_length*/\n#else\n (inquiry)iter_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op)\n{\n\n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options:\n 1) underlying array is contiguous\n -- return 1-d wrapper around it\n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type,\n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size,\n\t\t\t\t\t NULL, it->ao->data,\n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type,\n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size,\n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r);\n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n\n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n {\"index\", T_INT, offsetof(PyArrayIterObject, index), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\niter_coords_get(PyArrayIterObject *self)\n{\n int nd;\n nd = self->ao->nd;\n if (self->contiguous) { /* coordinates not kept track of --- need to generate\n from index */\n intp val;\n int i;\n val = self->index;\n for (i=0;icoordinates[i] = val / self->factors[i];\n val = val % self->factors[i];\n }\n }\n return PyArray_IntTupleFromIntp(nd, self->coordinates);\n}\n\nstatic PyGetSetDef iter_getsets[] = {\n\t{\"coords\",\n\t (getter)iter_coords_get,\n\t NULL,\n\t \"An N-d tuple of current coordinates.\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &iter_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t\t /* tp_members */\n iter_getsets, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular\n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators\n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++)\n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already\n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1)\n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of\n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord,\n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so,\n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size.\n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere.\n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well.\n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\n\t/* no subspace iteration needed. Finish up and Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0\n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t/* But, be sure to do it with a true array.\n\t */\n\tif (PyArray_CheckExact(arr)) {\n\t\tsub = array_subscript(arr, mit->indexobj);\n\t}\n\telse {\n\t\tPy_INCREF(arr);\n\t\tobj = PyArray_EnsureArray((PyObject *)arr);\n\t\tif (obj == NULL) goto fail;\n\t\tsub = array_subscript((PyArrayObject *)obj, mit->indexobj);\n\t\tPy_DECREF(obj);\n\t}\n\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects\n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been\n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj))\n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj,\n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1;\n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1),\n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0,\n\t\t\t\t\t CARRAY_FLAGS, NULL);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n\tmit->index = 0;\n\tmit->ait = NULL;\n\tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY\n#undef SOBJ_ISFANCY\n#undef SOBJ_BADARRAY\n#undef SOBJ_TOOMANY\n#undef SOBJ_LISTTUP\n\n\tif (oned) return (PyObject *)mit;\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple\n\t (with at least 1 list or arrayobject or Bool object), */\n\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i,\n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST, NULL);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing\n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n return (PyObject *)mit;\n\n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently that does not work.\n Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a);\n mapiter is equivalent to a[indexobj].flat but the latter gets to use\n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.mapiter\",\t\t\t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t\t /* tp_iter */\n (iternextfunc)0,\t /* tp_iternext */\n 0,\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\n\tint i, err=0;\n\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\n\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\n\tPyArray_MultiIter_RESET(multi);\n\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL)\n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\n return (PyObject *)multi;\n\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i,\n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\",\n\t (getter)arraymultiter_size_get,\n\t NULL,\n\t \"total size of broadcasted result\"},\n {\"index\",\n\t (getter)arraymultiter_index_get,\n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter),\n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.broadcast\",\t\t\t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods,\t /* tp_methods */\n arraymultiter_members,\t\t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types.\n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these\n builtins will be attempted leading to problems.\n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically\n allocated).\n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray,\n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless\n there is a reference-count problem\n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free((PyObject *)self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtype objects can be set.\n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"type\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"kind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"char\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"num\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n {\"hasobject\", T_UBYTE, offsetof(PyArray_Descr, hasobject), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base,\n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n char basic_=self->kind;\n char endian = self->byteorder;\n\tint size=self->elsize;\n\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n\tif (self->type_num == PyArray_UNICODE) {\n\t\tsize >>= 2;\n\t}\n return PyString_FromFormat(\"%c%c%d\", endian, basic_, size);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\tstatic int suffix_len=0;\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tif (suffix_len == 0)\n\t\t\tsuffix_len = strlen(\"scalar\");\n\t\tlen = strlen(typeobj->tp_name) - suffix_len;\n\t\tres = PyString_FromStringAndSize(typeobj->tp_name, len);\n\t}\n\tif (PyTypeNum_ISEXTENDED(self->type_num) && self->elsize != 0) {\n\t\tPyObject *p;\n\t\tp = PyString_FromFormat(\"%d\", self->elsize * 8);\n\t\tPyString_ConcatAndDel(&res, p);\n\t}\n\treturn res;\n}\n\nstatic PyObject *\narraydescr_base_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(self);\n return (PyObject *)self;\n\t}\n Py_INCREF(self->subarray->base);\n return (PyObject *)(self->subarray->base);\n}\n\nstatic PyObject *\narraydescr_shape_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n return Py_BuildValue(\"(N)\", PyInt_FromLong(1));\n\t}\n Py_INCREF(self->subarray->shape);\n return (PyObject *)(self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_numpy_internal, \"_array_descr\",\n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self)\n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyObject *\narraydescr_fields_get(PyArray_Descr *self)\n{\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyDictProxy_New(self->fields);\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdtype\",\n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"descr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"str\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n {\"name\",\n (getter)arraydescr_typename_get,\n NULL,\n \"The name of the true data-type\"},\n\t{\"base\",\n\t (getter)arraydescr_base_get,\n\t NULL,\n\t \"The base data-type or self if no subdtype\"},\n {\"shape\",\n (getter)arraydescr_shape_get,\n NULL,\n \"The shape of the subdtype or (1,)\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{\"fields\",\n\t (getter)arraydescr_fields_get,\n\t NULL,\n\t NULL},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\tstatic char *kwlist[] = {\"dtype\", \"align\", \"copy\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\",\n\t\t\t\t\t kwlist, &odescr, &align,\n\t\t\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr)\n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr)\n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv))\n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"numpy.core.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtype\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\telsize = self->elsize;\n\t\tif (self->type_num == PyArray_UNICODE) {\n\t\t\telsize >>= 2;\n\t\t}\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\n\t/* Now return the state which is at least\n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize\n and alignment for EXTENDED arrays\n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are:\n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtype object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtype object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args)\n{\n\tchar endian=PyArray_SWAP;\n\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS,\n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_str(PyArray_Descr *self)\n{\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) {\n\t\t\tsub = PyString_FromString(\"\");\n\t\t\tPyErr_Clear();\n\t\t}\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse if (self->subarray) {\n\t\tPyObject *p;\n\t\tPyObject *t = PyString_FromString(\"(\");\n\t\tp = arraydescr_str(self->subarray->base);\n\t\tPyString_ConcatAndDel(&t, p);\n\t\tPyString_ConcatAndDel(&t, PyString_FromString(\",\"));\n\t\tPyString_ConcatAndDel(&t, PyObject_Str(self->subarray->shape));\n\t\tPyString_ConcatAndDel(&t, PyString_FromString(\")\"));\n\t\tsub = t;\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\treturn sub;\n}\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *sub, *s;\n\ts = PyString_FromString(\"dtype(\");\n sub = arraydescr_str(self);\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic int\narraydescr_compare(PyArray_Descr *self, PyObject *other)\n{\n\tif (!PyArray_DescrCheck(other)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"not a dtype object.\");\n\t\treturn -1;\n\t}\n\tif (PyArray_EquivTypes(self, (PyArray_Descr *)other)) return 0;\n\tif (PyArray_CanCastTo(self, (PyArray_Descr *)other)) return -1;\n\treturn 1;\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic _int_or_ssize_t\ndescr_length(PyArray_Descr *self)\n{\n\n\tif (self->fields && self->fields != Py_None)\n\t\t/* Remove the last entry (root) */\n\t\treturn PyDict_Size(self->fields) - 1;\n\telse return 0;\n}\n\nstatic PyObject *\ndescr_subscript(PyArray_Descr *self, PyObject *op)\n{\n\n\tif (self->fields) {\n\t\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyObject *descr;\n\t\t\t\tdescr = PyTuple_GET_ITEM(obj, 0);\n\t\t\t\tPy_INCREF(descr);\n\t\t\t\treturn descr;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPyErr_Format(PyExc_KeyError,\n\t\t\t\t\t \"field named \\'%s\\' not found.\",\n\t\t\t\t\t PyString_AsString(op));\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t PyErr_SetString(PyExc_ValueError,\n\t\t\t\t \"only strings or unicode values allowed \" \\\n\t\t\t\t \"for getting fields.\");\n\t\t}\n\t}\n\telse {\n\t\tPyErr_Format(PyExc_KeyError,\n\t\t\t \"there are no fields in dtype %s.\",\n\t\t\t PyString_AsString(arraydescr_str(self)));\n\t}\n\treturn NULL;\n}\n\nstatic PyMappingMethods descr_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)descr_length,\t\t /*mp_length*/\n#else\n (inquiry)descr_length,\t\t /*mp_length*/\n#endif\n (binaryfunc)descr_subscript,\t /*mp_subscript*/\n (objobjargproc)NULL,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"numpy.dtype\",\t\t\t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n\t(cmpfunc)arraydescr_compare,\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &descr_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_str, /* tp_str */\n 0,\t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n 0,\t\t/* tp_iternext */\n arraydescr_methods,\t\t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0,\t\t /* tp_init */\n 0,\t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n\n/** Array Flags Object **/\n\ntypedef struct PyArrayFlagsObject {\n PyObject_HEAD\n PyObject *arr;\n int flags;\n} PyArrayFlagsObject;\n\n/*OBJECT_API\n Get New ArrayFlagsObject\n*/\nstatic PyObject *\nPyArray_NewFlagsObject(PyObject *obj)\n{\n PyObject *flagobj;\n int flags;\n if (obj == NULL) {\n flags = CONTIGUOUS | OWNDATA | FORTRAN | ALIGNED;\n }\n else {\n flags = PyArray_FLAGS(obj);\n }\n flagobj = PyArrayFlags_Type.tp_alloc(&PyArrayFlags_Type, 0);\n if (flagobj == NULL) return NULL;\n Py_XINCREF(obj);\n ((PyArrayFlagsObject *)flagobj)->arr = obj;\n ((PyArrayFlagsObject *)flagobj)->flags = flags;\n\n return flagobj;\n}\n\nstatic void\narrayflags_dealloc(PyArrayFlagsObject *self)\n{\n\tPy_XDECREF(self->arr);\n\tself->ob_type->tp_free((PyObject *)self);\n}\n\n\n#define _define_get(UPPER, lower) \\\nstatic PyObject * \\\narrayflags_ ## lower ## _get(PyArrayFlagsObject *self) \\\n{ \\\n PyObject *item; \\\n item = ((self->flags & (UPPER)) == (UPPER)) ? Py_True : Py_False; \\\n Py_INCREF(item); \\\n return item; \\\n}\n\n_define_get(CONTIGUOUS, contiguous)\n_define_get(FORTRAN, fortran)\n_define_get(UPDATEIFCOPY, updateifcopy)\n_define_get(OWNDATA, owndata)\n_define_get(ALIGNED, aligned)\n_define_get(WRITEABLE, writeable)\n\n_define_get(ALIGNED|WRITEABLE, behaved)\n_define_get(ALIGNED|WRITEABLE|CONTIGUOUS, carray)\n\nstatic PyObject *\narrayflags_forc_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & FORTRAN) == FORTRAN) ||\n ((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_fnc_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & FORTRAN) == FORTRAN) &&\n !((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_farray_get(PyArrayFlagsObject *self)\n{\n PyObject *item;\n \n if (((self->flags & (ALIGNED|WRITEABLE|FORTRAN)) == \\\n (ALIGNED|WRITEABLE|FORTRAN)) &&\n !((self->flags & CONTIGUOUS) == CONTIGUOUS))\n item = Py_True;\n else\n item = Py_False;\n \n Py_INCREF(item);\n return item;\n}\n\nstatic PyObject *\narrayflags_num_get(PyArrayFlagsObject *self)\n{\n return PyInt_FromLong(self->flags);\n}\n\n/* relies on setflags order being write, align, uic */\nstatic int\narrayflags_updateifcopy_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", Py_None, Py_None, \n (PyObject_IsTrue(obj) ? Py_True : Py_False));\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\nstatic int\narrayflags_aligned_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", Py_None, \n (PyObject_IsTrue(obj) ? Py_True : Py_False),\n Py_None);\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\nstatic int\narrayflags_writeable_set(PyArrayFlagsObject *self, PyObject *obj)\n{\n PyObject *res;\n if (self->arr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"Cannot set flags on array scalars.\");\n return -1;\n }\n res = PyObject_CallMethod(self->arr, \"setflags\", \"OOO\", \n (PyObject_IsTrue(obj) ? Py_True : Py_False),\n Py_None, Py_None);\n if (res == NULL) return -1;\n Py_DECREF(res);\n return 0;\n}\n\n\nstatic PyGetSetDef arrayflags_getsets[] = {\n\t{\"contiguous\",\n\t (getter)arrayflags_contiguous_get,\n\t NULL,\n\t \"\"},\n {\"fortran\",\n (getter)arrayflags_fortran_get,\n NULL,\n \"\"},\n {\"updateifcopy\",\n (getter)arrayflags_updateifcopy_get,\n (setter)arrayflags_updateifcopy_set,\n \"\"},\n {\"owndata\",\n (getter)arrayflags_owndata_get,\n NULL,\n \"\"},\n {\"aligned\",\n (getter)arrayflags_aligned_get,\n (setter)arrayflags_aligned_set,\n \"\"},\n {\"writeable\",\n (getter)arrayflags_writeable_get,\n (setter)arrayflags_writeable_set,\n \"\"},\n {\"fnc\",\n (getter)arrayflags_fnc_get,\n NULL,\n \"\"},\n {\"forc\",\n (getter)arrayflags_forc_get,\n NULL,\n \"\"},\n {\"behaved\",\n (getter)arrayflags_behaved_get,\n NULL,\n \"\"},\n {\"carray\",\n (getter)arrayflags_carray_get,\n NULL,\n \"\"},\n {\"farray\",\n (getter)arrayflags_farray_get,\n NULL,\n \"\"},\n {\"num\",\n (getter)arrayflags_num_get,\n NULL,\n \"\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyObject *\narrayflags_getitem(PyArrayFlagsObject *self, PyObject *ind)\n{\n char *key;\n int n;\n if (!PyString_Check(ind)) goto fail;\n key = PyString_AS_STRING(ind);\n n = PyString_GET_SIZE(ind);\n\tswitch(n) {\n\tcase 1:\n\t\tswitch(key[0]) {\n\t\tcase 'C':\n\t\t\treturn arrayflags_contiguous_get(self);\n\t\tcase 'F':\n\t\t\treturn arrayflags_fortran_get(self);\n\t\tcase 'W':\n\t\t\treturn arrayflags_writeable_get(self);\n\t\tcase 'B':\n\t\t\treturn arrayflags_behaved_get(self);\n\t\tcase 'O':\n\t\t\treturn arrayflags_owndata_get(self);\n\t\tcase 'A':\n\t\t\treturn arrayflags_aligned_get(self);\n\t\tcase 'U':\n\t\t\treturn arrayflags_updateifcopy_get(self);\n\t\tdefault:\n\t\t\tgoto fail;\n\t\t}\n\t\tbreak;\n\tcase 2:\n\t\tif (strncmp(key, \"CA\", n)==0)\n\t\t\treturn arrayflags_carray_get(self);\n\t\tif (strncmp(key, \"FA\", n)==0)\n\t\t\treturn arrayflags_farray_get(self);\n\t\tbreak;\n\tcase 3:\n\t\tif (strncmp(key, \"FNC\", n)==0)\n\t\t\treturn arrayflags_fnc_get(self);\n\t\tbreak;\n\tcase 4:\n\t\tif (strncmp(key, \"FORC\", n)==0)\n\t\t\treturn arrayflags_forc_get(self);\n\t\tbreak;\n\tcase 6:\n\t\tif (strncmp(key, \"CARRAY\", n)==0)\n\t\t\treturn arrayflags_carray_get(self);\n\t\tif (strncmp(key, \"FARRAY\", n)==0)\n\t\t\treturn arrayflags_farray_get(self);\n\t\tbreak;\n\tcase 7:\n\t\tif (strncmp(key,\"FORTRAN\",n)==0)\n\t\t\treturn arrayflags_fortran_get(self);\n\t\tif (strncmp(key,\"BEHAVED\",n)==0)\n\t\t\treturn arrayflags_behaved_get(self);\n\t\tif (strncmp(key,\"OWNDATA\",n)==0)\n\t\t\treturn arrayflags_owndata_get(self);\n\t\tif (strncmp(key,\"ALIGNED\",n)==0)\n\t\t\treturn arrayflags_aligned_get(self);\n\t\tbreak;\n\tcase 9:\t\n\t\tif (strncmp(key,\"WRITEABLE\",n)==0)\n\t\t\treturn arrayflags_writeable_get(self);\n\t\tbreak;\n\tcase 10:\n\t\tif (strncmp(key,\"CONTIGUOUS\",n)==0)\n\t\t\treturn arrayflags_contiguous_get(self);\n\t\tbreak;\n\tcase 12:\n\t\tif (strncmp(key, \"UPDATEIFCOPY\", n)==0)\n\t\t\treturn arrayflags_updateifcopy_get(self);\n\t\tbreak;\n\t}\n\n fail:\n PyErr_SetString(PyExc_KeyError, \"Unknown flag\");\n return NULL;\n}\n\nstatic int\narrayflags_setitem(PyArrayFlagsObject *self, PyObject *ind, PyObject *item)\n{ \n char *key;\n int n;\n if (!PyString_Check(ind)) goto fail;\n key = PyString_AS_STRING(ind);\n n = PyString_GET_SIZE(ind);\n if (((n==9) && (strncmp(key, \"WRITEABLE\", n)==0)) ||\n\t ((n==1) && (strncmp(key, \"W\", n)==0)))\n return arrayflags_writeable_set(self, item);\n else if (((n==7) && (strncmp(key, \"ALIGNED\", n)==0)) || \n ((n==1) && (strncmp(key, \"A\", n)==0)))\n return arrayflags_aligned_set(self, item);\n else if (((n==12) && (strncmp(key, \"UPDATEIFCOPY\", n)==0)) ||\n ((n==1) && (strncmp(key, \"U\", n)==0)))\n return arrayflags_updateifcopy_set(self, item); \n\nfail:\n PyErr_SetString(PyExc_KeyError, \"Unknown flag\");\n return -1;\n}\n\nstatic char *\n_torf_(int flags, int val)\n{\n if ((flags & val) == val) return \"True\";\n else return \"False\"; \n}\n\nstatic PyObject *\narrayflags_print(PyArrayFlagsObject *self)\n{\n int fl = self->flags;\n \n return PyString_FromFormat(\" %s : %s\\n %s : %s\\n %s : %s\\n\"\\\n \" %s : %s\\n %s : %s\\n %s : %s\",\n \"CONTIGUOUS\", _torf_(fl, CONTIGUOUS),\n \"FORTRAN\", _torf_(fl, FORTRAN),\n \"OWNDATA\", _torf_(fl, OWNDATA),\n \"WRITEABLE\", _torf_(fl, WRITEABLE),\n \"ALIGNED\", _torf_(fl, ALIGNED),\n \"UPDATEIFCOPY\", _torf_(fl, UPDATEIFCOPY));\n}\n\n\nstatic PyMappingMethods arrayflags_as_mapping = {\n#if PY_VERSION_HEX >= 0x02050000\n (lenfunc)NULL, \t\t /*mp_length*/\n#else\n (inquiry)NULL, \t\t /*mp_length*/\n#endif\n (binaryfunc)arrayflags_getitem,\t /*mp_subscript*/\n (objobjargproc)arrayflags_setitem, /*mp_ass_subscript*/\n};\n\n\nstatic PyObject *\narrayflags_new(PyTypeObject *self, PyObject *args, PyObject *kwds)\n{\n PyObject *arg=NULL;\n if (!PyArg_UnpackTuple(args, \"flagsobj\", 0, 1, &arg))\n return NULL;\n\n if ((arg != NULL) && PyArray_Check(arg)) {\n return PyArray_NewFlagsObject(arg);\n }\n else {\n return PyArray_NewFlagsObject(NULL);\n }\n}\n\nstatic PyTypeObject PyArrayFlags_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\n \"numpy.flagsobj\",\n sizeof(PyArrayFlagsObject),\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayflags_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n\t0,\t\t /* tp_compare */\n (reprfunc)arrayflags_print, /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t /* tp_as_sequence */\n &arrayflags_as_mapping,\t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arrayflags_print, /* tp_str */\n 0,\t \t /* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0,\t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t /* tp_iter */\n 0,\t\t /* tp_iternext */\n 0,\t \t /* tp_methods */\n 0,\t /* tp_members */\n arrayflags_getsets, /* tp_getset */\n 0,\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t /* tp_init */\n 0,\t /* tp_alloc */\n arrayflags_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "methods": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 4, + "token_count": 76, + "parameters": [ + "obj", + "default_" + ], + "start_line": 28, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 65, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 99, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 134, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 207, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 241, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 291, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 319, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 344, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 387, + "end_line": 407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 21, + "token_count": 413, + "parameters": [ + "o" + ], + "start_line": 427, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 83, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 67, + "complexity": 19, + "token_count": 406, + "parameters": [ + "o" + ], + "start_line": 516, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 593, + "end_line": 608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 614, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 638, + "end_line": 718, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 722, + "end_line": 736, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 749, + "end_line": 775, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 781, + "end_line": 795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , PyArray_ORDER fortran)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 804, + "end_line": 825, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 17, + "token_count": 616, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 834, + "end_line": 950, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 117, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 966, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 91, + "parameters": [ + "mp" + ], + "start_line": 979, + "end_line": 1001, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 1015, + "end_line": 1055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1070, + "end_line": 1111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1118, + "end_line": 1209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1215, + "end_line": 1244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1247, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1292, + "end_line": 1329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1336, + "end_line": 1344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1347, + "end_line": 1372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , _int_or_ssize_t i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1375, + "end_line": 1378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1381, + "end_line": 1416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , _int_or_ssize_t i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1429, + "end_line": 1432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1438, + "end_line": 1446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1452, + "end_line": 1502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1509, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1558, + "end_line": 1652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1655, + "end_line": 1692, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1704, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 382, + "parameters": [ + "mit", + "op" + ], + "start_line": 1760, + "end_line": 1820, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "count_new_axes_0d", + "long_name": "count_new_axes_0d( PyObject * tuple)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 7, + "token_count": 124, + "parameters": [ + "tuple" + ], + "start_line": 1823, + "end_line": 1850, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "add_new_axes_0d", + "long_name": "add_new_axes_0d( PyArrayObject * arr , int newaxis_count)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 121, + "parameters": [ + "arr", + "newaxis_count" + ], + "start_line": 1853, + "end_line": 1872, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 1884, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 107, + "complexity": 28, + "token_count": 674, + "parameters": [ + "self", + "op" + ], + "start_line": 1970, + "end_line": 2095, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 93, + "complexity": 28, + "token_count": 588, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 2110, + "end_line": 2215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 10, + "token_count": 182, + "parameters": [ + "self", + "op" + ], + "start_line": 2224, + "end_line": 2263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , _int_or_ssize_t * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2286, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , _int_or_ssize_t segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2301, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , _int_or_ssize_t segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2320, + "end_line": 2329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , _int_or_ssize_t segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2332, + "end_line": 2343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 1, + "token_count": 182, + "parameters": [ + "dict" + ], + "start_line": 2421, + "end_line": 2458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 43, + "complexity": 2, + "token_count": 203, + "parameters": [], + "start_line": 2468, + "end_line": 2511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2514, + "end_line": 2537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2541, + "end_line": 2564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2568, + "end_line": 2575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2578, + "end_line": 2585, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2588, + "end_line": 2596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceUnaryFunction", + "long_name": "PyArray_GenericInplaceUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 40, + "parameters": [ + "m1", + "op" + ], + "start_line": 2599, + "end_line": 2606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2609, + "end_line": 2612, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2615, + "end_line": 2618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2621, + "end_line": 2624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2627, + "end_line": 2630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2633, + "end_line": 2636, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power_is_scalar", + "long_name": "array_power_is_scalar( PyObject * o2 , double * exp)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 12, + "token_count": 154, + "parameters": [ + "o2", + "exp" + ], + "start_line": 2639, + "end_line": 2665, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "fast_scalar_power", + "long_name": "fast_scalar_power( PyArrayObject * a1 , PyObject * o2 , int inplace)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 12, + "token_count": 181, + "parameters": [ + "a1", + "o2", + "inplace" + ], + "start_line": 2669, + "end_line": 2707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * a1 , PyObject * o2 , PyObject * modulo)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a1", + "o2", + "modulo" + ], + "start_line": 2710, + "end_line": 2719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2723, + "end_line": 2726, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2729, + "end_line": 2732, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2735, + "end_line": 2738, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2741, + "end_line": 2744, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2747, + "end_line": 2750, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2753, + "end_line": 2756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2759, + "end_line": 2762, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2765, + "end_line": 2768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2771, + "end_line": 2774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2777, + "end_line": 2780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2783, + "end_line": 2786, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2789, + "end_line": 2792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2795, + "end_line": 2798, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * a1 , PyObject * o2 , PyObject * modulo)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a1", + "o2", + "modulo" + ], + "start_line": 2801, + "end_line": 2810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2813, + "end_line": 2816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2819, + "end_line": 2822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2825, + "end_line": 2828, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2831, + "end_line": 2834, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2837, + "end_line": 2840, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2843, + "end_line": 2846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2849, + "end_line": 2852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2855, + "end_line": 2859, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2862, + "end_line": 2866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2870, + "end_line": 2888, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2891, + "end_line": 2908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2913, + "end_line": 2928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2932, + "end_line": 2958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2961, + "end_line": 2986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2989, + "end_line": 3011, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 3014, + "end_line": 3036, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 3039, + "end_line": 3061, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 3064, + "end_line": 3068, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , _int_or_ssize_t ilow , _int_or_ssize_t ihigh)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 12, + "token_count": 268, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 3129, + "end_line": 3170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , _int_or_ssize_t ilow , _int_or_ssize_t ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 3174, + "end_line": 3196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 3199, + "end_line": 3211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 3244, + "end_line": 3291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 3294, + "end_line": 3330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 3339, + "end_line": 3356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 3359, + "end_line": 3371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 3374, + "end_line": 3386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 90, + "complexity": 19, + "token_count": 392, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3389, + "end_line": 3495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 9, + "token_count": 181, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3498, + "end_line": 3528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3534, + "end_line": 3554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 11, + "token_count": 203, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3562, + "end_line": 3597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 7, + "token_count": 128, + "parameters": [ + "ap" + ], + "start_line": 3603, + "end_line": 3622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 7, + "token_count": 126, + "parameters": [ + "ap" + ], + "start_line": 3626, + "end_line": 3644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3647, + "end_line": 3664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3667, + "end_line": 3700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3707, + "end_line": 3734, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp offset , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 117, + "parameters": [ + "elsize", + "nd", + "numbytes", + "offset", + "dims", + "newstrides" + ], + "start_line": 3754, + "end_line": 3774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3794, + "end_line": 3818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3824, + "end_line": 3846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd , int isfortran)", + "filename": "arrayobject.c", + "nloc": 54, + "complexity": 10, + "token_count": 311, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd", + "isfortran" + ], + "start_line": 3857, + "end_line": 3919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 132, + "complexity": 29, + "token_count": 785, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3927, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 167, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape , int refcheck , PyArray_ORDER fortran)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 17, + "token_count": 524, + "parameters": [ + "self", + "newshape", + "refcheck", + "fortran" + ], + "start_line": 4106, + "end_line": 4209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 104, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 4215, + "end_line": 4232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 49, + "complexity": 8, + "token_count": 279, + "parameters": [ + "arr", + "obj" + ], + "start_line": 4236, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 22, + "token_count": 638, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 4289, + "end_line": 4423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 4427, + "end_line": 4435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4441, + "end_line": 4444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4447, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 4460, + "end_line": 4489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 4493, + "end_line": 4496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 49, + "complexity": 9, + "token_count": 304, + "parameters": [ + "self", + "obj" + ], + "start_line": 4499, + "end_line": 4553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4557, + "end_line": 4564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4567, + "end_line": 4573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4577, + "end_line": 4583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4586, + "end_line": 4600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4603, + "end_line": 4647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4651, + "end_line": 4654, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4657, + "end_line": 4668, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4671, + "end_line": 4682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4688, + "end_line": 4691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4694, + "end_line": 4698, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 449, + "parameters": [ + "self", + "arg" + ], + "start_line": 4712, + "end_line": 4799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4802, + "end_line": 4820, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4823, + "end_line": 4841, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4844, + "end_line": 4854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4858, + "end_line": 4883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 191, + "parameters": [ + "self", + "val" + ], + "start_line": 4887, + "end_line": 4920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4923, + "end_line": 4956, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 207, + "parameters": [ + "self", + "val" + ], + "start_line": 4959, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4999, + "end_line": 5002, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 348, + "parameters": [ + "self", + "val" + ], + "start_line": 5005, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 5145, + "end_line": 5152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string , int stop_at_tuple)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 19, + "token_count": 243, + "parameters": [ + "s", + "max", + "stop_at_string", + "stop_at_tuple" + ], + "start_line": 5240, + "end_line": 5273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 158, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 5276, + "end_line": 5298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 5305, + "end_line": 5331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 5337, + "end_line": 5369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_python_scalar_type", + "long_name": "_array_find_python_scalar_type( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 8, + "token_count": 120, + "parameters": [ + "op" + ], + "start_line": 5372, + "end_line": 5395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 28, + "token_count": 634, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5407, + "end_line": 5537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 5540, + "end_line": 5563, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 189, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5568, + "end_line": 5606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 57, + "complexity": 24, + "token_count": 373, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5611, + "end_line": 5678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5685, + "end_line": 5694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5700, + "end_line": 5793, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 276, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5803, + "end_line": 5849, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5859, + "end_line": 5912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromArray", + "long_name": "PyArray_FromArray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 31, + "token_count": 658, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5917, + "end_line": 6043, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 501, + "parameters": [ + "str" + ], + "start_line": 6047, + "end_line": 6155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromStructInterface", + "long_name": "PyArray_FromStructInterface( PyObject * input)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 6, + "token_count": 234, + "parameters": [ + "input" + ], + "start_line": 6159, + "end_line": 6199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromInterface", + "long_name": "PyArray_FromInterface( PyObject * input)", + "filename": "arrayobject.c", + "nloc": 129, + "complexity": 28, + "token_count": 793, + "parameters": [ + "input" + ], + "start_line": 6203, + "end_line": 6341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromArrayAttr", + "long_name": "PyArray_FromArrayAttr( PyObject * op , PyArray_Descr * typecode , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 43, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 6345, + "end_line": 6388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 67, + "complexity": 21, + "token_count": 410, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6394, + "end_line": 6478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 6483, + "end_line": 6486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 6493, + "end_line": 6506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckFromAny", + "long_name": "PyArray_CheckFromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 111, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6552, + "end_line": 6568, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 84, + "parameters": [ + "op" + ], + "start_line": 6581, + "end_line": 6597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6603, + "end_line": 6691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 132, + "parameters": [ + "from", + "to" + ], + "start_line": 6696, + "end_line": 6724, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastScalar", + "long_name": "PyArray_CanCastScalar( PyTypeObject * from , PyTypeObject * to)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "from", + "to" + ], + "start_line": 6730, + "end_line": 6740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6752, + "end_line": 6790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterAllButAxis", + "long_name": "PyArray_IterAllButAxis( PyObject * obj , int axis)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 88, + "parameters": [ + "obj", + "axis" + ], + "start_line": 6798, + "end_line": 6815, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6820, + "end_line": 6830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6833, + "end_line": 6837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 6840, + "end_line": 6843, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6847, + "end_line": 6897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6900, + "end_line": 6954, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 113, + "complexity": 23, + "token_count": 668, + "parameters": [ + "self", + "ind" + ], + "start_line": 6958, + "end_line": 7091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 134, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 7095, + "end_line": 7127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 7130, + "end_line": 7172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 115, + "complexity": 27, + "token_count": 698, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 7175, + "end_line": 7309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 7326, + "end_line": 7371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 7376, + "end_line": 7380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_coords_get", + "long_name": "iter_coords_get( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 7396, + "end_line": 7411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 106, + "parameters": [ + "obj", + "iter" + ], + "start_line": 7476, + "end_line": 7492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 7499, + "end_line": 7568, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 7572, + "end_line": 7609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7615, + "end_line": 7659, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 107, + "complexity": 23, + "token_count": 715, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7677, + "end_line": 7816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 140, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 462, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7822, + "end_line": 7894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj , int oned , int fancy)", + "filename": "arrayobject.c", + "nloc": 104, + "complexity": 24, + "token_count": 726, + "parameters": [ + "indexobj", + "oned", + "fancy" + ], + "start_line": 7897, + "end_line": 8023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 8027, + "end_line": 8036, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 8107, + "end_line": 8156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 267, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 8159, + "end_line": 8204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 8207, + "end_line": 8226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 8229, + "end_line": 8236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 8239, + "end_line": 8249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 8252, + "end_line": 8262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 8265, + "end_line": 8268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 8271, + "end_line": 8283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 8313, + "end_line": 8320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 8379, + "end_line": 8388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 8406, + "end_line": 8428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 8434, + "end_line": 8444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 8463, + "end_line": 8471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 8474, + "end_line": 8489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 5, + "token_count": 132, + "parameters": [ + "self" + ], + "start_line": 8492, + "end_line": 8514, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_base_get", + "long_name": "arraydescr_base_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 8517, + "end_line": 8525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_shape_get", + "long_name": "arraydescr_shape_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 8528, + "end_line": 8535, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 8538, + "end_line": 8557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 8564, + "end_line": 8571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 8574, + "end_line": 8581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_fields_get", + "long_name": "arraydescr_fields_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 8584, + "end_line": 8591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 272, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 8639, + "end_line": 8691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 54, + "complexity": 13, + "token_count": 395, + "parameters": [ + "self", + "args" + ], + "start_line": 8697, + "end_line": 8758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 9, + "token_count": 264, + "parameters": [ + "self", + "args" + ], + "start_line": 8766, + "end_line": 8809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8829, + "end_line": 8895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8906, + "end_line": 8914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_str", + "long_name": "arraydescr_str( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 6, + "token_count": 287, + "parameters": [ + "self" + ], + "start_line": 8929, + "end_line": 8974, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 8977, + "end_line": 8986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_compare", + "long_name": "arraydescr_compare( PyArray_Descr * self , PyObject * other)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "other" + ], + "start_line": 8989, + "end_line": 8999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "descr_length", + "long_name": "descr_length( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 6, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 9006, + "end_line": 9013, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "descr_subscript", + "long_name": "descr_subscript( PyArray_Descr * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 126, + "parameters": [ + "self", + "op" + ], + "start_line": 9016, + "end_line": 9047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFlagsObject", + "long_name": "PyArray_NewFlagsObject( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 3, + "token_count": 96, + "parameters": [ + "obj" + ], + "start_line": 9125, + "end_line": 9142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_dealloc", + "long_name": "arrayflags_dealloc( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 9145, + "end_line": 9149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_forc_get", + "long_name": "arrayflags_forc_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 9173, + "end_line": 9185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_fnc_get", + "long_name": "arrayflags_fnc_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 9188, + "end_line": 9200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_farray_get", + "long_name": "arrayflags_farray_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 9203, + "end_line": 9216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_num_get", + "long_name": "arrayflags_num_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 9219, + "end_line": 9222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_updateifcopy_set", + "long_name": "arrayflags_updateifcopy_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9226, + "end_line": 9238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_aligned_set", + "long_name": "arrayflags_aligned_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9241, + "end_line": 9254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_writeable_set", + "long_name": "arrayflags_writeable_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9257, + "end_line": 9270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_getitem", + "long_name": "arrayflags_getitem( PyArrayFlagsObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 75, + "complexity": 31, + "token_count": 431, + "parameters": [ + "self", + "ind" + ], + "start_line": 9326, + "end_line": 9401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_setitem", + "long_name": "arrayflags_setitem( PyArrayFlagsObject * self , PyObject * ind , PyObject * item)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 14, + "token_count": 219, + "parameters": [ + "self", + "ind", + "item" + ], + "start_line": 9404, + "end_line": 9424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_torf_", + "long_name": "_torf_( int flags , int val)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 27, + "parameters": [ + "flags", + "val" + ], + "start_line": 9427, + "end_line": 9431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_print", + "long_name": "arrayflags_print( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 1, + "token_count": 77, + "parameters": [ + "self" + ], + "start_line": 9434, + "end_line": 9446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_new", + "long_name": "arrayflags_new( PyTypeObject * self , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9461, + "end_line": 9473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 4, + "token_count": 76, + "parameters": [ + "obj", + "default_" + ], + "start_line": 28, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 65, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 99, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 134, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 207, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 241, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 291, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 319, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 344, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 387, + "end_line": 407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 21, + "token_count": 413, + "parameters": [ + "o" + ], + "start_line": 427, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 83, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 67, + "complexity": 19, + "token_count": 406, + "parameters": [ + "o" + ], + "start_line": 516, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 593, + "end_line": 608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 614, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 638, + "end_line": 718, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 722, + "end_line": 736, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 749, + "end_line": 775, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 781, + "end_line": 795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , PyArray_ORDER fortran)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 804, + "end_line": 825, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 17, + "token_count": 616, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 834, + "end_line": 950, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 117, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 966, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 91, + "parameters": [ + "mp" + ], + "start_line": 979, + "end_line": 1001, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 1015, + "end_line": 1055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1070, + "end_line": 1111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1118, + "end_line": 1209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1215, + "end_line": 1244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1247, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1292, + "end_line": 1329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1336, + "end_line": 1344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1347, + "end_line": 1372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , _int_or_ssize_t i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1375, + "end_line": 1378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1381, + "end_line": 1416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , _int_or_ssize_t i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1429, + "end_line": 1432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1438, + "end_line": 1446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1452, + "end_line": 1502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1509, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1558, + "end_line": 1652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1655, + "end_line": 1692, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1704, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 382, + "parameters": [ + "mit", + "op" + ], + "start_line": 1760, + "end_line": 1820, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "count_new_axes_0d", + "long_name": "count_new_axes_0d( PyObject * tuple)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 7, + "token_count": 124, + "parameters": [ + "tuple" + ], + "start_line": 1823, + "end_line": 1850, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "add_new_axes_0d", + "long_name": "add_new_axes_0d( PyArrayObject * arr , int newaxis_count)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 121, + "parameters": [ + "arr", + "newaxis_count" + ], + "start_line": 1853, + "end_line": 1872, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 1884, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 107, + "complexity": 28, + "token_count": 674, + "parameters": [ + "self", + "op" + ], + "start_line": 1970, + "end_line": 2095, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 93, + "complexity": 28, + "token_count": 588, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 2110, + "end_line": 2215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 10, + "token_count": 182, + "parameters": [ + "self", + "op" + ], + "start_line": 2224, + "end_line": 2263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , _int_or_ssize_t * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2286, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , _int_or_ssize_t segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2301, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , _int_or_ssize_t segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2320, + "end_line": 2329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , _int_or_ssize_t segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2332, + "end_line": 2343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 1, + "token_count": 182, + "parameters": [ + "dict" + ], + "start_line": 2421, + "end_line": 2458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 43, + "complexity": 2, + "token_count": 203, + "parameters": [], + "start_line": 2468, + "end_line": 2511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2514, + "end_line": 2537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2541, + "end_line": 2564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2568, + "end_line": 2575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2578, + "end_line": 2585, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2588, + "end_line": 2596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceUnaryFunction", + "long_name": "PyArray_GenericInplaceUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 40, + "parameters": [ + "m1", + "op" + ], + "start_line": 2599, + "end_line": 2606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2609, + "end_line": 2612, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2615, + "end_line": 2618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2621, + "end_line": 2624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2627, + "end_line": 2630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2633, + "end_line": 2636, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power_is_scalar", + "long_name": "array_power_is_scalar( PyObject * o2 , double * exp)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 12, + "token_count": 154, + "parameters": [ + "o2", + "exp" + ], + "start_line": 2639, + "end_line": 2665, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "fast_scalar_power", + "long_name": "fast_scalar_power( PyArrayObject * a1 , PyObject * o2 , int inplace)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 12, + "token_count": 181, + "parameters": [ + "a1", + "o2", + "inplace" + ], + "start_line": 2669, + "end_line": 2707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * a1 , PyObject * o2 , PyObject * modulo)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a1", + "o2", + "modulo" + ], + "start_line": 2710, + "end_line": 2719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2723, + "end_line": 2726, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2729, + "end_line": 2732, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2735, + "end_line": 2738, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2741, + "end_line": 2744, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2747, + "end_line": 2750, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2753, + "end_line": 2756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2759, + "end_line": 2762, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2765, + "end_line": 2768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2771, + "end_line": 2774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2777, + "end_line": 2780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2783, + "end_line": 2786, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2789, + "end_line": 2792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2795, + "end_line": 2798, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * a1 , PyObject * o2 , PyObject * modulo)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a1", + "o2", + "modulo" + ], + "start_line": 2801, + "end_line": 2810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2813, + "end_line": 2816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2819, + "end_line": 2822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2825, + "end_line": 2828, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2831, + "end_line": 2834, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2837, + "end_line": 2840, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2843, + "end_line": 2846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2849, + "end_line": 2852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2855, + "end_line": 2859, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2862, + "end_line": 2866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2870, + "end_line": 2888, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2891, + "end_line": 2908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2913, + "end_line": 2928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2932, + "end_line": 2958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2961, + "end_line": 2986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2989, + "end_line": 3011, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 3014, + "end_line": 3036, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 3039, + "end_line": 3061, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 3064, + "end_line": 3068, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , _int_or_ssize_t ilow , _int_or_ssize_t ihigh)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 12, + "token_count": 268, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 3129, + "end_line": 3170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , _int_or_ssize_t ilow , _int_or_ssize_t ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 3174, + "end_line": 3196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 3199, + "end_line": 3211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 3244, + "end_line": 3291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 3294, + "end_line": 3330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 3339, + "end_line": 3356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 3359, + "end_line": 3371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 3374, + "end_line": 3386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 90, + "complexity": 19, + "token_count": 392, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3389, + "end_line": 3495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 9, + "token_count": 181, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3498, + "end_line": 3528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3534, + "end_line": 3554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 11, + "token_count": 203, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3562, + "end_line": 3597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 7, + "token_count": 128, + "parameters": [ + "ap" + ], + "start_line": 3603, + "end_line": 3622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 7, + "token_count": 126, + "parameters": [ + "ap" + ], + "start_line": 3626, + "end_line": 3644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3647, + "end_line": 3664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3667, + "end_line": 3700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3707, + "end_line": 3734, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp offset , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 117, + "parameters": [ + "elsize", + "nd", + "numbytes", + "offset", + "dims", + "newstrides" + ], + "start_line": 3754, + "end_line": 3774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3794, + "end_line": 3818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3824, + "end_line": 3846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd , int isfortran)", + "filename": "arrayobject.c", + "nloc": 54, + "complexity": 10, + "token_count": 311, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd", + "isfortran" + ], + "start_line": 3857, + "end_line": 3919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 132, + "complexity": 29, + "token_count": 785, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3927, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 167, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape , int refcheck , PyArray_ORDER fortran)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 17, + "token_count": 524, + "parameters": [ + "self", + "newshape", + "refcheck", + "fortran" + ], + "start_line": 4106, + "end_line": 4209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 104, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 4215, + "end_line": 4232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 49, + "complexity": 8, + "token_count": 279, + "parameters": [ + "arr", + "obj" + ], + "start_line": 4236, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 22, + "token_count": 638, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 4289, + "end_line": 4423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 4427, + "end_line": 4435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4441, + "end_line": 4444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4447, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 4460, + "end_line": 4489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 4493, + "end_line": 4496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 49, + "complexity": 9, + "token_count": 304, + "parameters": [ + "self", + "obj" + ], + "start_line": 4499, + "end_line": 4553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4557, + "end_line": 4564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4567, + "end_line": 4573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4577, + "end_line": 4583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4586, + "end_line": 4600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4603, + "end_line": 4647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4651, + "end_line": 4654, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4657, + "end_line": 4668, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4671, + "end_line": 4682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4688, + "end_line": 4691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4694, + "end_line": 4698, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 449, + "parameters": [ + "self", + "arg" + ], + "start_line": 4712, + "end_line": 4799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4802, + "end_line": 4820, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4823, + "end_line": 4841, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4844, + "end_line": 4854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4858, + "end_line": 4883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 191, + "parameters": [ + "self", + "val" + ], + "start_line": 4887, + "end_line": 4920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4923, + "end_line": 4956, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 207, + "parameters": [ + "self", + "val" + ], + "start_line": 4959, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4999, + "end_line": 5002, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 348, + "parameters": [ + "self", + "val" + ], + "start_line": 5005, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 5145, + "end_line": 5152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string , int stop_at_tuple)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 19, + "token_count": 243, + "parameters": [ + "s", + "max", + "stop_at_string", + "stop_at_tuple" + ], + "start_line": 5240, + "end_line": 5273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 158, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 5276, + "end_line": 5298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 5305, + "end_line": 5331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 5337, + "end_line": 5369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_python_scalar_type", + "long_name": "_array_find_python_scalar_type( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 8, + "token_count": 120, + "parameters": [ + "op" + ], + "start_line": 5372, + "end_line": 5395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 28, + "token_count": 634, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5407, + "end_line": 5537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 5540, + "end_line": 5563, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 189, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5568, + "end_line": 5606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 57, + "complexity": 24, + "token_count": 373, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5611, + "end_line": 5678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5685, + "end_line": 5694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5700, + "end_line": 5793, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 276, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5803, + "end_line": 5849, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5859, + "end_line": 5912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromArray", + "long_name": "PyArray_FromArray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 31, + "token_count": 658, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5917, + "end_line": 6043, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 501, + "parameters": [ + "str" + ], + "start_line": 6047, + "end_line": 6155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromStructInterface", + "long_name": "PyArray_FromStructInterface( PyObject * input)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 6, + "token_count": 234, + "parameters": [ + "input" + ], + "start_line": 6159, + "end_line": 6199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromInterface", + "long_name": "PyArray_FromInterface( PyObject * input)", + "filename": "arrayobject.c", + "nloc": 129, + "complexity": 28, + "token_count": 793, + "parameters": [ + "input" + ], + "start_line": 6203, + "end_line": 6341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromArrayAttr", + "long_name": "PyArray_FromArrayAttr( PyObject * op , PyArray_Descr * typecode , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 43, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 6345, + "end_line": 6388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 67, + "complexity": 21, + "token_count": 410, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6394, + "end_line": 6478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 6483, + "end_line": 6486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 6493, + "end_line": 6506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckFromAny", + "long_name": "PyArray_CheckFromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires , PyObject * context)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 111, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6552, + "end_line": 6568, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 84, + "parameters": [ + "op" + ], + "start_line": 6581, + "end_line": 6597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6603, + "end_line": 6691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 132, + "parameters": [ + "from", + "to" + ], + "start_line": 6696, + "end_line": 6724, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastScalar", + "long_name": "PyArray_CanCastScalar( PyTypeObject * from , PyTypeObject * to)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "from", + "to" + ], + "start_line": 6730, + "end_line": 6740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6752, + "end_line": 6790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterAllButAxis", + "long_name": "PyArray_IterAllButAxis( PyObject * obj , int axis)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 88, + "parameters": [ + "obj", + "axis" + ], + "start_line": 6798, + "end_line": 6815, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6820, + "end_line": 6830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6833, + "end_line": 6837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 6840, + "end_line": 6843, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6847, + "end_line": 6897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6900, + "end_line": 6954, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 113, + "complexity": 23, + "token_count": 668, + "parameters": [ + "self", + "ind" + ], + "start_line": 6958, + "end_line": 7091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 134, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 7095, + "end_line": 7127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 7130, + "end_line": 7172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 115, + "complexity": 27, + "token_count": 698, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 7175, + "end_line": 7309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 7326, + "end_line": 7371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 7376, + "end_line": 7380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_coords_get", + "long_name": "iter_coords_get( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 7396, + "end_line": 7411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 106, + "parameters": [ + "obj", + "iter" + ], + "start_line": 7476, + "end_line": 7492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 7499, + "end_line": 7568, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 7572, + "end_line": 7609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7615, + "end_line": 7659, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 107, + "complexity": 23, + "token_count": 715, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7677, + "end_line": 7816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 140, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 462, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7822, + "end_line": 7894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj , int oned , int fancy)", + "filename": "arrayobject.c", + "nloc": 104, + "complexity": 24, + "token_count": 726, + "parameters": [ + "indexobj", + "oned", + "fancy" + ], + "start_line": 7897, + "end_line": 8023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 8027, + "end_line": 8036, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 8107, + "end_line": 8156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 267, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 8159, + "end_line": 8204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 8207, + "end_line": 8226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 8229, + "end_line": 8236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 8239, + "end_line": 8249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 8252, + "end_line": 8262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 8265, + "end_line": 8268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 8271, + "end_line": 8283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 8313, + "end_line": 8320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 8379, + "end_line": 8388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 8406, + "end_line": 8428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 8434, + "end_line": 8444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 8463, + "end_line": 8471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 8474, + "end_line": 8489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 5, + "token_count": 132, + "parameters": [ + "self" + ], + "start_line": 8492, + "end_line": 8514, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_base_get", + "long_name": "arraydescr_base_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 8517, + "end_line": 8525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_shape_get", + "long_name": "arraydescr_shape_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 8528, + "end_line": 8535, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 8538, + "end_line": 8557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 8564, + "end_line": 8571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 8574, + "end_line": 8581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_fields_get", + "long_name": "arraydescr_fields_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 8584, + "end_line": 8591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 272, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 8639, + "end_line": 8691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 54, + "complexity": 13, + "token_count": 395, + "parameters": [ + "self", + "args" + ], + "start_line": 8697, + "end_line": 8758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8766, + "end_line": 8808, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8828, + "end_line": 8894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8905, + "end_line": 8913, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_str", + "long_name": "arraydescr_str( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 6, + "token_count": 287, + "parameters": [ + "self" + ], + "start_line": 8928, + "end_line": 8973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 8976, + "end_line": 8985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_compare", + "long_name": "arraydescr_compare( PyArray_Descr * self , PyObject * other)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "other" + ], + "start_line": 8988, + "end_line": 8998, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "descr_length", + "long_name": "descr_length( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 6, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 9005, + "end_line": 9012, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "descr_subscript", + "long_name": "descr_subscript( PyArray_Descr * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 126, + "parameters": [ + "self", + "op" + ], + "start_line": 9015, + "end_line": 9046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFlagsObject", + "long_name": "PyArray_NewFlagsObject( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 3, + "token_count": 96, + "parameters": [ + "obj" + ], + "start_line": 9124, + "end_line": 9141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_dealloc", + "long_name": "arrayflags_dealloc( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 9144, + "end_line": 9148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_forc_get", + "long_name": "arrayflags_forc_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 9172, + "end_line": 9184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_fnc_get", + "long_name": "arrayflags_fnc_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 9187, + "end_line": 9199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_farray_get", + "long_name": "arrayflags_farray_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 9202, + "end_line": 9215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_num_get", + "long_name": "arrayflags_num_get( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 9218, + "end_line": 9221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_updateifcopy_set", + "long_name": "arrayflags_updateifcopy_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9225, + "end_line": 9237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_aligned_set", + "long_name": "arrayflags_aligned_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9240, + "end_line": 9253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_writeable_set", + "long_name": "arrayflags_writeable_set( PyArrayFlagsObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 4, + "token_count": 83, + "parameters": [ + "self", + "obj" + ], + "start_line": 9256, + "end_line": 9269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_getitem", + "long_name": "arrayflags_getitem( PyArrayFlagsObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 75, + "complexity": 31, + "token_count": 431, + "parameters": [ + "self", + "ind" + ], + "start_line": 9325, + "end_line": 9400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_setitem", + "long_name": "arrayflags_setitem( PyArrayFlagsObject * self , PyObject * ind , PyObject * item)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 14, + "token_count": 219, + "parameters": [ + "self", + "ind", + "item" + ], + "start_line": 9403, + "end_line": 9423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_torf_", + "long_name": "_torf_( int flags , int val)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 27, + "parameters": [ + "flags", + "val" + ], + "start_line": 9426, + "end_line": 9430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_print", + "long_name": "arrayflags_print( PyArrayFlagsObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 1, + "token_count": 77, + "parameters": [ + "self" + ], + "start_line": 9433, + "end_line": 9445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arrayflags_new", + "long_name": "arrayflags_new( PyTypeObject * self , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9460, + "end_line": 9472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 9, + "token_count": 264, + "parameters": [ + "self", + "args" + ], + "start_line": 8766, + "end_line": 8809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + } + ], + "nloc": 7564, + "complexity": 1636, + "token_count": 43892, + "diff_parsed": { + "added": [ + "\tif (endian != '|' &&", + "\t PyArray_IsNativeByteOrder(endian)) endian = '=';" + ], + "deleted": [ + "\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';" + ] + } + }, + { + "old_path": "numpy/core/src/scalarmathmodule.c.src", + "new_path": "numpy/core/src/scalarmathmodule.c.src", + "filename": "scalarmathmodule.c.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -35,8 +35,8 @@\n other = b; \\\n } \\\n else { \\\n- self = a; \\\n- other = b; \\\n+ self = b; \\\n+ other = a; \\\n if (!PyObject_IsScalar(self, @NAME@)) { \\\n Py_INCREF(Py_NotImplemented); \\\n return Py_NotImplemented; \\\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "/* -*- c -*- */\n\n/* The purpose of this module is to add faster math for array scalars\n that does not go through the ufunc machinery \n\n but still supports error-modes. \n\n NOT FINISHED\n */\n\n#include \"numpy/arrayobject.h\"\n#include \"numpy/ufuncobject.h\"\n\n\n/* The general strategy is to\n\n1) Make self the array scalar and \"other\" the other data-type\n2) If both are the same data-type, then do a quick exit.\n3) If other is another array scalar, then\n a) If it can be cast then cast and calculate\n b) Otherwise, return NotImplemented \n (or call the appropriate function on other... ---\n shortcut what Python will do anyway). \n4) If other is a 0-d array\n -- Cast it to an array scalar and do #3\n5) If other is a Python scalar\n -- Cast it to an array scalar and do #3\n5) Go through the ufunc machinery for all other cases. \n\n*/\n\n#define _CREATE_SELF_OTHER(a, b, NAME) { \\\n if PyObject_IsScalar(a, NAME) { \\\n self = a; \\\n other = b; \\\n } \\\n else { \\\n self = b; \\\n other = a; \\\n if (!PyObject_IsScalar(self, @NAME@)) { \\\n Py_INCREF(Py_NotImplemented); \\\n return Py_NotImplemented; \\\n } \\\n } \\\n } \n\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n#Name=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n**/\n\nstatic PyObject *\n@name@_add(PyObject *a, PyObject *b)\n{\n PyObject *self, *other, *arg3, *temp;\n\n _CREATE_SELF_OTHER(a, b, @NAME@);\n \n if PyObject_IsScalar(other, @NAME@) {\n arg3 = other;\n Py_INCREF(arg3);\n }\n else if ((temp = _object_to_scalar(other)) != NULL) {\n \n }\n\n \n}\n\nstatic PyObject *\n@name@_subtract(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_multiply(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_divide(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_remainder(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_divmod(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_power(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_negative(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_copy(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_absolute(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_nonzero_number(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_invert(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_lshift(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_rshift(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_and(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_xor(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_or(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_int(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_long(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_float(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_oct(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_hex(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_floor_divide(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_true_divide(PyObject *a, PyObject *b)\n{\n}\n\n#if PY_VERSION_HEX >= 0x02050000\nstatic Py_ssize_t\n@name@_index(PyObject *a)\n{\n}\n#endif\n\n\nstatic PyObject*\n@name@_richcompare(PyObject *self, PyObject *other, int cmp_op)\n{\n}\n/**end repeat**/\n\n\n\n\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n**/\nstatic PyNumberMethods @name@_as_number = {\n (binaryfunc)@name@_add, /*nb_add*/\n (binaryfunc)@name@_subtract, /*nb_subtract*/\n (binaryfunc)@name@_multiply, /*nb_multiply*/\n (binaryfunc)@name@_divide, /*nb_divide*/\n (binaryfunc)@name@_remainder, /*nb_remainder*/\n (binaryfunc)@name@_divmod, /*nb_divmod*/\n (ternaryfunc)@name@_power, /*nb_power*/\n (unaryfunc)@name@_negative,\n (unaryfunc)@name@_copy, /*nb_pos*/\n (unaryfunc)@name@_absolute, /*nb_abs*/\n (inquiry)@name@_nonzero_number, /*nb_nonzero*/\n (unaryfunc)@name@_invert, /*nb_invert*/\n (binaryfunc)@name@_lshift, /*nb_lshift*/\n (binaryfunc)@name@_rshift, /*nb_rshift*/\n (binaryfunc)@name@_and, /*nb_and*/\n (binaryfunc)@name@_xor, /*nb_xor*/\n (binaryfunc)@name@_or, /*nb_or*/\n 0, /*nb_coerce*/\n (unaryfunc)@name@_int, /*nb_int*/\n (unaryfunc)@name@_long, /*nb_long*/\n (unaryfunc)@name@_float, /*nb_float*/\n (unaryfunc)@name@_oct, /*nb_oct*/\n (unaryfunc)@name@_hex, /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)@name@_floor_divide, /*nb_floor_divide*/\n (binaryfunc)@name@_true_divide, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n#if PY_VERSION_HEX >= 0x02050000\n\t(lenfunc)@name@_index, /*nb_index*/\n#endif\n};\n\nstatic void\nadd_scalarmath(void)\n{\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n**/\n\tPyArr@NAME@Type_Type.tp_as_number = @name@_as_number;\n\tPyArr@NAME@Type_Type.tp_richcompare = @name@_richcompare;\n/**end repeat**/\n}\n\n\n\nstatic struct PyMethodDef methods[] = {\n\t{\"alter_pyscalars\", (PyCFunction) alter_pyscalars,\n\t METH_VARARGS , doc_alterpyscalars},\n\t{NULL, NULL, 0}\n};\n\nDL_EXPORT(void) initscalarmath(void) {\n\tPyObject *m;\n\n\tm = Py_initModule(\"scalarmath\", methods);\n\t\n\tif (import_array() < 0) return;\n\tif (import_umath() < 0) return;\n\n\tadd_scalarmath();\n\t\n\treturn;\n}\n", + "source_code_before": "/* -*- c -*- */\n\n/* The purpose of this module is to add faster math for array scalars\n that does not go through the ufunc machinery \n\n but still supports error-modes. \n\n NOT FINISHED\n */\n\n#include \"numpy/arrayobject.h\"\n#include \"numpy/ufuncobject.h\"\n\n\n/* The general strategy is to\n\n1) Make self the array scalar and \"other\" the other data-type\n2) If both are the same data-type, then do a quick exit.\n3) If other is another array scalar, then\n a) If it can be cast then cast and calculate\n b) Otherwise, return NotImplemented \n (or call the appropriate function on other... ---\n shortcut what Python will do anyway). \n4) If other is a 0-d array\n -- Cast it to an array scalar and do #3\n5) If other is a Python scalar\n -- Cast it to an array scalar and do #3\n5) Go through the ufunc machinery for all other cases. \n\n*/\n\n#define _CREATE_SELF_OTHER(a, b, NAME) { \\\n if PyObject_IsScalar(a, NAME) { \\\n self = a; \\\n other = b; \\\n } \\\n else { \\\n self = a; \\\n other = b; \\\n if (!PyObject_IsScalar(self, @NAME@)) { \\\n Py_INCREF(Py_NotImplemented); \\\n return Py_NotImplemented; \\\n } \\\n } \\\n } \n\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n#Name=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n**/\n\nstatic PyObject *\n@name@_add(PyObject *a, PyObject *b)\n{\n PyObject *self, *other, *arg3, *temp;\n\n _CREATE_SELF_OTHER(a, b, @NAME@);\n \n if PyObject_IsScalar(other, @NAME@) {\n arg3 = other;\n Py_INCREF(arg3);\n }\n else if ((temp = _object_to_scalar(other)) != NULL) {\n \n }\n\n \n}\n\nstatic PyObject *\n@name@_subtract(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_multiply(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_divide(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_remainder(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_divmod(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_power(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_negative(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_copy(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_absolute(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_nonzero_number(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_invert(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_lshift(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_rshift(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_and(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_xor(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_or(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_int(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_long(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_float(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_oct(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_hex(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_floor_divide(PyObject *a, PyObject *b)\n{\n}\n\nstatic PyObject *\n@name@_true_divide(PyObject *a, PyObject *b)\n{\n}\n\n#if PY_VERSION_HEX >= 0x02050000\nstatic Py_ssize_t\n@name@_index(PyObject *a)\n{\n}\n#endif\n\n\nstatic PyObject*\n@name@_richcompare(PyObject *self, PyObject *other, int cmp_op)\n{\n}\n/**end repeat**/\n\n\n\n\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n**/\nstatic PyNumberMethods @name@_as_number = {\n (binaryfunc)@name@_add, /*nb_add*/\n (binaryfunc)@name@_subtract, /*nb_subtract*/\n (binaryfunc)@name@_multiply, /*nb_multiply*/\n (binaryfunc)@name@_divide, /*nb_divide*/\n (binaryfunc)@name@_remainder, /*nb_remainder*/\n (binaryfunc)@name@_divmod, /*nb_divmod*/\n (ternaryfunc)@name@_power, /*nb_power*/\n (unaryfunc)@name@_negative,\n (unaryfunc)@name@_copy, /*nb_pos*/\n (unaryfunc)@name@_absolute, /*nb_abs*/\n (inquiry)@name@_nonzero_number, /*nb_nonzero*/\n (unaryfunc)@name@_invert, /*nb_invert*/\n (binaryfunc)@name@_lshift, /*nb_lshift*/\n (binaryfunc)@name@_rshift, /*nb_rshift*/\n (binaryfunc)@name@_and, /*nb_and*/\n (binaryfunc)@name@_xor, /*nb_xor*/\n (binaryfunc)@name@_or, /*nb_or*/\n 0, /*nb_coerce*/\n (unaryfunc)@name@_int, /*nb_int*/\n (unaryfunc)@name@_long, /*nb_long*/\n (unaryfunc)@name@_float, /*nb_float*/\n (unaryfunc)@name@_oct, /*nb_oct*/\n (unaryfunc)@name@_hex, /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)@name@_floor_divide, /*nb_floor_divide*/\n (binaryfunc)@name@_true_divide, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n#if PY_VERSION_HEX >= 0x02050000\n\t(lenfunc)@name@_index, /*nb_index*/\n#endif\n};\n\nstatic void\nadd_scalarmath(void)\n{\n/**begin repeat\n#name=byte,ubyte,short,ushort,int,uint,long,ulong,float,double,longdouble,cfloat,cdouble,clongdouble#\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n**/\n\tPyArr@NAME@Type_Type.tp_as_number = @name@_as_number;\n\tPyArr@NAME@Type_Type.tp_richcompare = @name@_richcompare;\n/**end repeat**/\n}\n\n\n\nstatic struct PyMethodDef methods[] = {\n\t{\"alter_pyscalars\", (PyCFunction) alter_pyscalars,\n\t METH_VARARGS , doc_alterpyscalars},\n\t{NULL, NULL, 0}\n};\n\nDL_EXPORT(void) initscalarmath(void) {\n\tPyObject *m;\n\n\tm = Py_initModule(\"scalarmath\", methods);\n\t\n\tif (import_array() < 0) return;\n\tif (import_umath() < 0) return;\n\n\tadd_scalarmath();\n\t\n\treturn;\n}\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + " self = b; \\", + " other = a; \\" + ], + "deleted": [ + " self = a; \\", + " other = b; \\" + ] + } + } + ] + }, + { + "hash": "471196b6dfc3f45decc18dc34e044842e5fa2c21", + "msg": "Introduced configuration kw argument to setup. This fixes long lasted long configuration messages when setup command line has only help request or errors.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T08:59:36+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T08:59:36+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "da78766309515905b4016ac494dac384fe80a5fd" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 72, + "insertions": 102, + "lines": 174, + "files": 3, + "dmm_unit_size": 0.17647058823529413, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/core.py", + "new_path": "numpy/distutils/core.py", + "filename": "core.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -47,6 +47,45 @@\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n \n+def _dict_append(d, **kws):\n+ for k,v in kws.items():\n+ if not d.has_key(k):\n+ d[k] = v\n+ continue\n+ dv = d[k]\n+ if isinstance(dv, tuple):\n+ dv += tuple(v)\n+ continue\n+ if isinstance(dv, list):\n+ dv += list(v)\n+ continue\n+ if isinstance(dv, dict):\n+ _dict_append(dv, **v)\n+ continue\n+ if isinstance(dv, str):\n+ assert isinstance(v,str),`type(v)`\n+ d[k] = v\n+ raise TypeError,`type(dv)`\n+ return\n+\n+def _command_line_ok(_cache=[]):\n+ \"\"\" Return True if command line does not contain any\n+ help or display requests.\n+ \"\"\"\n+ if _cache:\n+ return _cache[0]\n+ ok = True\n+ display_opts = ['--'+n for n in Distribution.display_option_names]\n+ for o in Distribution.display_options:\n+ if o[1]:\n+ display_opts.append('-'+o[1])\n+ for arg in sys.argv:\n+ if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n+ ok = False\n+ break\n+ _cache.append(ok)\n+ return ok\n+\n def setup(**attr):\n \n cmdclass = numpy_cmdclass.copy()\n@@ -56,6 +95,33 @@ def setup(**attr):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n \n+ if new_attr.has_key('configuration'):\n+ # To avoid calling configuration if there are any errors\n+ # or help request in command in the line.\n+ configuration = new_attr.pop('configuration')\n+\n+ import distutils.core\n+ old_dist = distutils.core._setup_distribution\n+ old_stop = distutils.core._setup_stop_after\n+ distutils.core._setup_distribution = None\n+ distutils.core._setup_stop_after = \"commandline\"\n+ try:\n+ dist = setup(**new_attr)\n+ distutils.core._setup_distribution = old_dist\n+ distutils.core._setup_stop_after = old_stop\n+ except Exception,msg:\n+ distutils.core._setup_distribution = old_dist\n+ distutils.core._setup_stop_after = old_stop\n+ raise msg\n+ if dist.help or not _command_line_ok():\n+ # probably displayed help, skip running any commands\n+ return dist\n+\n+ # create setup dictionary and append to new_attr\n+ config = configuration()\n+ if hasattr(config,'todict'): config = config.todict()\n+ _dict_append(new_attr, **config)\n+\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n", + "added_lines": 66, + "deleted_lines": 0, + "source_code": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from setuptools.command import bdist_egg, develop, easy_install\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef _dict_append(d, **kws):\n for k,v in kws.items():\n if not d.has_key(k):\n d[k] = v\n continue\n dv = d[k]\n if isinstance(dv, tuple):\n dv += tuple(v)\n continue\n if isinstance(dv, list):\n dv += list(v)\n continue\n if isinstance(dv, dict):\n _dict_append(dv, **v)\n continue\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n raise TypeError,`type(dv)`\n return\n\ndef _command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n if new_attr.has_key('configuration'):\n # To avoid calling configuration if there are any errors\n # or help request in command in the line.\n configuration = new_attr.pop('configuration')\n\n import distutils.core\n old_dist = distutils.core._setup_distribution\n old_stop = distutils.core._setup_stop_after\n distutils.core._setup_distribution = None\n distutils.core._setup_stop_after = \"commandline\"\n try:\n dist = setup(**new_attr)\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n except Exception,msg:\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n raise msg\n if dist.help or not _command_line_ok():\n # probably displayed help, skip running any commands\n return dist\n\n # create setup dictionary and append to new_attr\n config = configuration()\n if hasattr(config,'todict'): config = config.todict()\n _dict_append(new_attr, **config)\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "source_code_before": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from setuptools.command import bdist_egg, develop, easy_install\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "methods": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 20, + "complexity": 7, + "token_count": 125, + "parameters": [ + "d", + "kws" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 71, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 89, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 153, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 181, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 29, + "complexity": 12, + "token_count": 196, + "parameters": [ + "attr" + ], + "start_line": 50, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 87, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 115, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 20, + "complexity": 7, + "token_count": 125, + "parameters": [ + "d", + "kws" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 89, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 71, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "nloc": 170, + "complexity": 49, + "token_count": 1066, + "diff_parsed": { + "added": [ + "def _dict_append(d, **kws):", + " for k,v in kws.items():", + " if not d.has_key(k):", + " d[k] = v", + " continue", + " dv = d[k]", + " if isinstance(dv, tuple):", + " dv += tuple(v)", + " continue", + " if isinstance(dv, list):", + " dv += list(v)", + " continue", + " if isinstance(dv, dict):", + " _dict_append(dv, **v)", + " continue", + " if isinstance(dv, str):", + " assert isinstance(v,str),`type(v)`", + " d[k] = v", + " raise TypeError,`type(dv)`", + " return", + "", + "def _command_line_ok(_cache=[]):", + " \"\"\" Return True if command line does not contain any", + " help or display requests.", + " \"\"\"", + " if _cache:", + " return _cache[0]", + " ok = True", + " display_opts = ['--'+n for n in Distribution.display_option_names]", + " for o in Distribution.display_options:", + " if o[1]:", + " display_opts.append('-'+o[1])", + " for arg in sys.argv:", + " if arg.startswith('--help') or arg=='-h' or arg in display_opts:", + " ok = False", + " break", + " _cache.append(ok)", + " return ok", + "", + " if new_attr.has_key('configuration'):", + " # To avoid calling configuration if there are any errors", + " # or help request in command in the line.", + " configuration = new_attr.pop('configuration')", + "", + " import distutils.core", + " old_dist = distutils.core._setup_distribution", + " old_stop = distutils.core._setup_stop_after", + " distutils.core._setup_distribution = None", + " distutils.core._setup_stop_after = \"commandline\"", + " try:", + " dist = setup(**new_attr)", + " distutils.core._setup_distribution = old_dist", + " distutils.core._setup_stop_after = old_stop", + " except Exception,msg:", + " distutils.core._setup_distribution = old_dist", + " distutils.core._setup_stop_after = old_stop", + " raise msg", + " if dist.help or not _command_line_ok():", + " # probably displayed help, skip running any commands", + " return dist", + "", + " # create setup dictionary and append to new_attr", + " config = configuration()", + " if hasattr(config,'todict'): config = config.todict()", + " _dict_append(new_attr, **config)", + "" + ], + "deleted": [] + } + }, + { + "old_path": "numpy/distutils/misc_util.py", + "new_path": "numpy/distutils/misc_util.py", + "filename": "misc_util.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1252,50 +1252,6 @@ def get_info(self,*names):\n dict_append(info_dict,**get_info(a))\n return info_dict\n \n-class BadConfiguration(Configuration):\n- \"\"\"\n- When the command line is not ok, use this as the configuration class.\n- \"\"\"\n- def _do_nothing(self, *args, **kw):\n- pass\n- add_subpackage = _do_nothing\n- add_extension = _do_nothing\n- add_library = _do_nothing\n- add_data_dir = _do_nothing\n- add_data_files = _do_nothing\n- add_scripts = _do_nothing\n- add_headers = _do_nothing\n- add_include_dirs = _do_nothing\n- make_config_py = _do_nothing\n-\n- def get_info(self, *args, **kw):\n- return {}\n- def have_f77c(self, *args, **kw):\n- return False\n- def have_f90c(self, *args, **kw):\n- return False\n-\n-def command_line_ok(_cache=[]):\n- \"\"\" Return True if command line does not contain any\n- help or display requests.\n- \"\"\"\n- if _cache:\n- return _cache[0]\n- ok = True\n- from distutils.dist import Distribution\n- display_opts = ['--'+n for n in Distribution.display_option_names]\n- for o in Distribution.display_options:\n- if o[1]:\n- display_opts.append('-'+o[1])\n- for arg in sys.argv:\n- if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n- ok = False\n- break\n- _cache.append(ok)\n- return ok\n-\n-if not command_line_ok():\n- Configuration = BadConfiguration\n \n def get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n", + "added_lines": 0, + "deleted_lines": 44, + "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return '*' in s or '?' is s\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return '*' in s or '?' is s\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\nclass BadConfiguration(Configuration):\n \"\"\"\n When the command line is not ok, use this as the configuration class.\n \"\"\"\n def _do_nothing(self, *args, **kw):\n pass\n add_subpackage = _do_nothing\n add_extension = _do_nothing\n add_library = _do_nothing\n add_data_dir = _do_nothing\n add_data_files = _do_nothing\n add_scripts = _do_nothing\n add_headers = _do_nothing\n add_include_dirs = _do_nothing\n make_config_py = _do_nothing\n\n def get_info(self, *args, **kw):\n return {}\n def have_f77c(self, *args, **kw):\n return False\n def have_f90c(self, *args, **kw):\n return False\n\ndef command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n from distutils.dist import Distribution\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\nif not command_line_ok():\n Configuration = BadConfiguration\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "methods": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 2, + "token_count": 13, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 57, + "complexity": 15, + "token_count": 350, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 910, + "end_line": 919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 921, + "end_line": 941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 943, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 951, + "end_line": 958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 960, + "end_line": 1023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1025, + "end_line": 1047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1049, + "end_line": 1058, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1060, + "end_line": 1075, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1077, + "end_line": 1087, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1089, + "end_line": 1098, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1100, + "end_line": 1103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1105, + "end_line": 1116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1118, + "end_line": 1129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1131, + "end_line": 1144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1146, + "end_line": 1157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1159, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1228, + "end_line": 1232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1217, + "end_line": 1235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1207, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1239, + "end_line": 1244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1246, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1256, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1268, + "end_line": 1282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1286, + "end_line": 1297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1300, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1307, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1328, + "end_line": 1361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 2, + "token_count": 13, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 57, + "complexity": 15, + "token_count": 350, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 910, + "end_line": 919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 921, + "end_line": 941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 943, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 951, + "end_line": 958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 960, + "end_line": 1023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1025, + "end_line": 1047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1049, + "end_line": 1058, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1060, + "end_line": 1075, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1077, + "end_line": 1087, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1089, + "end_line": 1098, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1100, + "end_line": 1103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1105, + "end_line": 1116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1118, + "end_line": 1129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1131, + "end_line": 1144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1146, + "end_line": 1157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1159, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1228, + "end_line": 1232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1217, + "end_line": 1235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1207, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1239, + "end_line": 1244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1246, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_do_nothing", + "long_name": "_do_nothing( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1259, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1271, + "end_line": 1272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1273, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1275, + "end_line": 1276, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "command_line_ok", + "long_name": "command_line_ok( _cache = [ ] )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 9, + "token_count": 98, + "parameters": [ + "_cache" + ], + "start_line": 1278, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1300, + "end_line": 1310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1312, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1330, + "end_line": 1341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1344, + "end_line": 1349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1351, + "end_line": 1370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1372, + "end_line": 1405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "have_f90c", + "long_name": "have_f90c( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1275, + "end_line": 1276, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_do_nothing", + "long_name": "_do_nothing( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1259, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1273, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "command_line_ok", + "long_name": "command_line_ok( _cache = [ ] )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 9, + "token_count": 98, + "parameters": [ + "_cache" + ], + "start_line": 1278, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "get_info", + "long_name": "get_info( self , * args , ** kw )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "args", + "kw" + ], + "start_line": 1271, + "end_line": 1272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "nloc": 1022, + "complexity": 323, + "token_count": 7069, + "diff_parsed": { + "added": [], + "deleted": [ + "class BadConfiguration(Configuration):", + " \"\"\"", + " When the command line is not ok, use this as the configuration class.", + " \"\"\"", + " def _do_nothing(self, *args, **kw):", + " pass", + " add_subpackage = _do_nothing", + " add_extension = _do_nothing", + " add_library = _do_nothing", + " add_data_dir = _do_nothing", + " add_data_files = _do_nothing", + " add_scripts = _do_nothing", + " add_headers = _do_nothing", + " add_include_dirs = _do_nothing", + " make_config_py = _do_nothing", + "", + " def get_info(self, *args, **kw):", + " return {}", + " def have_f77c(self, *args, **kw):", + " return False", + " def have_f90c(self, *args, **kw):", + " return False", + "", + "def command_line_ok(_cache=[]):", + " \"\"\" Return True if command line does not contain any", + " help or display requests.", + " \"\"\"", + " if _cache:", + " return _cache[0]", + " ok = True", + " from distutils.dist import Distribution", + " display_opts = ['--'+n for n in Distribution.display_option_names]", + " for o in Distribution.display_options:", + " if o[1]:", + " display_opts.append('-'+o[1])", + " for arg in sys.argv:", + " if arg.startswith('--help') or arg=='-h' or arg in display_opts:", + " ok = False", + " break", + " _cache.append(ok)", + " return ok", + "", + "if not command_line_ok():", + " Configuration = BadConfiguration" + ] + } + }, + { + "old_path": "setup.py", + "new_path": "setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -31,10 +31,42 @@\n Operating System :: MacOS\n \"\"\"\n \n+def configuration(parent_package='',top_path=None):\n+ from numpy.distutils.misc_util import Configuration\n+\n+ config = Configuration(None, parent_package, top_path,\n+ maintainer = \"NumPy Developers\",\n+ maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n+ description = DOCLINES[0],\n+ long_description = \"\\n\".join(DOCLINES[2:]),\n+ url = \"http://numeric.scipy.org\",\n+ download_url = \"http://sourceforge.net/projects/numpy\",\n+ license = 'BSD',\n+ classifiers=filter(None, CLASSIFIERS.split('\\n')),\n+ author = \"Travis E. Oliphant, et.al.\",\n+ author_email = \"oliphant@ee.byu.edu\",\n+ platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n+ )\n+ config.set_options(ignore_setup_xxx_py=True,\n+ assume_default_configuration=True,\n+ delegate_options_to_subpackages=True,\n+ quiet=True)\n+ \n+ config.add_subpackage('numpy')\n+\n+\n+ config.name = 'numpy'\n+ #config.dict_append(version=version)\n+ #print config.name,'version',config.version\n+ \n+ config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n+ 'scipy_compatibility']))\n+ \n+ return config\n+\n def setup_package():\n \n from numpy.distutils.core import setup\n- from numpy.distutils.misc_util import Configuration\n \n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n@@ -42,35 +74,11 @@ def setup_package():\n sys.path.insert(0,local_path)\n \n try:\n- config = Configuration(\n- maintainer = \"NumPy Developers\",\n- maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n- description = DOCLINES[0],\n- long_description = \"\\n\".join(DOCLINES[2:]),\n- url = \"http://numeric.scipy.org\",\n- download_url = \"http://sourceforge.net/projects/numpy\",\n- license = 'BSD',\n- classifiers=filter(None, CLASSIFIERS.split('\\n')),\n- author = \"Travis E. Oliphant, et.al.\",\n- author_email = \"oliphant@ee.byu.edu\",\n- platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n- )\n- config.set_options(ignore_setup_xxx_py=True,\n- assume_default_configuration=True,\n- delegate_options_to_subpackages=True,\n- quiet=True)\n-\n- config.add_subpackage('numpy')\n \n from numpy.version import version\n- config.name = 'numpy'\n- config.dict_append(version=version)\n- #print config.name,'version',config.version\n-\n- config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n- 'scipy_compatibility']))\n-\n- setup( **config.todict() )\n+ setup( configuration=configuration,\n+ version = version\n+ )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n", + "added_lines": 36, + "deleted_lines": 28, + "source_code": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n\n config = Configuration(None, parent_package, top_path,\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n )\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n\n\n config.name = 'numpy'\n #config.dict_append(version=version)\n #print config.name,'version',config.version\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n \n return config\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n\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\n from numpy.version import version\n setup( configuration=configuration,\n version = version\n )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "source_code_before": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n from numpy.distutils.misc_util import Configuration\n\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 config = Configuration(\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n )\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n\n config.add_subpackage('numpy')\n\n from numpy.version import version\n config.name = 'numpy'\n config.dict_append(version=version)\n #print config.name,'version',config.version\n\n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n\n setup( **config.todict() )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 24, + "complexity": 1, + "token_count": 155, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 15, + "complexity": 2, + "token_count": 91, + "parameters": [], + "start_line": 67, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 36, + "complexity": 2, + "token_count": 234, + "parameters": [], + "start_line": 34, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 24, + "complexity": 1, + "token_count": 155, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 15, + "complexity": 2, + "token_count": 91, + "parameters": [], + "start_line": 67, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "nloc": 70, + "complexity": 3, + "token_count": 272, + "diff_parsed": { + "added": [ + "def configuration(parent_package='',top_path=None):", + " from numpy.distutils.misc_util import Configuration", + "", + " config = Configuration(None, parent_package, top_path,", + " maintainer = \"NumPy Developers\",", + " maintainer_email = \"numpy-discussion@lists.sourceforge.net\",", + " description = DOCLINES[0],", + " long_description = \"\\n\".join(DOCLINES[2:]),", + " url = \"http://numeric.scipy.org\",", + " download_url = \"http://sourceforge.net/projects/numpy\",", + " license = 'BSD',", + " classifiers=filter(None, CLASSIFIERS.split('\\n')),", + " author = \"Travis E. Oliphant, et.al.\",", + " author_email = \"oliphant@ee.byu.edu\",", + " platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],", + " )", + " config.set_options(ignore_setup_xxx_py=True,", + " assume_default_configuration=True,", + " delegate_options_to_subpackages=True,", + " quiet=True)", + "", + " config.add_subpackage('numpy')", + "", + "", + " config.name = 'numpy'", + " #config.dict_append(version=version)", + " #print config.name,'version',config.version", + "", + " config.add_data_files(('numpy',['*.txt','COMPATIBILITY',", + " 'scipy_compatibility']))", + "", + " return config", + "", + " setup( configuration=configuration,", + " version = version", + " )" + ], + "deleted": [ + " from numpy.distutils.misc_util import Configuration", + " config = Configuration(", + " maintainer = \"NumPy Developers\",", + " maintainer_email = \"numpy-discussion@lists.sourceforge.net\",", + " description = DOCLINES[0],", + " long_description = \"\\n\".join(DOCLINES[2:]),", + " url = \"http://numeric.scipy.org\",", + " download_url = \"http://sourceforge.net/projects/numpy\",", + " license = 'BSD',", + " classifiers=filter(None, CLASSIFIERS.split('\\n')),", + " author = \"Travis E. Oliphant, et.al.\",", + " author_email = \"oliphant@ee.byu.edu\",", + " platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],", + " )", + " config.set_options(ignore_setup_xxx_py=True,", + " assume_default_configuration=True,", + " delegate_options_to_subpackages=True,", + " quiet=True)", + "", + " config.add_subpackage('numpy')", + " config.name = 'numpy'", + " config.dict_append(version=version)", + " #print config.name,'version',config.version", + "", + " config.add_data_files(('numpy',['*.txt','COMPATIBILITY',", + " 'scipy_compatibility']))", + "", + " setup( **config.todict() )" + ] + } + } + ] + }, + { + "hash": "d1573150a33df8c6eaf95189a6dcd6ee6f0c48ad", + "msg": "Hint for using new setup configuration kw argument.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T09:03:37+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T09:03:37+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "471196b6dfc3f45decc18dc34e044842e5fa2c21" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 1, + "insertions": 2, + "lines": 3, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/doc/DISTUTILS.txt", + "new_path": "numpy/doc/DISTUTILS.txt", + "filename": "DISTUTILS.txt", + "extension": "txt", + "change_type": "MODIFY", + "diff": "@@ -74,7 +74,8 @@ Here follows a minimal example for a pure Python SciPy package\n \n if __name__ == \"__main__\":\n from numpy.distutils.core import setup\n- setup(**configuration(top_path='').todict())\n+ #setup(**configuration(top_path='').todict())\n+ setup(configuration=configuration)\n \n The first argument ``parent_package`` of the main configuration\n function will contain a name of the parent SciPy package and the\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": ".. -*- rest -*-\n\nNumPy Distutils - Users Guide\n=============================\n\n:Author: Pearu Peterson \n:Discussions to: scipy-dev@scipy.org\n:Created: October 2005\n:Revision: $LastChangedRevision$\n:SVN source: $HeadURL$\n\nSciPy structure\n'''''''''''''''\n\nCurrently SciPy project consists of two packages:\n\n- NumPy (previously called SciPy core) --- it provides packages like:\n\n + numpy.distutils - extension to Python distutils\n + numpy.f2py - a tool to bind Fortran/C codes to Python\n + numpy.core - future replacement of Numeric and numarray packages\n + numpy.lib - extra utility functions\n + numpy.testing - numpy-style tools for unit testing\n + etc\n\n- SciPy --- a collection of scientific tools for Python.\n\nThe aim of this document is to describe how to add new tools to SciPy.\n\n\nRequirements for SciPy packages\n'''''''''''''''''''''''''''''''\n\nSciPy consists of Python packages, called SciPy packages, that are\navailable to Python users via ``scipy`` name space. Each SciPy package\nmay contain other SciPy packages. And so on. So, SciPy directory tree\nis a tree of packages with arbitrary depth and width. Any SciPy\npackage may depend on NumPy packages but the dependence on other\nSciPy packages should be kept minimal or zero.\n\nA SciPy package contains in addition to its sources, the following\nfiles and directories:\n\n ``setup.py`` --- building script\n ``info.py`` --- contains documentation and import flags\n ``__init__.py`` --- package initializer\n ``tests/`` --- directory of unittests\n\nTheir contents will be described below.\n\nThe ``setup.py`` file\n'''''''''''''''''''''\n\nIn order to add a Python package to SciPy, its building script (the\n``setup.py`` file) must meet certain requirements. The minimal and the\nmost important one is that it must define a function\n``configuration(parent_package='',top_path=None)`` that returns a\ndictionary suitable for passing to ``numpy.distutils.core.setup(..)``\nfunction. In order to simplify the construction of such an distionary,\n``numpy.distutils.misc_util`` provides a class ``Configuration``, the\nusage of will be described below.\n\nSciPy pure Python package example\n---------------------------------\n\nHere follows a minimal example for a pure Python SciPy package\n``setup.py`` file that will be explained in detail below::\n\n #!/usr/bin/env python\n def configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n config = Configuration('mypackage',parent_package,top_path)\n return config\n\n if __name__ == \"__main__\":\n from numpy.distutils.core import setup\n #setup(**configuration(top_path='').todict())\n setup(configuration=configuration)\n\nThe first argument ``parent_package`` of the main configuration\nfunction will contain a name of the parent SciPy package and the\nsecond argument ``top_path`` contains the name of the directory where\nthe main ``setup.py`` script is located. Both arguments should be\npassed to the ``Configuration`` constructor after the name of the\ncurrent package.\n\nThe ``Configuration`` constructor has also fourth optional argument,\n``package_path``, that can be used when package files are located in\nsome other location than the directory of the ``setup.py`` file. \n\nRemaining ``Configuration`` arguments are all keyword arguments that will\nbe used to initialize attributes of ``Configuration``\ninstance. Usually, these keywords are the same as the ones that\n``setup(..)`` function would expect, for example, ``packages``,\n``ext_modules``, ``data_files``, ``include_dirs``, ``libraries``,\n``headers``, ``scripts``, ``package_dir``, etc. However, the direct\nspecification of these keywords is not recommended as the content of\nthese keyword arguments will not be processed or checked for the\nconsistency of SciPy building system.\n\nFinally, ``Configuration`` has ``.todict()`` method that returns all\nthe configuration data as a dictionary suitable for passing on to the\n``setup(..)`` function.\n\n``Configuration`` instance attributes\n-------------------------------------\n\nIn addition to attributes that can be specified via keyword arguments\nto ``Configuration`` constructor, ``Configuration`` instance (let us\ndenote as ``config``) has the following attributes that can be useful\nin writing setup scripts:\n\n+ ``config.name`` - full name of the current package. The names of parent\n packages can be extracted as ``config.name.split('.')``.\n\n+ ``config.local_path`` - path to the location of current ``setup.py`` file.\n\n+ ``config.top_path`` - path to the location of main ``setup.py`` file.\n\n``Configuration`` instance methods\n----------------------------------\n\n+ ``config.todict()`` --- returns configuration distionary suitable for\n passing to ``numpy.distutils.core.setup(..)`` function.\n\n+ ``config.paths(*paths) --- applies ``glob.glob(..)`` to items of\n ``paths`` if necessary. Fixes ``paths`` item that is relative to\n ``config.local_path``.\n\n+ ``config.get_subpackage(subpackage_name,subpackage_path=None)`` ---\n returns a list of subpackage configurations. Subpackage is looked in the\n current directory under the name ``subpackage_name`` but the path\n can be specified also via optional ``subpackage_path`` argument.\n If ``subpackage_name`` is specified as ``None`` then the subpackage\n name will be taken the basename of ``subpackage_path``.\n Any ``*`` used for subpackage names are expanded as wildcards.\n\n+ ``config.add_subpackage(subpackage_name,subpackage_path=None)`` ---\n add SciPy subpackage configuration to the current one. The meaning\n and usage of arguments is explained above, see\n ``config.get_subpackage()`` method.\n\n+ ``config.add_data_files(*files)`` --- prepend ``files`` to ``data_files``\n list. If ``files`` item is a tuple then its first element defines\n the suffix of where data files are copied relative to package installation\n directory and the second element specifies the path to data\n files. By default data files are copied under package installation\n directory. For example,\n\n ::\n\n config.add_data_files('foo.dat',\n\t ('fun',['gun.dat','nun/pun.dat','/tmp/sun.dat']),\n 'bar/car.dat'.\n '/full/path/to/can.dat',\n )\n\n will install data files to the following locations\n\n ::\n\n /\n foo.dat\n fun/\n gun.dat\n\tpun.dat\n sun.dat\n bar/\n car.dat\n can.dat \n\n Path to data files can be a function taking no arguments and\n returning path(s) to data files -- this is a useful when data files\n are generated while building the package. (XXX: explain the step\n when this function are called exactly) \n\n+ ``config.add_data_dir(data_path)`` --- add directory ``data_path``\n recursively to ``data_files``. The whole directory tree starting at\n ``data_path`` will be copied under package installation directory.\n If ``data_path`` is a tuple then its first element defines\n the suffix of where data files are copied relative to package installation\n directory and the second element specifies the path to data directory.\n By default, data directory are copied under package installation\n directory under the basename of ``data_path``. For example,\n \n ::\n\n config.add_data_dir('fun') # fun/ contains foo.dat bar/car.dat\n config.add_data_dir(('sun','fun'))\n config.add_data_dir(('gun','/full/path/to/fun'))\n\n will install data files to the following locations \n\n ::\n\n /\n fun/\n foo.dat\n bar/\n car.dat\n sun/\n foo.dat\n bar/\n car.dat\n gun/\n foo.dat\n bar/\n car.dat\n\n+ ``config.add_include_dirs(*paths)`` --- prepend ``paths`` to\n ``include_dirs`` list. This list will be visible to all extension\n modules of the current package.\n\n+ ``config.add_headers(*files)`` --- prepend ``files`` to ``headers``\n list. By default, headers will be installed under \n ``/include/pythonX.X//``\n directory. If ``files`` item is a tuple then it's first argument\n specifies the installation suffix relative to\n ``/include/pythonX.X/`` path.\n\n+ ``config.add_scripts(*files)`` --- prepend ``files`` to ``scripts``\n list. Scripts will be installed under ``/bin/`` directory.\n\n+ ``config.add_extension(name,sources,*kw)`` --- create and add an\n ``Extension`` instance to ``ext_modules`` list. The first argument \n ``name`` defines the name of the extension module that will be\n installed under ``config.name`` package. The second argument is\n a list of sources. ``add_extension`` method takes also keyword\n arguments that are passed on to the ``Extension`` constructor.\n The list of allowed keywords is the following: ``include_dirs``,\n ``define_macros``, ``undef_macros``, ``library_dirs``, ``libraries``,\n ``runtime_library_dirs``, ``extra_objects``, ``extra_compile_args``,\n ``extra_link_args``, ``export_symbols``, ``swig_opts``, ``depends``,\n ``language``, ``f2py_options``, ``module_dirs``, ``extra_info``.\n\n Note that ``config.paths`` method is applied to all lists that\n may contain paths. ``extra_info`` is a dictionary or a list\n of dictionaries that content will be appended to keyword arguments.\n The list ``depends`` contains paths to files or directories\n that the sources of the extension module depend on. If any path\n in the ``depends`` list is newer than the extension module, then\n the module will be rebuilt.\n\n The list of sources may contain functions ('source generators')\n with a pattern ``def (ext, build_dir): return\n ``. If ``funcname`` returns ``None``, no sources\n are generated. And if the ``Extension`` instance has no sources\n after processing all source generators, no extension module will\n be built. This is the recommended way to conditionally define\n extension modules. Source generator functions are called by the\n ``build_src`` command of ``numpy.distutils``.\n\n For example, here is a typical source generator function::\n\n def generate_source(ext,build_dir):\n import os\n from distutils.dep_util import newer\n target = os.path.join(build_dir,'somesource.c')\n if newer(target,__file__):\n # create target file\n return target\n\n The first argument contains the Extension instance that can be\n useful to access its attributes like ``depends``, ``sources``,\n etc. lists and modify them during the building process.\n The second argument gives a path to a build directory that must\n be used when creating files to a disk.\n\n+ ``config.add_library(name, sources, **build_info)`` --- add\n a library to ``libraries`` list. Allowed keywords arguments\n are ``depends``, ``macros``, ``include_dirs``,\n ``extra_compiler_args``, ``f2py_options``. See ``.add_extension()``\n method for more information on arguments.\n\n+ ``config.have_f77c()`` --- return True if Fortran 77 compiler is\n available (read: a simple Fortran 77 code compiled succesfully). \n\n+ ``config.have_f90c()`` --- return True if Fortran 90 compiler is\n available (read: a simple Fortran 90 code compiled succesfully). \n\n+ ``config.get_version()`` --- return version string of the current package,\n ``None`` if version information could not be detected. This methods\n scans files ``__version__.py``, ``_version.py``,\n ``version.py``, ``__svn_version__.py`` for string variables\n ``version``, ``__version__``, ``_version``.\n\n+ ``config.make_svn_version_py()`` --- appends a data function to\n ``data_files`` list that will generate ``__svn_version__.py`` file\n to the current package directory. The file will be removed from\n the source directory when Python exits.\n\n+ ``config.get_build_temp_dir()`` --- return a path to a temporary\n directory. This is the place where one should build temporary\n files.\n\n+ ``config.get_distribution()`` --- return distutils ``Distribution``\n instance.\n\n+ ``config.get_config_cmd()`` --- returns ``numpy.distutils`` config\n command instance.\n\n+ ``config.get_info(*names)`` ---\n\nTemplate files\n--------------\n\nXXX: Describe how files with extensions ``.f.src``, ``.pyf.src``,\n``.c.src``, etc. are pre-processed by the ``build_src`` command.\n\nUseful functions in ``numpy.distutils.misc_util``\n-------------------------------------------------\n\n+ ``get_numpy_include_dirs()`` --- return a list of NumPy base\n include directories. NumPy base include directories contain\n header files such as ``numpy/arrayobject.h``, ``numpy/funcobject.h``\n etc. For installed NumPy the returned list has length 1\n but when building NumPy the list may contain more directories,\n for example, a path to ``config.h`` file that\n ``numpy/base/setup.py`` file generates and is used by ``numpy``\n header files.\n\n+ ``append_path(prefix,path)`` --- smart append ``path`` to ``prefix``.\n\n+ ``gpaths(paths, local_path='')`` --- apply glob to paths and prepend\n ``local_path`` if needed.\n\n+ ``njoin(*path)`` --- join pathname components + convert ``/``-separated path\n to ``os.sep``-separated path and resolve ``..``, ``.`` from paths.\n Ex. ``njoin('a',['b','./c'],'..','g') -> os.path.join('a','b','g')``.\n\n+ ``minrelpath(path)`` --- resolves dots in ``path``.\n\n+ ``rel_path(path, parent_path)`` --- return ``path`` relative to ``parent_path``.\n\n+ ``def get_cmd(cmdname,_cache={})`` --- returns ``numpy.distutils``\n command instance.\n\n+ ``all_strings(lst)``\n\n+ ``has_f_sources(sources)``\n\n+ ``has_cxx_sources(sources)``\n\n+ ``filter_sources(sources)`` --- return ``c_sources, cxx_sources,\n f_sources, fmodule_sources``\n\n+ ``get_dependencies(sources)``\n\n+ ``is_local_src_dir(directory)``\n\n+ ``get_ext_source_files(ext)``\n\n+ ``get_script_files(scripts)``\n\n+ ``get_lib_source_files(lib)``\n\n+ ``get_data_files(data)``\n\n+ ``dot_join(*args)`` --- join non-zero arguments with a dot.\n\n+ ``get_frame(level=0)`` --- return frame object from call stack with given level.\n\n+ ``cyg2win32(path)``\n\n+ ``mingw32()`` --- return ``True`` when using mingw32 environment.\n\n+ ``terminal_has_colors()``, ``red_text(s)``, ``green_text(s)``,\n ``yellow_text(s)``, ``blue_text(s)``, ``cyan_text(s)``\n\n+ ``get_path(mod_name,parent_path=None)`` --- return path of a module\n relative to parent_path when given. Handles also ``__main__`` and\n ``__builtin__`` modules.\n\n+ ``allpath(name)`` --- replaces ``/`` with ``os.sep`` in ``name``.\n\n+ ``cxx_ext_match``, ``fortran_ext_match``, ``f90_ext_match``,\n ``f90_module_name_match``\n\n``numpy.distutils.system_info`` module\n--------------------------------------\n\n+ ``get_info(name,notfound_action=0)``\n+ ``combine_paths(*args,**kws)``\n+ ``show_all()``\n\n``numpy.distutils.cpuinfo`` module\n----------------------------------\n\n+ ``cpuinfo``\n\n``numpy.distutils.log`` module\n------------------------------\n\n+ ``set_verbosity(v)``\n\n\n``numpy.distutils.exec_command`` module\n---------------------------------------\n\n+ ``get_pythonexe()``\n+ ``splitcmdline(line)``\n+ ``find_executable(exe, path=None)``\n+ ``exec_command( command, execute_in='', use_shell=None, use_tee=None, **env )``\n\nThe ``info.py`` file\n''''''''''''''''''''\n\nScipy package import hooks assume that each Scipy package contains\n``info.py`` file that contains overall documentation about the package\nand some variables defining the order of package imports, dependence\nrelations between packages, etc.\n\nThe following information will be looked in the ``info.py`` file:\n\n__doc__\n The documentation string of the package.\n\n__doc_title__\n The title of the package. If not defined then the first non-empty \n line of ``__doc__`` will be used.\n\n__all__\n List of symbols that package exports. Optional.\n\nglobal_symbols\n List of names that should be imported to numpy name space. To import\n all symbols to ``numpy`` namespace, define ``global_symbols=['*']``.\n\ndepends\n List of names that the package depends on. Prefix ``numpy.``\n will be automatically added to package names. For example,\n use ``testing`` to indicate dependence on ``numpy.testing``\n package. Default value is ``[]``.\n\npostpone_import\n Boolean variable indicating that importing the package should be\n postponed until the first attempt of its usage. Default value is ``False``.\n Depreciated.\n\nThe ``__init__.py`` file\n''''''''''''''''''''''''\n\nTo speed up the import time as well as to minimize memory usage, numpy\nuses ppimport hooks to transparently postpone importing large modules\nthat might not be used during the Scipy usage session. But in order to\nhave an access to the documentation of all Scipy packages, including \nof the postponed packages, the documentation string of a package (that would\nusually reside in ``__init__.py`` file) should be copied also\nto ``info.py`` file.\n\nSo, the header a typical ``__init__.py`` file is::\n\n #\n # Package ... - ...\n #\n\n from info import __doc__\n ...\n\n from numpy.testing import ScipyTest\n test = ScipyTest().test\n\nThe ``tests/`` directory\n''''''''''''''''''''''''\n\nIdeally, every Python code, extension module, or subpackage in Scipy\npackage directory should have the corresponding ``test_.py``\nfile in ``tests/`` directory. This file should define classes\nderived from ``ScipyTestCase`` (or from ``unittest.TestCase``) class\nand have names starting with ``test``. The methods of these classes\nwhich names start with ``bench``, ``check``, or ``test``, are passed\non to unittest machinery. In addition, the value of the first optional\nargument of these methods determine the level of the corresponding\ntest. Default level is 1.\n\nA minimal example of a ``test_yyy.py`` file that implements tests for\na Scipy package module ``numpy.xxx.yyy`` containing a function\n``zzz()``, is shown below::\n\n import sys\n from numpy.testing import *\n\n set_package_path()\n # import xxx symbols\n from xxx.yyy import zzz\n restore_path()\n\n #Optional:\n set_local_path()\n # import modules that are located in the same directory as this file.\n restore_path()\n\n class test_zzz(ScipyTestCase):\n def check_simple(self, level=1):\n assert zzz()=='Hello from zzz'\n #...\n\n if __name__ == \"__main__\":\n ScipyTest().run()\n\n``ScipyTestCase`` is derived from ``unittest.TestCase`` and it\nbasically only implements an additional method ``measure(self,\ncode_str, times=1)``.\n\n``numpy.testing`` module provides also the following convenience\nfunctions::\n\n assert_equal(actual,desired,err_msg='',verbose=1)\n assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1)\n assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1)\n assert_array_equal(x,y,err_msg='')\n assert_array_almost_equal(x,y,decimal=6,err_msg='')\n rand(*shape) # returns random array with a given shape\n\n``ScipyTest`` can be used for running ``tests/test_*.py`` scripts.\nFor instance, to run all test scripts of the module ``xxx``, execute\nin Python:\n\n >>> ScipyTest('xxx').test(level=1,verbosity=1)\n\nor equivalently,\n\n >>> import xxx\n >>> ScipyTest(xxx).test(level=1,verbosity=1)\n\nTo run only tests for ``xxx.yyy`` module, execute:\n\n >>> ScipyTest('xxx.yyy').test(level=1,verbosity=1)\n\nTo take the level and verbosity parameters for tests from\n``sys.argv``, use ``ScipyTest.run()`` method (this is supported only\nwhen ``optparse`` is installed).\n", + "source_code_before": ".. -*- rest -*-\n\nNumPy Distutils - Users Guide\n=============================\n\n:Author: Pearu Peterson \n:Discussions to: scipy-dev@scipy.org\n:Created: October 2005\n:Revision: $LastChangedRevision$\n:SVN source: $HeadURL$\n\nSciPy structure\n'''''''''''''''\n\nCurrently SciPy project consists of two packages:\n\n- NumPy (previously called SciPy core) --- it provides packages like:\n\n + numpy.distutils - extension to Python distutils\n + numpy.f2py - a tool to bind Fortran/C codes to Python\n + numpy.core - future replacement of Numeric and numarray packages\n + numpy.lib - extra utility functions\n + numpy.testing - numpy-style tools for unit testing\n + etc\n\n- SciPy --- a collection of scientific tools for Python.\n\nThe aim of this document is to describe how to add new tools to SciPy.\n\n\nRequirements for SciPy packages\n'''''''''''''''''''''''''''''''\n\nSciPy consists of Python packages, called SciPy packages, that are\navailable to Python users via ``scipy`` name space. Each SciPy package\nmay contain other SciPy packages. And so on. So, SciPy directory tree\nis a tree of packages with arbitrary depth and width. Any SciPy\npackage may depend on NumPy packages but the dependence on other\nSciPy packages should be kept minimal or zero.\n\nA SciPy package contains in addition to its sources, the following\nfiles and directories:\n\n ``setup.py`` --- building script\n ``info.py`` --- contains documentation and import flags\n ``__init__.py`` --- package initializer\n ``tests/`` --- directory of unittests\n\nTheir contents will be described below.\n\nThe ``setup.py`` file\n'''''''''''''''''''''\n\nIn order to add a Python package to SciPy, its building script (the\n``setup.py`` file) must meet certain requirements. The minimal and the\nmost important one is that it must define a function\n``configuration(parent_package='',top_path=None)`` that returns a\ndictionary suitable for passing to ``numpy.distutils.core.setup(..)``\nfunction. In order to simplify the construction of such an distionary,\n``numpy.distutils.misc_util`` provides a class ``Configuration``, the\nusage of will be described below.\n\nSciPy pure Python package example\n---------------------------------\n\nHere follows a minimal example for a pure Python SciPy package\n``setup.py`` file that will be explained in detail below::\n\n #!/usr/bin/env python\n def configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n config = Configuration('mypackage',parent_package,top_path)\n return config\n\n if __name__ == \"__main__\":\n from numpy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n\nThe first argument ``parent_package`` of the main configuration\nfunction will contain a name of the parent SciPy package and the\nsecond argument ``top_path`` contains the name of the directory where\nthe main ``setup.py`` script is located. Both arguments should be\npassed to the ``Configuration`` constructor after the name of the\ncurrent package.\n\nThe ``Configuration`` constructor has also fourth optional argument,\n``package_path``, that can be used when package files are located in\nsome other location than the directory of the ``setup.py`` file. \n\nRemaining ``Configuration`` arguments are all keyword arguments that will\nbe used to initialize attributes of ``Configuration``\ninstance. Usually, these keywords are the same as the ones that\n``setup(..)`` function would expect, for example, ``packages``,\n``ext_modules``, ``data_files``, ``include_dirs``, ``libraries``,\n``headers``, ``scripts``, ``package_dir``, etc. However, the direct\nspecification of these keywords is not recommended as the content of\nthese keyword arguments will not be processed or checked for the\nconsistency of SciPy building system.\n\nFinally, ``Configuration`` has ``.todict()`` method that returns all\nthe configuration data as a dictionary suitable for passing on to the\n``setup(..)`` function.\n\n``Configuration`` instance attributes\n-------------------------------------\n\nIn addition to attributes that can be specified via keyword arguments\nto ``Configuration`` constructor, ``Configuration`` instance (let us\ndenote as ``config``) has the following attributes that can be useful\nin writing setup scripts:\n\n+ ``config.name`` - full name of the current package. The names of parent\n packages can be extracted as ``config.name.split('.')``.\n\n+ ``config.local_path`` - path to the location of current ``setup.py`` file.\n\n+ ``config.top_path`` - path to the location of main ``setup.py`` file.\n\n``Configuration`` instance methods\n----------------------------------\n\n+ ``config.todict()`` --- returns configuration distionary suitable for\n passing to ``numpy.distutils.core.setup(..)`` function.\n\n+ ``config.paths(*paths) --- applies ``glob.glob(..)`` to items of\n ``paths`` if necessary. Fixes ``paths`` item that is relative to\n ``config.local_path``.\n\n+ ``config.get_subpackage(subpackage_name,subpackage_path=None)`` ---\n returns a list of subpackage configurations. Subpackage is looked in the\n current directory under the name ``subpackage_name`` but the path\n can be specified also via optional ``subpackage_path`` argument.\n If ``subpackage_name`` is specified as ``None`` then the subpackage\n name will be taken the basename of ``subpackage_path``.\n Any ``*`` used for subpackage names are expanded as wildcards.\n\n+ ``config.add_subpackage(subpackage_name,subpackage_path=None)`` ---\n add SciPy subpackage configuration to the current one. The meaning\n and usage of arguments is explained above, see\n ``config.get_subpackage()`` method.\n\n+ ``config.add_data_files(*files)`` --- prepend ``files`` to ``data_files``\n list. If ``files`` item is a tuple then its first element defines\n the suffix of where data files are copied relative to package installation\n directory and the second element specifies the path to data\n files. By default data files are copied under package installation\n directory. For example,\n\n ::\n\n config.add_data_files('foo.dat',\n\t ('fun',['gun.dat','nun/pun.dat','/tmp/sun.dat']),\n 'bar/car.dat'.\n '/full/path/to/can.dat',\n )\n\n will install data files to the following locations\n\n ::\n\n /\n foo.dat\n fun/\n gun.dat\n\tpun.dat\n sun.dat\n bar/\n car.dat\n can.dat \n\n Path to data files can be a function taking no arguments and\n returning path(s) to data files -- this is a useful when data files\n are generated while building the package. (XXX: explain the step\n when this function are called exactly) \n\n+ ``config.add_data_dir(data_path)`` --- add directory ``data_path``\n recursively to ``data_files``. The whole directory tree starting at\n ``data_path`` will be copied under package installation directory.\n If ``data_path`` is a tuple then its first element defines\n the suffix of where data files are copied relative to package installation\n directory and the second element specifies the path to data directory.\n By default, data directory are copied under package installation\n directory under the basename of ``data_path``. For example,\n \n ::\n\n config.add_data_dir('fun') # fun/ contains foo.dat bar/car.dat\n config.add_data_dir(('sun','fun'))\n config.add_data_dir(('gun','/full/path/to/fun'))\n\n will install data files to the following locations \n\n ::\n\n /\n fun/\n foo.dat\n bar/\n car.dat\n sun/\n foo.dat\n bar/\n car.dat\n gun/\n foo.dat\n bar/\n car.dat\n\n+ ``config.add_include_dirs(*paths)`` --- prepend ``paths`` to\n ``include_dirs`` list. This list will be visible to all extension\n modules of the current package.\n\n+ ``config.add_headers(*files)`` --- prepend ``files`` to ``headers``\n list. By default, headers will be installed under \n ``/include/pythonX.X//``\n directory. If ``files`` item is a tuple then it's first argument\n specifies the installation suffix relative to\n ``/include/pythonX.X/`` path.\n\n+ ``config.add_scripts(*files)`` --- prepend ``files`` to ``scripts``\n list. Scripts will be installed under ``/bin/`` directory.\n\n+ ``config.add_extension(name,sources,*kw)`` --- create and add an\n ``Extension`` instance to ``ext_modules`` list. The first argument \n ``name`` defines the name of the extension module that will be\n installed under ``config.name`` package. The second argument is\n a list of sources. ``add_extension`` method takes also keyword\n arguments that are passed on to the ``Extension`` constructor.\n The list of allowed keywords is the following: ``include_dirs``,\n ``define_macros``, ``undef_macros``, ``library_dirs``, ``libraries``,\n ``runtime_library_dirs``, ``extra_objects``, ``extra_compile_args``,\n ``extra_link_args``, ``export_symbols``, ``swig_opts``, ``depends``,\n ``language``, ``f2py_options``, ``module_dirs``, ``extra_info``.\n\n Note that ``config.paths`` method is applied to all lists that\n may contain paths. ``extra_info`` is a dictionary or a list\n of dictionaries that content will be appended to keyword arguments.\n The list ``depends`` contains paths to files or directories\n that the sources of the extension module depend on. If any path\n in the ``depends`` list is newer than the extension module, then\n the module will be rebuilt.\n\n The list of sources may contain functions ('source generators')\n with a pattern ``def (ext, build_dir): return\n ``. If ``funcname`` returns ``None``, no sources\n are generated. And if the ``Extension`` instance has no sources\n after processing all source generators, no extension module will\n be built. This is the recommended way to conditionally define\n extension modules. Source generator functions are called by the\n ``build_src`` command of ``numpy.distutils``.\n\n For example, here is a typical source generator function::\n\n def generate_source(ext,build_dir):\n import os\n from distutils.dep_util import newer\n target = os.path.join(build_dir,'somesource.c')\n if newer(target,__file__):\n # create target file\n return target\n\n The first argument contains the Extension instance that can be\n useful to access its attributes like ``depends``, ``sources``,\n etc. lists and modify them during the building process.\n The second argument gives a path to a build directory that must\n be used when creating files to a disk.\n\n+ ``config.add_library(name, sources, **build_info)`` --- add\n a library to ``libraries`` list. Allowed keywords arguments\n are ``depends``, ``macros``, ``include_dirs``,\n ``extra_compiler_args``, ``f2py_options``. See ``.add_extension()``\n method for more information on arguments.\n\n+ ``config.have_f77c()`` --- return True if Fortran 77 compiler is\n available (read: a simple Fortran 77 code compiled succesfully). \n\n+ ``config.have_f90c()`` --- return True if Fortran 90 compiler is\n available (read: a simple Fortran 90 code compiled succesfully). \n\n+ ``config.get_version()`` --- return version string of the current package,\n ``None`` if version information could not be detected. This methods\n scans files ``__version__.py``, ``_version.py``,\n ``version.py``, ``__svn_version__.py`` for string variables\n ``version``, ``__version__``, ``_version``.\n\n+ ``config.make_svn_version_py()`` --- appends a data function to\n ``data_files`` list that will generate ``__svn_version__.py`` file\n to the current package directory. The file will be removed from\n the source directory when Python exits.\n\n+ ``config.get_build_temp_dir()`` --- return a path to a temporary\n directory. This is the place where one should build temporary\n files.\n\n+ ``config.get_distribution()`` --- return distutils ``Distribution``\n instance.\n\n+ ``config.get_config_cmd()`` --- returns ``numpy.distutils`` config\n command instance.\n\n+ ``config.get_info(*names)`` ---\n\nTemplate files\n--------------\n\nXXX: Describe how files with extensions ``.f.src``, ``.pyf.src``,\n``.c.src``, etc. are pre-processed by the ``build_src`` command.\n\nUseful functions in ``numpy.distutils.misc_util``\n-------------------------------------------------\n\n+ ``get_numpy_include_dirs()`` --- return a list of NumPy base\n include directories. NumPy base include directories contain\n header files such as ``numpy/arrayobject.h``, ``numpy/funcobject.h``\n etc. For installed NumPy the returned list has length 1\n but when building NumPy the list may contain more directories,\n for example, a path to ``config.h`` file that\n ``numpy/base/setup.py`` file generates and is used by ``numpy``\n header files.\n\n+ ``append_path(prefix,path)`` --- smart append ``path`` to ``prefix``.\n\n+ ``gpaths(paths, local_path='')`` --- apply glob to paths and prepend\n ``local_path`` if needed.\n\n+ ``njoin(*path)`` --- join pathname components + convert ``/``-separated path\n to ``os.sep``-separated path and resolve ``..``, ``.`` from paths.\n Ex. ``njoin('a',['b','./c'],'..','g') -> os.path.join('a','b','g')``.\n\n+ ``minrelpath(path)`` --- resolves dots in ``path``.\n\n+ ``rel_path(path, parent_path)`` --- return ``path`` relative to ``parent_path``.\n\n+ ``def get_cmd(cmdname,_cache={})`` --- returns ``numpy.distutils``\n command instance.\n\n+ ``all_strings(lst)``\n\n+ ``has_f_sources(sources)``\n\n+ ``has_cxx_sources(sources)``\n\n+ ``filter_sources(sources)`` --- return ``c_sources, cxx_sources,\n f_sources, fmodule_sources``\n\n+ ``get_dependencies(sources)``\n\n+ ``is_local_src_dir(directory)``\n\n+ ``get_ext_source_files(ext)``\n\n+ ``get_script_files(scripts)``\n\n+ ``get_lib_source_files(lib)``\n\n+ ``get_data_files(data)``\n\n+ ``dot_join(*args)`` --- join non-zero arguments with a dot.\n\n+ ``get_frame(level=0)`` --- return frame object from call stack with given level.\n\n+ ``cyg2win32(path)``\n\n+ ``mingw32()`` --- return ``True`` when using mingw32 environment.\n\n+ ``terminal_has_colors()``, ``red_text(s)``, ``green_text(s)``,\n ``yellow_text(s)``, ``blue_text(s)``, ``cyan_text(s)``\n\n+ ``get_path(mod_name,parent_path=None)`` --- return path of a module\n relative to parent_path when given. Handles also ``__main__`` and\n ``__builtin__`` modules.\n\n+ ``allpath(name)`` --- replaces ``/`` with ``os.sep`` in ``name``.\n\n+ ``cxx_ext_match``, ``fortran_ext_match``, ``f90_ext_match``,\n ``f90_module_name_match``\n\n``numpy.distutils.system_info`` module\n--------------------------------------\n\n+ ``get_info(name,notfound_action=0)``\n+ ``combine_paths(*args,**kws)``\n+ ``show_all()``\n\n``numpy.distutils.cpuinfo`` module\n----------------------------------\n\n+ ``cpuinfo``\n\n``numpy.distutils.log`` module\n------------------------------\n\n+ ``set_verbosity(v)``\n\n\n``numpy.distutils.exec_command`` module\n---------------------------------------\n\n+ ``get_pythonexe()``\n+ ``splitcmdline(line)``\n+ ``find_executable(exe, path=None)``\n+ ``exec_command( command, execute_in='', use_shell=None, use_tee=None, **env )``\n\nThe ``info.py`` file\n''''''''''''''''''''\n\nScipy package import hooks assume that each Scipy package contains\n``info.py`` file that contains overall documentation about the package\nand some variables defining the order of package imports, dependence\nrelations between packages, etc.\n\nThe following information will be looked in the ``info.py`` file:\n\n__doc__\n The documentation string of the package.\n\n__doc_title__\n The title of the package. If not defined then the first non-empty \n line of ``__doc__`` will be used.\n\n__all__\n List of symbols that package exports. Optional.\n\nglobal_symbols\n List of names that should be imported to numpy name space. To import\n all symbols to ``numpy`` namespace, define ``global_symbols=['*']``.\n\ndepends\n List of names that the package depends on. Prefix ``numpy.``\n will be automatically added to package names. For example,\n use ``testing`` to indicate dependence on ``numpy.testing``\n package. Default value is ``[]``.\n\npostpone_import\n Boolean variable indicating that importing the package should be\n postponed until the first attempt of its usage. Default value is ``False``.\n Depreciated.\n\nThe ``__init__.py`` file\n''''''''''''''''''''''''\n\nTo speed up the import time as well as to minimize memory usage, numpy\nuses ppimport hooks to transparently postpone importing large modules\nthat might not be used during the Scipy usage session. But in order to\nhave an access to the documentation of all Scipy packages, including \nof the postponed packages, the documentation string of a package (that would\nusually reside in ``__init__.py`` file) should be copied also\nto ``info.py`` file.\n\nSo, the header a typical ``__init__.py`` file is::\n\n #\n # Package ... - ...\n #\n\n from info import __doc__\n ...\n\n from numpy.testing import ScipyTest\n test = ScipyTest().test\n\nThe ``tests/`` directory\n''''''''''''''''''''''''\n\nIdeally, every Python code, extension module, or subpackage in Scipy\npackage directory should have the corresponding ``test_.py``\nfile in ``tests/`` directory. This file should define classes\nderived from ``ScipyTestCase`` (or from ``unittest.TestCase``) class\nand have names starting with ``test``. The methods of these classes\nwhich names start with ``bench``, ``check``, or ``test``, are passed\non to unittest machinery. In addition, the value of the first optional\nargument of these methods determine the level of the corresponding\ntest. Default level is 1.\n\nA minimal example of a ``test_yyy.py`` file that implements tests for\na Scipy package module ``numpy.xxx.yyy`` containing a function\n``zzz()``, is shown below::\n\n import sys\n from numpy.testing import *\n\n set_package_path()\n # import xxx symbols\n from xxx.yyy import zzz\n restore_path()\n\n #Optional:\n set_local_path()\n # import modules that are located in the same directory as this file.\n restore_path()\n\n class test_zzz(ScipyTestCase):\n def check_simple(self, level=1):\n assert zzz()=='Hello from zzz'\n #...\n\n if __name__ == \"__main__\":\n ScipyTest().run()\n\n``ScipyTestCase`` is derived from ``unittest.TestCase`` and it\nbasically only implements an additional method ``measure(self,\ncode_str, times=1)``.\n\n``numpy.testing`` module provides also the following convenience\nfunctions::\n\n assert_equal(actual,desired,err_msg='',verbose=1)\n assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1)\n assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1)\n assert_array_equal(x,y,err_msg='')\n assert_array_almost_equal(x,y,decimal=6,err_msg='')\n rand(*shape) # returns random array with a given shape\n\n``ScipyTest`` can be used for running ``tests/test_*.py`` scripts.\nFor instance, to run all test scripts of the module ``xxx``, execute\nin Python:\n\n >>> ScipyTest('xxx').test(level=1,verbosity=1)\n\nor equivalently,\n\n >>> import xxx\n >>> ScipyTest(xxx).test(level=1,verbosity=1)\n\nTo run only tests for ``xxx.yyy`` module, execute:\n\n >>> ScipyTest('xxx.yyy').test(level=1,verbosity=1)\n\nTo take the level and verbosity parameters for tests from\n``sys.argv``, use ``ScipyTest.run()`` method (this is supported only\nwhen ``optparse`` is installed).\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + " #setup(**configuration(top_path='').todict())", + " setup(configuration=configuration)" + ], + "deleted": [ + " setup(**configuration(top_path='').todict())" + ] + } + } + ] + }, + { + "hash": "c31f2f845587db8101f697dc36286bd55d780ead", + "msg": "Applied http://projects.scipy.org/scipy/numpy/ticket/39", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T09:17:10+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T09:17:10+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "d1573150a33df8c6eaf95189a6dcd6ee6f0c48ad" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 4, + "insertions": 13, + "lines": 17, + "files": 2, + "dmm_unit_size": 0.5, + "dmm_unit_complexity": 0.5, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/cpuinfo.py", + "new_path": "numpy/distutils/cpuinfo.py", + "filename": "cpuinfo.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -177,6 +177,10 @@ 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_PentiumM(self):\n+ return re.match(r'.*?Pentium.*?M\\b',\n+ self.info[0]['model name']) is not None\n+\n def _is_Prescott(self):\n return self.is_PentiumIV() and self.has_sse3()\n \n", + "added_lines": 4, + "deleted_lines": 0, + "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision: 1.1 $\n$Date: 2005/04/09 19:29:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: cpuinfo.py,v 1.1 2005/04/09 19:29:34 pearu Exp $\"\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_PentiumM(self):\n return re.match(r'.*?Pentium.*?M\\b',\n self.info[0]['model name']) is not None\n\n def _is_Prescott(self):\n return self.is_PentiumIV() and self.has_sse3()\n\n def _is_Nocona(self):\n return self.is_PentiumIV() and self.is_64bit()\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['family']) 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 _is_Xeon = _is_XEON\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 True\n if self.info[0].get('clflush size','')=='64':\n return True\n if self.info[0].get('uname_m','')=='x86_64':\n return True\n if self.info[0].get('arch','')=='IA-64':\n return True\n return False\n\n def _is_32bit(self):\n return not self.is_64bit()\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: 1.1 $\n$Date: 2005/04/09 19:29:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: cpuinfo.py,v 1.1 2005/04/09 19:29:34 pearu Exp $\"\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_Prescott(self):\n return self.is_PentiumIV() and self.has_sse3()\n\n def _is_Nocona(self):\n return self.is_PentiumIV() and self.is_64bit()\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['family']) 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 _is_Xeon = _is_XEON\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 True\n if self.info[0].get('clflush size','')=='64':\n return True\n if self.info[0].get('uname_m','')=='x86_64':\n return True\n if self.info[0].get('arch','')=='IA-64':\n return True\n return False\n\n def _is_32bit(self):\n return not self.is_64bit()\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_PentiumM", + "long_name": "_is_PentiumM( 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_Prescott", + "long_name": "_is_Prescott( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Nocona", + "long_name": "_is_Nocona( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Itanium", + "long_name": "_is_Itanium( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 190, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_is_XEON", + "long_name": "_is_XEON( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 194, + "end_line": 196, + "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": 202, + "end_line": 203, + "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": 205, + "end_line": 206, + "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": 208, + "end_line": 209, + "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": 211, + "end_line": 212, + "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": 214, + "end_line": 215, + "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": 217, + "end_line": 218, + "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": 220, + "end_line": 221, + "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": 223, + "end_line": 224, + "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": 226, + "end_line": 227, + "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": 229, + "end_line": 230, + "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": 10, + "complexity": 5, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "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": 243, + "end_line": 244, + "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": 250, + "end_line": 269, + "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": 274, + "end_line": 275, + "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": 277, + "end_line": 278, + "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": 280, + "end_line": 281, + "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": 298, + "end_line": 300, + "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": 301, + "end_line": 302, + "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": 323, + "end_line": 348, + "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": 352, + "end_line": 354, + "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": 356, + "end_line": 357, + "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": 359, + "end_line": 360, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 365, + "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": 389, + "end_line": 434, + "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": 438, + "end_line": 439, + "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": 440, + "end_line": 441, + "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": 443, + "end_line": 444, + "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": 445, + "end_line": 446, + "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": 447, + "end_line": 448, + "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": 450, + "end_line": 452, + "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": 454, + "end_line": 455, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 466, + "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": 467, + "end_line": 468, + "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": 469, + "end_line": 470, + "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": 471, + "end_line": 472, + "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": 473, + "end_line": 474, + "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": 475, + "end_line": 476, + "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": 477, + "end_line": 478, + "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": 479, + "end_line": 480, + "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": 481, + "end_line": 482, + "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": 483, + "end_line": 484, + "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": 485, + "end_line": 486, + "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": 488, + "end_line": 489, + "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": 490, + "end_line": 491, + "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": 492, + "end_line": 493, + "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": 503, + "end_line": 542, + "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": 548, + "end_line": 549, + "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": 551, + "end_line": 552, + "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": 554, + "end_line": 555, + "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": 557, + "end_line": 559, + "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": 561, + "end_line": 563, + "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": 565, + "end_line": 567, + "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": 569, + "end_line": 571, + "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": 573, + "end_line": 574, + "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": 576, + "end_line": 578, + "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": 580, + "end_line": 582, + "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": 586, + "end_line": 587, + "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": 589, + "end_line": 590, + "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": 592, + "end_line": 593, + "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": 595, + "end_line": 596, + "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": 598, + "end_line": 599, + "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": 601, + "end_line": 602, + "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": 604, + "end_line": 606, + "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": 608, + "end_line": 610, + "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": 612, + "end_line": 614, + "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": 616, + "end_line": 618, + "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": 620, + "end_line": 621, + "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": 625, + "end_line": 626, + "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": 628, + "end_line": 629, + "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": 631, + "end_line": 636, + "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": 638, + "end_line": 646, + "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": 648, + "end_line": 649, + "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": 651, + "end_line": 653, + "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": 655, + "end_line": 656, + "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_Prescott", + "long_name": "_is_Prescott( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 180, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Nocona", + "long_name": "_is_Nocona( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 186, + "end_line": 188, + "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": 190, + "end_line": 192, + "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": 198, + "end_line": 199, + "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": 201, + "end_line": 202, + "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": 204, + "end_line": 205, + "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": 207, + "end_line": 208, + "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": 210, + "end_line": 211, + "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": 213, + "end_line": 214, + "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": 216, + "end_line": 217, + "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": 219, + "end_line": 220, + "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": 222, + "end_line": 223, + "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": 225, + "end_line": 226, + "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": 10, + "complexity": 5, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 228, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "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": 239, + "end_line": 240, + "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": 246, + "end_line": 265, + "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": 270, + "end_line": 271, + "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": 273, + "end_line": 274, + "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": 276, + "end_line": 277, + "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": 294, + "end_line": 296, + "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": 297, + "end_line": 298, + "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": 319, + "end_line": 344, + "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": 348, + "end_line": 350, + "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": 352, + "end_line": 353, + "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": 355, + "end_line": 356, + "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": 357, + "end_line": 358, + "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": 360, + "end_line": 361, + "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": 385, + "end_line": 430, + "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": 434, + "end_line": 435, + "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": 436, + "end_line": 437, + "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": 439, + "end_line": 440, + "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": 441, + "end_line": 442, + "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": 443, + "end_line": 444, + "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": 446, + "end_line": 448, + "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": 450, + "end_line": 451, + "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": 453, + "end_line": 454, + "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": 455, + "end_line": 456, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 466, + "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": 467, + "end_line": 468, + "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": 469, + "end_line": 470, + "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": 471, + "end_line": 472, + "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": 473, + "end_line": 474, + "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": 475, + "end_line": 476, + "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": 477, + "end_line": 478, + "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": 479, + "end_line": 480, + "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": 481, + "end_line": 482, + "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": 484, + "end_line": 485, + "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": 486, + "end_line": 487, + "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": 488, + "end_line": 489, + "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": 499, + "end_line": 538, + "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": 544, + "end_line": 545, + "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": 547, + "end_line": 548, + "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": 550, + "end_line": 551, + "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": 553, + "end_line": 555, + "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": 557, + "end_line": 559, + "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": 561, + "end_line": 563, + "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": 565, + "end_line": 567, + "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": 569, + "end_line": 570, + "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": 572, + "end_line": 574, + "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": 576, + "end_line": 578, + "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": 582, + "end_line": 583, + "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": 585, + "end_line": 586, + "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": 588, + "end_line": 589, + "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": 591, + "end_line": 592, + "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": 594, + "end_line": 595, + "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": 597, + "end_line": 598, + "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": 600, + "end_line": 602, + "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": 604, + "end_line": 606, + "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": 608, + "end_line": 610, + "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": 612, + "end_line": 614, + "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": 616, + "end_line": 617, + "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": 621, + "end_line": 622, + "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": 624, + "end_line": 625, + "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": 627, + "end_line": 632, + "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": 634, + "end_line": 642, + "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": 644, + "end_line": 645, + "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": 647, + "end_line": 649, + "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": 651, + "end_line": 652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "_is_PentiumM", + "long_name": "_is_PentiumM( 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 + } + ], + "nloc": 548, + "complexity": 227, + "token_count": 5008, + "diff_parsed": { + "added": [ + " def _is_PentiumM(self):", + " return re.match(r'.*?Pentium.*?M\\b',", + " self.info[0]['model name']) is not None", + "" + ], + "deleted": [] + } + }, + { + "old_path": "numpy/distutils/fcompiler/intel.py", + "new_path": "numpy/distutils/fcompiler/intel.py", + "filename": "intel.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -48,16 +48,20 @@ def get_flags_arch(self):\n opt.append('-fdiv_check')\n if cpu.has_f00f_bug():\n opt.append('-0f_check')\n- if cpu.is_PentiumPro() or cpu.is_PentiumII():\n- opt.extend(['-tpp6','-xi'])\n- elif cpu.is_PentiumIII():\n- opt.append('-tpp6')\n+ if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():\n+ opt.extend(['-tpp6'])\n+ elif cpu.is_PentiumM():\n+ opt.extend(['-tpp7','-xB'])\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n elif cpu.is_PentiumIV() or cpu.is_XEON():\n opt.extend(['-tpp7','-xW'])\n if cpu.has_mmx():\n opt.append('-xM')\n+ if cpu.has_sse2():\n+ opt.append('-arch SSE2')\n+ elif cpu.has_sse():\n+ opt.append('-arch SSE')\n return opt\n \n def get_flags_linker_so(self):\n@@ -65,6 +69,7 @@ def get_flags_linker_so(self):\n v = self.get_version()\n if v and v >= '8.0':\n opt.append('-nofor_main')\n+ opt.extend(self.get_flags_arch())\n return opt\n \n class IntelItaniumFCompiler(IntelFCompiler):\n", + "added_lines": 9, + "deleted_lines": 4, + "source_code": "# http://developer.intel.com/software/products/compilers/flin/\n\nimport os\nimport sys\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.fcompiler import FCompiler, dummy_fortran_file\nfrom numpy.distutils.exec_command import find_executable\n\nclass IntelFCompiler(FCompiler):\n\n compiler_type = 'intel'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit '\\\n 'applications, Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','ifc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-72\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n pic_flags = ['-KPIC']\n module_dir_switch = '-module ' # Don't remove ending space!\n module_include_switch = '-I'\n\n def get_flags(self):\n opt = self.pic_flags + [\"-cm\"]\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_opt(self):\n return ['-O3','-unroll']\n\n def get_flags_arch(self):\n opt = []\n if cpu.has_fdiv_bug():\n opt.append('-fdiv_check')\n if cpu.has_f00f_bug():\n opt.append('-0f_check')\n if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():\n opt.extend(['-tpp6'])\n elif cpu.is_PentiumM():\n opt.extend(['-tpp7','-xB'])\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n elif cpu.is_PentiumIV() or cpu.is_XEON():\n opt.extend(['-tpp7','-xW'])\n if cpu.has_mmx():\n opt.append('-xM')\n if cpu.has_sse2():\n opt.append('-arch SSE2')\n elif cpu.has_sse():\n opt.append('-arch SSE')\n return opt\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n v = self.get_version()\n if v and v >= '8.0':\n opt.append('-nofor_main')\n opt.extend(self.get_flags_arch())\n return opt\n\nclass IntelItaniumFCompiler(IntelFCompiler):\n compiler_type = 'intele'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','efort','efc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\nclass IntelVisualFCompiler(FCompiler):\n\n compiler_type = 'intelv'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n ar_exe = 'lib.exe'\n fc_exe = 'ifl'\n if sys.platform=='win32':\n from distutils.msvccompiler import MSVCCompiler\n ar_exe = MSVCCompiler().lib\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\n compile_switch = '/c '\n object_switch = '/Fo' #No space after /Fo!\n library_switch = '/OUT:' #No space after /OUT:!\n module_dir_switch = '/module:' #No space after /module:\n module_include_switch = '/I'\n\n def get_flags(self):\n opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_debug(self):\n return ['/4Yb','/d2']\n\n def get_flags_opt(self):\n return ['/O3','/Qip','/Qipo','/Qipo_obj']\n\n def get_flags_arch(self):\n opt = []\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt.extend(['/G6','/Qaxi'])\n elif cpu.is_PentiumIII():\n opt.extend(['/G6','/QaxK'])\n elif cpu.is_Pentium():\n opt.append('/G5')\n elif cpu.is_PentiumIV():\n opt.extend(['/G7','/QaxW'])\n if cpu.has_mmx():\n opt.append('/QaxM')\n return opt\n\nclass IntelItaniumVisualFCompiler(IntelVisualFCompiler):\n\n compiler_type = 'intelev'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n fc_exe = 'efl' # XXX this is a wild guess\n ar_exe = IntelVisualFCompiler.ar_exe\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='intel')\n compiler.customize()\n print compiler.get_version()\n", + "source_code_before": "# http://developer.intel.com/software/products/compilers/flin/\n\nimport os\nimport sys\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.fcompiler import FCompiler, dummy_fortran_file\nfrom numpy.distutils.exec_command import find_executable\n\nclass IntelFCompiler(FCompiler):\n\n compiler_type = 'intel'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit '\\\n 'applications, Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','ifc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-72\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n pic_flags = ['-KPIC']\n module_dir_switch = '-module ' # Don't remove ending space!\n module_include_switch = '-I'\n\n def get_flags(self):\n opt = self.pic_flags + [\"-cm\"]\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_opt(self):\n return ['-O3','-unroll']\n\n def get_flags_arch(self):\n opt = []\n if cpu.has_fdiv_bug():\n opt.append('-fdiv_check')\n if cpu.has_f00f_bug():\n opt.append('-0f_check')\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt.extend(['-tpp6','-xi'])\n elif cpu.is_PentiumIII():\n opt.append('-tpp6')\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n elif cpu.is_PentiumIV() or cpu.is_XEON():\n opt.extend(['-tpp7','-xW'])\n if cpu.has_mmx():\n opt.append('-xM')\n return opt\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n v = self.get_version()\n if v and v >= '8.0':\n opt.append('-nofor_main')\n return opt\n\nclass IntelItaniumFCompiler(IntelFCompiler):\n compiler_type = 'intele'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','efort','efc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\nclass IntelVisualFCompiler(FCompiler):\n\n compiler_type = 'intelv'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n ar_exe = 'lib.exe'\n fc_exe = 'ifl'\n if sys.platform=='win32':\n from distutils.msvccompiler import MSVCCompiler\n ar_exe = MSVCCompiler().lib\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\n compile_switch = '/c '\n object_switch = '/Fo' #No space after /Fo!\n library_switch = '/OUT:' #No space after /OUT:!\n module_dir_switch = '/module:' #No space after /module:\n module_include_switch = '/I'\n\n def get_flags(self):\n opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_debug(self):\n return ['/4Yb','/d2']\n\n def get_flags_opt(self):\n return ['/O3','/Qip','/Qipo','/Qipo_obj']\n\n def get_flags_arch(self):\n opt = []\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt.extend(['/G6','/Qaxi'])\n elif cpu.is_PentiumIII():\n opt.extend(['/G6','/QaxK'])\n elif cpu.is_Pentium():\n opt.append('/G5')\n elif cpu.is_PentiumIV():\n opt.extend(['/G7','/QaxW'])\n if cpu.has_mmx():\n opt.append('/QaxM')\n return opt\n\nclass IntelItaniumVisualFCompiler(IntelVisualFCompiler):\n\n compiler_type = 'intelev'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n fc_exe = 'efl' # XXX this is a wild guess\n ar_exe = IntelVisualFCompiler.ar_exe\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='intel')\n compiler.customize()\n print compiler.get_version()\n", + "methods": [ + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 40, + "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": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 21, + "complexity": 13, + "token_count": 156, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "intel.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 67, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 125, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 135, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 13, + "complexity": 7, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 138, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 40, + "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": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 17, + "complexity": 10, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "intel.py", + "nloc": 6, + "complexity": 3, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 63, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 120, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 124, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 127, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 13, + "complexity": 7, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 133, + "end_line": 145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 21, + "complexity": 13, + "token_count": 156, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "intel.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 67, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "nloc": 148, + "complexity": 30, + "token_count": 924, + "diff_parsed": { + "added": [ + " if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():", + " opt.extend(['-tpp6'])", + " elif cpu.is_PentiumM():", + " opt.extend(['-tpp7','-xB'])", + " if cpu.has_sse2():", + " opt.append('-arch SSE2')", + " elif cpu.has_sse():", + " opt.append('-arch SSE')", + " opt.extend(self.get_flags_arch())" + ], + "deleted": [ + " if cpu.is_PentiumPro() or cpu.is_PentiumII():", + " opt.extend(['-tpp6','-xi'])", + " elif cpu.is_PentiumIII():", + " opt.append('-tpp6')" + ] + } + } + ] + }, + { + "hash": "2a800cc944f0cbb2594a69cc1fbee3049ce6399b", + "msg": "Add svn revision number to version.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T09:38:29+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T09:38:29+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "c31f2f845587db8101f697dc36286bd55d780ead" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 9, + "insertions": 5, + "lines": 14, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "setup.py", + "new_path": "setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -54,10 +54,10 @@ def configuration(parent_package='',top_path=None):\n \n config.add_subpackage('numpy')\n \n-\n- config.name = 'numpy'\n- #config.dict_append(version=version)\n- #print config.name,'version',config.version\n+ config.name = 'numpy' # used in generated file names\n+ \n+ from numpy.version import version\n+ config.dict_append(version=version)\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n@@ -74,11 +74,7 @@ def setup_package():\n sys.path.insert(0,local_path)\n \n try:\n-\n- from numpy.version import version\n- setup( configuration=configuration,\n- version = version\n- )\n+ setup( configuration=configuration )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n", + "added_lines": 5, + "deleted_lines": 9, + "source_code": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n\n config = Configuration(None, parent_package, top_path,\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n )\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n\n config.name = 'numpy' # used in generated file names\n \n from numpy.version import version\n config.dict_append(version=version)\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n \n return config\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n\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 setup( configuration=configuration )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "source_code_before": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n\n config = Configuration(None, parent_package, top_path,\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n )\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n\n\n config.name = 'numpy'\n #config.dict_append(version=version)\n #print config.name,'version',config.version\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n \n return config\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n\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\n from numpy.version import version\n setup( configuration=configuration,\n version = version\n )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 26, + "complexity": 1, + "token_count": 169, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [], + "start_line": 67, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 24, + "complexity": 1, + "token_count": 155, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 15, + "complexity": 2, + "token_count": 91, + "parameters": [], + "start_line": 67, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 26, + "complexity": 1, + "token_count": 169, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [], + "start_line": 67, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + } + ], + "nloc": 69, + "complexity": 3, + "token_count": 276, + "diff_parsed": { + "added": [ + " config.name = 'numpy' # used in generated file names", + "", + " from numpy.version import version", + " config.dict_append(version=version)", + " setup( configuration=configuration )" + ], + "deleted": [ + "", + " config.name = 'numpy'", + " #config.dict_append(version=version)", + " #print config.name,'version',config.version", + "", + " from numpy.version import version", + " setup( configuration=configuration,", + " version = version", + " )" + ] + } + } + ] + }, + { + "hash": "aa6ca9bba4a8c0232ea4c717ab2539e7882f37a3", + "msg": "unit test for r2312", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-03-31T14:23:05+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T14:23:05+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "2a800cc944f0cbb2594a69cc1fbee3049ce6399b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 0, + "insertions": 4, + "lines": 4, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/core/tests/test_multiarray.py", + "new_path": "numpy/core/tests/test_multiarray.py", + "filename": "test_multiarray.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -192,6 +192,10 @@ def check_constructor(self):\n y[()] = 6\n self.failUnlessEqual(x[()], 6)\n \n+ def check_output(self):\n+ x = array(2)\n+ self.failUnlessRaises(ValueError, add, x, [1], x)\n+ \n class test_creation(ScipyTestCase):\n def check_from_attribute(self):\n class x(object):\n", + "added_lines": 4, + "deleted_lines": 0, + "source_code": "\nfrom numpy.testing import *\nfrom numpy.core import *\n\nclass test_flags(ScipyTestCase):\n def setUp(self):\n self.a = arange(10)\n\n def check_writeable(self):\n mydict = locals()\n self.a.flags.writeable = False\n self.assertRaises(RuntimeError, runstring, 'self.a[0] = 3', mydict)\n self.a.flags.writeable = True\n self.a[0] = 5\n self.a[0] = 0\n\n def check_otherflags(self):\n assert_equal(self.a.flags.carray, True)\n assert_equal(self.a.flags.farray, False)\n assert_equal(self.a.flags.behaved, True)\n assert_equal(self.a.flags.fnc, False)\n assert_equal(self.a.flags.forc, True)\n assert_equal(self.a.flags.owndata, True)\n assert_equal(self.a.flags.writeable, True)\n assert_equal(self.a.flags.aligned, True)\n assert_equal(self.a.flags.updateifcopy, False)\n\n\nclass test_attributes(ScipyTestCase):\n def setUp(self):\n self.one = arange(10)\n self.two = arange(20).reshape(4,5)\n self.three = arange(60,dtype=float64).reshape(2,5,6)\n\n def check_attributes(self):\n assert_equal(self.one.shape, (10,))\n assert_equal(self.two.shape, (4,5))\n assert_equal(self.three.shape, (2,5,6))\n self.three.shape = (10,3,2)\n assert_equal(self.three.shape, (10,3,2))\n self.three.shape = (2,5,6)\n assert_equal(self.one.strides, (self.one.itemsize,))\n num = self.two.itemsize\n assert_equal(self.two.strides, (5*num, num))\n num = self.three.itemsize\n assert_equal(self.three.strides, (30*num, 6*num, num))\n assert_equal(self.one.ndim, 1)\n assert_equal(self.two.ndim, 2)\n assert_equal(self.three.ndim, 3)\n num = self.two.itemsize\n assert_equal(self.two.size, 20)\n assert_equal(self.two.nbytes, 20*num)\n assert_equal(self.two.itemsize, self.two.dtype.itemsize)\n assert_equal(self.two.base, arange(20))\n\n def check_dtypeattr(self):\n assert_equal(self.one.dtype, dtype(int_))\n assert_equal(self.three.dtype, dtype(float_))\n assert_equal(self.one.dtype.char, 'l')\n assert_equal(self.three.dtype.char, 'd')\n self.failUnless(self.three.dtype.str[0] in '<>')\n assert_equal(self.one.dtype.str[1], 'i')\n assert_equal(self.three.dtype.str[1], 'f')\n\n def check_stridesattr(self):\n x = self.one\n def make_array(size, offset, strides):\n return ndarray([size], buffer=x,\n offset=offset*x.itemsize,\n strides=strides*x.itemsize)\n assert_equal(make_array(4, 4, -1), array([4, 3, 2, 1]))\n self.failUnlessRaises(ValueError, make_array, 4, 4, -2)\n self.failUnlessRaises(ValueError, make_array, 4, 2, -1)\n self.failUnlessRaises(ValueError, make_array, 8, 3, 1)\n #self.failUnlessRaises(ValueError, make_array, 8, 3, 0)\n #self.failUnlessRaises(ValueError, lambda: ndarray([1], strides=4))\n\n\n def check_set_stridesattr(self):\n x = self.one\n def make_array(size, offset, strides):\n try:\n r = ndarray([size], buffer=x, offset=offset*x.itemsize)\n except:\n pass\n r.strides = strides=strides*x.itemsize\n return r\n assert_equal(make_array(4, 4, -1), array([4, 3, 2, 1]))\n self.failUnlessRaises(ValueError, make_array, 4, 4, -2)\n self.failUnlessRaises(ValueError, make_array, 4, 2, -1)\n self.failUnlessRaises(ValueError, make_array, 8, 3, 1)\n #self.failUnlessRaises(ValueError, make_array, 8, 3, 0)\n\n def check_fill(self):\n for t in \"?bhilqpBHILQPfdgFDGO\":\n x = empty((3,2,1), t)\n y = empty((3,2,1), t)\n x.fill(1)\n y[...] = 1\n assert_equal(x,y)\n\n x = array([(0,0.0), (1,1.0)], dtype='i4,f8')\n x.fill(x[0])\n assert_equal(x['f1'][1], x['f1'][0])\n\nclass test_dtypedescr(ScipyTestCase):\n def check_construction(self):\n d1 = dtype('i4')\n assert_equal(d1, dtype(int32))\n d2 = dtype('f8')\n assert_equal(d2, dtype(float64))\n\nclass test_fromstring(ScipyTestCase):\n def check_binary(self):\n a = fromstring('\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@',dtype='')\n assert_equal(self.one.dtype.str[1], 'i')\n assert_equal(self.three.dtype.str[1], 'f')\n\n def check_stridesattr(self):\n x = self.one\n def make_array(size, offset, strides):\n return ndarray([size], buffer=x,\n offset=offset*x.itemsize,\n strides=strides*x.itemsize)\n assert_equal(make_array(4, 4, -1), array([4, 3, 2, 1]))\n self.failUnlessRaises(ValueError, make_array, 4, 4, -2)\n self.failUnlessRaises(ValueError, make_array, 4, 2, -1)\n self.failUnlessRaises(ValueError, make_array, 8, 3, 1)\n #self.failUnlessRaises(ValueError, make_array, 8, 3, 0)\n #self.failUnlessRaises(ValueError, lambda: ndarray([1], strides=4))\n\n\n def check_set_stridesattr(self):\n x = self.one\n def make_array(size, offset, strides):\n try:\n r = ndarray([size], buffer=x, offset=offset*x.itemsize)\n except:\n pass\n r.strides = strides=strides*x.itemsize\n return r\n assert_equal(make_array(4, 4, -1), array([4, 3, 2, 1]))\n self.failUnlessRaises(ValueError, make_array, 4, 4, -2)\n self.failUnlessRaises(ValueError, make_array, 4, 2, -1)\n self.failUnlessRaises(ValueError, make_array, 8, 3, 1)\n #self.failUnlessRaises(ValueError, make_array, 8, 3, 0)\n\n def check_fill(self):\n for t in \"?bhilqpBHILQPfdgFDGO\":\n x = empty((3,2,1), t)\n y = empty((3,2,1), t)\n x.fill(1)\n y[...] = 1\n assert_equal(x,y)\n\n x = array([(0,0.0), (1,1.0)], dtype='i4,f8')\n x.fill(x[0])\n assert_equal(x['f1'][1], x['f1'][0])\n\nclass test_dtypedescr(ScipyTestCase):\n def check_construction(self):\n d1 = dtype('i4')\n assert_equal(d1, dtype(int32))\n d2 = dtype('f8')\n assert_equal(d2, dtype(float64))\n\nclass test_fromstring(ScipyTestCase):\n def check_binary(self):\n a = fromstring('\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@',dtype='= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return is_string(s) and ('*' in s or '?' is s)\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if callable(file):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return '*' in s or '?' is s\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "methods": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 912, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 923, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 945, + "end_line": 951, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 953, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 962, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1027, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1051, + "end_line": 1060, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1079, + "end_line": 1089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1091, + "end_line": 1100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1102, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1107, + "end_line": 1118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1120, + "end_line": 1131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1133, + "end_line": 1146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1148, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1161, + "end_line": 1207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1230, + "end_line": 1234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1219, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1209, + "end_line": 1239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1241, + "end_line": 1246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1248, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1258, + "end_line": 1268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1270, + "end_line": 1284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1288, + "end_line": 1299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1302, + "end_line": 1307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1309, + "end_line": 1328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1330, + "end_line": 1363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 2, + "token_count": 13, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 57, + "complexity": 15, + "token_count": 350, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 910, + "end_line": 919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 921, + "end_line": 941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 943, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 951, + "end_line": 958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 960, + "end_line": 1023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1025, + "end_line": 1047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1049, + "end_line": 1058, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1060, + "end_line": 1075, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1077, + "end_line": 1087, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1089, + "end_line": 1098, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1100, + "end_line": 1103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1105, + "end_line": 1116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1118, + "end_line": 1129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1131, + "end_line": 1144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1146, + "end_line": 1157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1159, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1228, + "end_line": 1232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1217, + "end_line": 1235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1207, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1239, + "end_line": 1244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1246, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1256, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1268, + "end_line": 1282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1286, + "end_line": 1297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1300, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1307, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1328, + "end_line": 1361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "nloc": 1024, + "complexity": 325, + "token_count": 7085, + "diff_parsed": { + "added": [ + " return is_string(s) and ('*' in s or '?' is s)", + " if callable(file):", + " d = ''", + " elif os.path.isabs(filepat):" + ], + "deleted": [ + " return '*' in s or '?' is s", + " if os.path.isabs(filepat):" + ] + } + } + ] + }, + { + "hash": "f0c7ba02e42d71d120cc782395f01acc6ae15db0", + "msg": "Fix inplace building of data sources.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T16:22:10+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T16:22:10+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "17e57d06d885affe8a916d4e587d63db361565f0" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 7, + "insertions": 7, + "lines": 14, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/distutils/command/build_src.py", + "new_path": "numpy/distutils/command/build_src.py", + "filename": "build_src.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -87,6 +87,10 @@ def run(self):\n \n def build_sources(self):\n \n+ if self.inplace:\n+ self.get_package_dir = self.get_finalized_command('build_py')\\\n+ .get_package_dir\n+\n self.build_py_modules_sources()\n \n for libname_info in self.libraries:\n@@ -114,7 +118,7 @@ def build_data_files_sources(self):\n elif isinstance(data,tuple):\n d,files = data\n if self.inplace:\n- build_dir = d\n+ build_dir = self.get_package_dir('.'.join(d.split(os.sep)))\n else:\n build_dir = os.path.join(self.build_src,d)\n funcs = filter(callable,files)\n@@ -143,13 +147,11 @@ def build_py_modules_sources(self):\n return\n log.info('building py_modules sources')\n new_py_modules = []\n- if self.inplace:\n- get_package_dir = self.get_finalized_command('build_py').get_package_dir\n for source in self.py_modules:\n if is_sequence(source) and len(source)==3:\n package, module_base, source = source\n if self.inplace:\n- build_dir = get_package_dir(package)\n+ build_dir = self.get_package_dir(package)\n else:\n build_dir = os.path.join(self.build_src,\n os.path.join(*package.split('.')))\n@@ -201,10 +203,8 @@ def build_extension_sources(self, ext):\n modpath = fullname.split('.')\n package = '.'.join(modpath[0:-1])\n \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+ self.ext_target_dir = self.get_package_dir(package)\n \n sources = self.generate_sources(sources, ext)\n \n", + "added_lines": 7, + "deleted_lines": 7, + "source_code": "\"\"\" Build swig, f2py, weave, sources.\n\"\"\"\n\nimport os\nimport re\n\nfrom distutils.command import build_ext\nfrom distutils.dep_util import newer_group, newer\n\nfrom numpy.distutils import log\nfrom numpy.distutils.misc_util import fortran_ext_match, \\\n appendpath, is_string, is_sequence\nfrom numpy.distutils.from_template import process_file as process_f_file\nfrom numpy.distutils.conv_template import process_file as process_c_file\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.py_modules_dict = 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 or []\n self.data_files = self.distribution.data_files or []\n\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_dict is used in build_py.find_package_modules\n self.py_modules_dict = {}\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\n return\n\n def build_sources(self):\n\n if self.inplace:\n self.get_package_dir = self.get_finalized_command('build_py')\\\n .get_package_dir\n\n self.build_py_modules_sources()\n\n for libname_info in self.libraries:\n self.build_library_sources(*libname_info)\n\n if self.extensions:\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n\n self.build_data_files_sources()\n\n return\n\n def build_data_files_sources(self):\n if not self.data_files:\n return\n log.info('building data_files sources')\n from numpy.distutils.misc_util import get_data_files\n new_data_files = []\n for data in self.data_files:\n if isinstance(data,str):\n new_data_files.append(data)\n elif isinstance(data,tuple):\n d,files = data\n if self.inplace:\n build_dir = self.get_package_dir('.'.join(d.split(os.sep)))\n else:\n build_dir = os.path.join(self.build_src,d)\n funcs = filter(callable,files)\n files = filter(lambda f:not callable(f), files)\n for f in funcs:\n if f.func_code.co_argcount==1:\n s = f(build_dir)\n else:\n s = f()\n if s is not None:\n if isinstance(s,list):\n files.extend(s)\n elif isinstance(s,str):\n files.append(s)\n else:\n raise TypeError(repr(s))\n filenames = get_data_files((d,files))\n new_data_files.append((d, filenames))\n else:\n raise\n self.data_files[:] = new_data_files\n return\n\n def build_py_modules_sources(self):\n if not self.py_modules:\n return\n log.info('building py_modules sources')\n new_py_modules = []\n for source in self.py_modules:\n if is_sequence(source) and len(source)==3:\n package, module_base, source = source\n if self.inplace:\n build_dir = self.get_package_dir(package)\n else:\n build_dir = os.path.join(self.build_src,\n os.path.join(*package.split('.')))\n if callable(source):\n target = os.path.join(build_dir, module_base + '.py')\n source = source(target)\n if source is None:\n continue\n modules = [(package, module_base, source)]\n if not self.py_modules_dict.has_key(package):\n self.py_modules_dict[package] = []\n self.py_modules_dict[package] += modules\n else:\n new_py_modules.append(source)\n self.py_modules[:] = new_py_modules\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 sources = self.template_sources(sources, (lib_name, build_info))\n\n sources, h_files = self.filter_h_files(sources)\n\n if h_files:\n print self.package,'- nothing done with h_files=',h_files\n\n #for f in h_files:\n # self.distribution.headers.append((lib_name,f))\n\n build_info['sources'] = sources\n return\n\n def build_extension_sources(self, ext):\n\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 self.ext_target_dir = self.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 = self.pyrex_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules_dict.has_key(package):\n self.py_modules_dict[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_dict[package] += modules\n\n sources, h_files = self.filter_h_files(sources)\n\n if h_files:\n print package,'- nothing done with h_files=',h_files\n #for f in h_files:\n # self.distribution.headers.append((package,f))\n\n ext.sources = sources\n\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if is_string(source):\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 is_sequence(extension):\n name = extension[0]\n # if not extension[1].has_key('include_dirs'):\n # extension[1]['include_dirs'] = []\n # incl_dirs = extension[1]['include_dirs']\n else:\n name = extension.name\n # incl_dirs = extension.include_dirs\n #if self.build_src not in incl_dirs:\n # incl_dirs.append(self.build_src)\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 not source:\n continue\n if is_sequence(source):\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\n return new_sources\n\n def filter_py_files(self, sources):\n return self.filter_files(sources,['.py'])\n\n def filter_h_files(self, sources):\n return self.filter_files(sources,['.h','.hpp','.inc'])\n\n def filter_files(self, sources, exts = []):\n new_sources = []\n files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext in exts:\n files.append(source)\n else:\n new_sources.append(source)\n return new_sources, files\n\n def template_sources(self, sources, extension):\n new_sources = []\n if is_sequence(extension):\n depends = extension[1].get('depends')\n include_dirs = extension[1].get('include_dirs')\n else:\n depends = extension.depends\n include_dirs = extension.include_dirs\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_group([source] + depends, target_file)):\n if _f_pyf_ext_match(base):\n log.info(\"from_template:> %s\" % (target_file))\n outstr = process_f_file(source)\n else:\n log.info(\"conv_template:> %s\" % (target_file))\n outstr = process_c_file(source)\n fid = open(target_file,'w')\n fid.write(outstr)\n fid.close()\n if _header_ext_match(target_file):\n d = os.path.dirname(target_file)\n if d not in include_dirs:\n log.info(\" adding '%s' to include_dirs.\" % (d))\n include_dirs.append(d)\n new_sources.append(target_file)\n else:\n new_sources.append(source)\n return new_sources\n\n def pyrex_sources(self, sources, extension):\n have_pyrex = False\n try:\n import Pyrex\n have_pyrex = True\n except ImportError:\n pass\n new_sources = []\n ext_name = extension.name.split('.')[-1]\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyx':\n if self.inplace or not have_pyrex:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n target_file = os.path.join(target_dir, ext_name + '.c')\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')):\n if have_pyrex:\n log.info(\"pyrexc:> %s\" % (target_file))\n self.mkpath(target_dir)\n from Pyrex.Compiler import Main\n options = Main.CompilationOptions(\n defaults=Main.default_options,\n output_file=target_file)\n pyrex_result = Main.compile(source, options=options)\n if pyrex_result.num_errors != 0:\n raise RuntimeError(\"%d errors in Pyrex compile\" %\n pyrex_result.num_errors)\n else:\n log.warn(\"Pyrex needed to compile %s but not available.\"\\\n \" Using old target %s\"\\\n % (source, target_file))\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 if name != ext_name:\n raise ValueError('mismatch of extension names: %s '\n 'provides %r but expected %r' % (\n source, name, 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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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\n if self.distribution.libraries:\n for name,build_info in self.distribution.libraries:\n if name in extension.libraries:\n f2py_options.extend(build_info.get('f2py_options',[]))\n\n log.info(\"f2py options: %s\" % (f2py_options))\n\n if f2py_sources:\n if len(f2py_sources) != 1:\n raise ValueError(\n 'only one .pyf file is allowed per extension module but got'\\\n ' more: %r' % (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 numpy.f2py as 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 is_sequence(extension):\n 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 numpy.f2py as 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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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 numpy.f2py as 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 if not os.path.isfile(target_c):\n raise ValueError(\"%r missing\" % (target_c,))\n if not os.path.isfile(target_h):\n raise ValueError(\"%r missing\" % (target_h,))\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 if name != ext_name[1:]:\n raise ValueError(\n 'mismatch of extension names: %s provides %r'\n ' but expected %r' % (source, name, 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), repr(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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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\n_f_pyf_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n_header_ext_match = re.compile(r'.*[.](inc|h|hpp)\\Z',re.I).match\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.command import build_ext\nfrom distutils.dep_util import newer_group, newer\n\nfrom numpy.distutils import log\nfrom numpy.distutils.misc_util import fortran_ext_match, \\\n appendpath, is_string, is_sequence\nfrom numpy.distutils.from_template import process_file as process_f_file\nfrom numpy.distutils.conv_template import process_file as process_c_file\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.py_modules_dict = 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 or []\n self.data_files = self.distribution.data_files or []\n\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_dict is used in build_py.find_package_modules\n self.py_modules_dict = {}\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\n return\n\n def build_sources(self):\n\n self.build_py_modules_sources()\n\n for libname_info in self.libraries:\n self.build_library_sources(*libname_info)\n\n if self.extensions:\n self.check_extensions_list(self.extensions)\n\n for ext in self.extensions:\n self.build_extension_sources(ext)\n\n self.build_data_files_sources()\n\n return\n\n def build_data_files_sources(self):\n if not self.data_files:\n return\n log.info('building data_files sources')\n from numpy.distutils.misc_util import get_data_files\n new_data_files = []\n for data in self.data_files:\n if isinstance(data,str):\n new_data_files.append(data)\n elif isinstance(data,tuple):\n d,files = data\n if self.inplace:\n build_dir = d\n else:\n build_dir = os.path.join(self.build_src,d)\n funcs = filter(callable,files)\n files = filter(lambda f:not callable(f), files)\n for f in funcs:\n if f.func_code.co_argcount==1:\n s = f(build_dir)\n else:\n s = f()\n if s is not None:\n if isinstance(s,list):\n files.extend(s)\n elif isinstance(s,str):\n files.append(s)\n else:\n raise TypeError(repr(s))\n filenames = get_data_files((d,files))\n new_data_files.append((d, filenames))\n else:\n raise\n self.data_files[:] = new_data_files\n return\n\n def build_py_modules_sources(self):\n if not self.py_modules:\n return\n log.info('building py_modules sources')\n new_py_modules = []\n if self.inplace:\n get_package_dir = self.get_finalized_command('build_py').get_package_dir\n for source in self.py_modules:\n if is_sequence(source) and len(source)==3:\n package, module_base, source = source\n if self.inplace:\n build_dir = get_package_dir(package)\n else:\n build_dir = os.path.join(self.build_src,\n os.path.join(*package.split('.')))\n if callable(source):\n target = os.path.join(build_dir, module_base + '.py')\n source = source(target)\n if source is None:\n continue\n modules = [(package, module_base, source)]\n if not self.py_modules_dict.has_key(package):\n self.py_modules_dict[package] = []\n self.py_modules_dict[package] += modules\n else:\n new_py_modules.append(source)\n self.py_modules[:] = new_py_modules\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 sources = self.template_sources(sources, (lib_name, build_info))\n\n sources, h_files = self.filter_h_files(sources)\n\n if h_files:\n print self.package,'- nothing done with h_files=',h_files\n\n #for f in h_files:\n # self.distribution.headers.append((lib_name,f))\n\n build_info['sources'] = sources\n return\n\n def build_extension_sources(self, ext):\n\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\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 = self.pyrex_sources(sources, ext)\n\n sources, py_files = self.filter_py_files(sources)\n\n if not self.py_modules_dict.has_key(package):\n self.py_modules_dict[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_dict[package] += modules\n\n sources, h_files = self.filter_h_files(sources)\n\n if h_files:\n print package,'- nothing done with h_files=',h_files\n #for f in h_files:\n # self.distribution.headers.append((package,f))\n\n ext.sources = sources\n\n return\n\n def generate_sources(self, sources, extension):\n new_sources = []\n func_sources = []\n for source in sources:\n if is_string(source):\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 is_sequence(extension):\n name = extension[0]\n # if not extension[1].has_key('include_dirs'):\n # extension[1]['include_dirs'] = []\n # incl_dirs = extension[1]['include_dirs']\n else:\n name = extension.name\n # incl_dirs = extension.include_dirs\n #if self.build_src not in incl_dirs:\n # incl_dirs.append(self.build_src)\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 not source:\n continue\n if is_sequence(source):\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\n return new_sources\n\n def filter_py_files(self, sources):\n return self.filter_files(sources,['.py'])\n\n def filter_h_files(self, sources):\n return self.filter_files(sources,['.h','.hpp','.inc'])\n\n def filter_files(self, sources, exts = []):\n new_sources = []\n files = []\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext in exts:\n files.append(source)\n else:\n new_sources.append(source)\n return new_sources, files\n\n def template_sources(self, sources, extension):\n new_sources = []\n if is_sequence(extension):\n depends = extension[1].get('depends')\n include_dirs = extension[1].get('include_dirs')\n else:\n depends = extension.depends\n include_dirs = extension.include_dirs\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_group([source] + depends, target_file)):\n if _f_pyf_ext_match(base):\n log.info(\"from_template:> %s\" % (target_file))\n outstr = process_f_file(source)\n else:\n log.info(\"conv_template:> %s\" % (target_file))\n outstr = process_c_file(source)\n fid = open(target_file,'w')\n fid.write(outstr)\n fid.close()\n if _header_ext_match(target_file):\n d = os.path.dirname(target_file)\n if d not in include_dirs:\n log.info(\" adding '%s' to include_dirs.\" % (d))\n include_dirs.append(d)\n new_sources.append(target_file)\n else:\n new_sources.append(source)\n return new_sources\n\n def pyrex_sources(self, sources, extension):\n have_pyrex = False\n try:\n import Pyrex\n have_pyrex = True\n except ImportError:\n pass\n new_sources = []\n ext_name = extension.name.split('.')[-1]\n for source in sources:\n (base, ext) = os.path.splitext(source)\n if ext == '.pyx':\n if self.inplace or not have_pyrex:\n target_dir = os.path.dirname(base)\n else:\n target_dir = appendpath(self.build_src, os.path.dirname(base))\n target_file = os.path.join(target_dir, ext_name + '.c')\n depends = [source] + extension.depends\n if (self.force or newer_group(depends, target_file, 'newer')):\n if have_pyrex:\n log.info(\"pyrexc:> %s\" % (target_file))\n self.mkpath(target_dir)\n from Pyrex.Compiler import Main\n options = Main.CompilationOptions(\n defaults=Main.default_options,\n output_file=target_file)\n pyrex_result = Main.compile(source, options=options)\n if pyrex_result.num_errors != 0:\n raise RuntimeError(\"%d errors in Pyrex compile\" %\n pyrex_result.num_errors)\n else:\n log.warn(\"Pyrex needed to compile %s but not available.\"\\\n \" Using old target %s\"\\\n % (source, target_file))\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 if name != ext_name:\n raise ValueError('mismatch of extension names: %s '\n 'provides %r but expected %r' % (\n source, name, 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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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\n if self.distribution.libraries:\n for name,build_info in self.distribution.libraries:\n if name in extension.libraries:\n f2py_options.extend(build_info.get('f2py_options',[]))\n\n log.info(\"f2py options: %s\" % (f2py_options))\n\n if f2py_sources:\n if len(f2py_sources) != 1:\n raise ValueError(\n 'only one .pyf file is allowed per extension module but got'\\\n ' more: %r' % (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 numpy.f2py as 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 is_sequence(extension):\n 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 numpy.f2py as 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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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 numpy.f2py as 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 if not os.path.isfile(target_c):\n raise ValueError(\"%r missing\" % (target_c,))\n if not os.path.isfile(target_h):\n raise ValueError(\"%r missing\" % (target_h,))\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 if name != ext_name[1:]:\n raise ValueError(\n 'mismatch of extension names: %s provides %r'\n ' but expected %r' % (source, name, 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), repr(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 if not os.path.isfile(target_file):\n raise ValueError(\"%r missing\" % (target_file,))\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\n_f_pyf_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n_header_ext_match = re.compile(r'.*[.](inc|h|hpp)\\Z',re.I).match\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": 14, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 34, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 9, + "token_count": 194, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "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": 81, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_sources", + "long_name": "build_sources( self )", + "filename": "build_src.py", + "nloc": 13, + "complexity": 5, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "build_data_files_sources", + "long_name": "build_data_files_sources( self )", + "filename": "build_src.py", + "nloc": 35, + "complexity": 11, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "build_py_modules_sources", + "long_name": "build_py_modules_sources( self )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 9, + "token_count": 179, + "parameters": [ + "self" + ], + "start_line": 145, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "build_library_sources", + "long_name": "build_library_sources( self , lib_name , build_info )", + "filename": "build_src.py", + "nloc": 12, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "lib_name", + "build_info" + ], + "start_line": 172, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "build_extension_sources", + "long_name": "build_extension_sources( self , ext )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 5, + "token_count": 228, + "parameters": [ + "self", + "ext" + ], + "start_line": 195, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + }, + { + "name": "generate_sources", + "long_name": "generate_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 31, + "complexity": 10, + "token_count": 183, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 240, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "filter_py_files", + "long_name": "filter_py_files( self , sources )", + "filename": "build_src.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "sources" + ], + "start_line": 279, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "filter_h_files", + "long_name": "filter_h_files( self , sources )", + "filename": "build_src.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "sources" + ], + "start_line": 282, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "filter_files", + "long_name": "filter_files( self , sources , exts = [ ] )", + "filename": "build_src.py", + "nloc": 10, + "complexity": 3, + "token_count": 62, + "parameters": [ + "self", + "sources", + "exts" + ], + "start_line": 285, + "end_line": 294, + "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": 36, + "complexity": 10, + "token_count": 267, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 296, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "pyrex_sources", + "long_name": "pyrex_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 38, + "complexity": 10, + "token_count": 243, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 333, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "f2py_sources", + "long_name": "f2py_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 122, + "complexity": 33, + "token_count": 953, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 372, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 1 + }, + { + "name": "swig_sources", + "long_name": "swig_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 82, + "complexity": 19, + "token_count": 542, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 508, + "end_line": 597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + }, + { + "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": 608, + "end_line": 617, + "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": 619, + "end_line": 628, + "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": 630, + "end_line": 635, + "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": 644, + "end_line": 656, + "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": 14, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 34, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 9, + "token_count": 194, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "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": 81, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_sources", + "long_name": "build_sources( self )", + "filename": "build_src.py", + "nloc": 10, + "complexity": 4, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "build_data_files_sources", + "long_name": "build_data_files_sources( self )", + "filename": "build_src.py", + "nloc": 35, + "complexity": 11, + "token_count": 214, + "parameters": [ + "self" + ], + "start_line": 105, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "build_py_modules_sources", + "long_name": "build_py_modules_sources( self )", + "filename": "build_src.py", + "nloc": 28, + "complexity": 10, + "token_count": 192, + "parameters": [ + "self" + ], + "start_line": 141, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 1 + }, + { + "name": "build_library_sources", + "long_name": "build_library_sources( self , lib_name , build_info )", + "filename": "build_src.py", + "nloc": 12, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "lib_name", + "build_info" + ], + "start_line": 170, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "build_extension_sources", + "long_name": "build_extension_sources( self , ext )", + "filename": "build_src.py", + "nloc": 27, + "complexity": 5, + "token_count": 236, + "parameters": [ + "self", + "ext" + ], + "start_line": 193, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "generate_sources", + "long_name": "generate_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 31, + "complexity": 10, + "token_count": 183, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 240, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "filter_py_files", + "long_name": "filter_py_files( self , sources )", + "filename": "build_src.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "sources" + ], + "start_line": 279, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "filter_h_files", + "long_name": "filter_h_files( self , sources )", + "filename": "build_src.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "sources" + ], + "start_line": 282, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "filter_files", + "long_name": "filter_files( self , sources , exts = [ ] )", + "filename": "build_src.py", + "nloc": 10, + "complexity": 3, + "token_count": 62, + "parameters": [ + "self", + "sources", + "exts" + ], + "start_line": 285, + "end_line": 294, + "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": 36, + "complexity": 10, + "token_count": 267, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 296, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "pyrex_sources", + "long_name": "pyrex_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 38, + "complexity": 10, + "token_count": 243, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 333, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "f2py_sources", + "long_name": "f2py_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 122, + "complexity": 33, + "token_count": 953, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 372, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 1 + }, + { + "name": "swig_sources", + "long_name": "swig_sources( self , sources , extension )", + "filename": "build_src.py", + "nloc": 82, + "complexity": 19, + "token_count": 542, + "parameters": [ + "self", + "sources", + "extension" + ], + "start_line": 508, + "end_line": 597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + }, + { + "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": 608, + "end_line": 617, + "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": 619, + "end_line": 628, + "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": 630, + "end_line": 635, + "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": 644, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "build_py_modules_sources", + "long_name": "build_py_modules_sources( self )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 9, + "token_count": 179, + "parameters": [ + "self" + ], + "start_line": 145, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "build_extension_sources", + "long_name": "build_extension_sources( self , ext )", + "filename": "build_src.py", + "nloc": 26, + "complexity": 5, + "token_count": 228, + "parameters": [ + "self", + "ext" + ], + "start_line": 195, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + }, + { + "name": "build_data_files_sources", + "long_name": "build_data_files_sources( self )", + "filename": "build_src.py", + "nloc": 35, + "complexity": 11, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "build_sources", + "long_name": "build_sources( self )", + "filename": "build_src.py", + "nloc": 13, + "complexity": 5, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + } + ], + "nloc": 553, + "complexity": 146, + "token_count": 3852, + "diff_parsed": { + "added": [ + " if self.inplace:", + " self.get_package_dir = self.get_finalized_command('build_py')\\", + " .get_package_dir", + "", + " build_dir = self.get_package_dir('.'.join(d.split(os.sep)))", + " build_dir = self.get_package_dir(package)", + " self.ext_target_dir = self.get_package_dir(package)" + ], + "deleted": [ + " build_dir = d", + " if self.inplace:", + " get_package_dir = self.get_finalized_command('build_py').get_package_dir", + " build_dir = get_package_dir(package)", + "", + " build_py = self.get_finalized_command('build_py')", + " self.ext_target_dir = build_py.get_package_dir(package)" + ] + } + } + ] + }, + { + "hash": "827b79a954d3f222bb1f618fd0a14e606dbd7e6e", + "msg": "Fixed _wrapit so that it correctly handled non-array return values.", + "author": { + "name": "Tim Hochberg", + "email": "tim_hochberg@local" + }, + "committer": { + "name": "Tim Hochberg", + "email": "tim_hochberg@local" + }, + "author_date": "2006-03-31T16:28:24+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T16:28:24+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f0c7ba02e42d71d120cc782395f01acc6ae15db0" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 3, + "insertions": 17, + "lines": 20, + "files": 2, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/core/oldnumeric.py", + "new_path": "numpy/core/oldnumeric.py", + "filename": "oldnumeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -166,7 +166,7 @@ def _wrapit(obj, method, *args, **kwds):\n except AttributeError:\n wrap = None\n result = getattr(asarray(obj),method)(*args, **kwds)\n- if wrap:\n+ if wrap and isinstance(result, mu.ndarray):\n \tif not isinstance(result, mu.ndarray):\n result = asarray(result)\n result = wrap(result)\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "# Compatibility module containing deprecated names\n\n__all__ = ['asarray', 'array', 'concatenate',\n 'NewAxis',\n 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',\n 'LittleEndian', 'Bool',\n 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',\n 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger',\n # UnsignedInt64 and Unsigned128 added below if possible\n # same for Int64 and Int128, Float128, and Complex128\n 'Int8', 'Int16', 'Int32',\n 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',\n 'PyObject', 'Float32', 'Float64', 'Float16', 'Float8',\n 'Complex32', 'Complex64', 'Complex8', 'Complex16',\n 'typecodes', 'sarray', 'arrayrange', 'cross_correlate',\n 'matrixmultiply', 'outerproduct', 'innerproduct',\n # from cPickle\n 'dump', 'dumps',\n # functions that are now methods\n 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask',\n 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin',\n 'searchsorted', 'alen',\n 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape',\n 'compress', 'clip', 'sum', 'product', 'prod', 'sometrue', 'alltrue',\n 'any', 'all', 'cumsum', 'cumproduct', 'cumprod', 'ptp', 'ndim',\n 'rank', 'size', 'around', 'round_', 'mean', 'std', 'var', 'squeeze',\n 'amax', 'amin',\n ]\n\nimport multiarray as mu\nimport umath as um\nimport numerictypes as nt\nfrom numeric import asarray, array, asanyarray, correlate, outer, concatenate\nfrom umath import sign, absolute, multiply\nimport numeric as _nx\nimport sys\n_dt_ = nt.sctype2char\n\nimport types\n\ntry:\n _gentype = types.GeneratorType\nexcept AttributeError:\n _gentype = types.NoneType\n#Use this to add a new axis to an array\n#compatibility only\nNewAxis = None\n\n#deprecated\nUFuncType = type(um.sin)\nUfuncType = type(um.sin)\nArrayType = mu.ndarray\narraytype = mu.ndarray\n\nLittleEndian = (sys.byteorder == 'little')\n\n# save away Python sum\n_sum_ = sum\n\n# backward compatible names from old Precision.py\n\nCharacter = 'S1'\nUnsignedInt8 = _dt_(nt.uint8)\nUInt8 = UnsignedInt8\nUnsignedInt16 = _dt_(nt.uint16)\nUInt16 = UnsignedInt16\nUnsignedInt32 = _dt_(nt.uint32)\nUInt32 = UnsignedInt32\nUnsignedInt = _dt_(nt.uint)\n\ntry:\n UnsignedInt64 = _dt_(nt.uint64)\nexcept AttributeError:\n pass\nelse:\n UInt64 = UnsignedInt64\n __all__ += ['UnsignedInt64', 'UInt64']\ntry:\n UnsignedInt128 = _dt_(nt.uint128)\nexcept AttributeError:\n pass\nelse:\n UInt128 = UnsignedInt128\n __all__ += ['UnsignedInt128','UInt128']\n\nInt8 = _dt_(nt.int8)\nInt16 = _dt_(nt.int16)\nInt32 = _dt_(nt.int32)\n\ntry:\n Int64 = _dt_(nt.int64)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int64']\n\ntry:\n Int128 = _dt_(nt.int128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int128']\n\nBool = _dt_(bool)\nInt0 = _dt_(int)\nInt = _dt_(int)\nFloat0 = _dt_(float)\nFloat = _dt_(float)\nComplex0 = _dt_(complex)\nComplex = _dt_(complex)\nPyObject = _dt_(nt.object_)\nFloat32 = _dt_(nt.float32)\nFloat64 = _dt_(nt.float64)\n\nFloat16='f'\nFloat8='f'\nUnsignedInteger='L'\nComplex8='F'\nComplex16='F'\n\ntry:\n Float128 = _dt_(nt.float128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Float128']\n\nComplex32 = _dt_(nt.complex64)\nComplex64 = _dt_(nt.complex128)\n\ntry:\n Complex128 = _dt_(nt.complex256)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Complex128']\n\ntypecodes = {'Character':'S1',\n 'Integer':'bhilqp',\n 'UnsignedInteger':'BHILQP',\n 'Float':'fdg',\n 'Complex':'FDG',\n 'AllInteger':'bBhHiIlLqQpP',\n 'AllFloat':'fdgFDG',\n 'All':'?bhilqpBHILQPfdgFDGSUVO'}\n\ndef sarray(a, dtype=None, copy=False):\n return array(a, dtype, copy)\n\n# backward compatibility\narrayrange = mu.arange\ncross_correlate = correlate\n\n# deprecated names\nmatrixmultiply = mu.dot\nouterproduct = outer\ninnerproduct = mu.inner\n\nfrom cPickle import dump, dumps\n\n# functions that are now methods\n\ndef _wrapit(obj, method, *args, **kwds):\n try:\n wrap = obj.__array_wrap__\n except AttributeError:\n wrap = None\n result = getattr(asarray(obj),method)(*args, **kwds)\n if wrap and isinstance(result, mu.ndarray):\n\tif not isinstance(result, mu.ndarray):\n result = asarray(result)\n result = wrap(result)\n return result\n\ndef take(a, indices, axis=0):\n try:\n take = a.take\n except AttributeError:\n return _wrapit(a, 'take', indices, axis)\n return take(indices, axis)\n\n# not deprecated --- copy if necessary, view otherwise\ndef reshape(a, newshape, order='C'):\n \"\"\"Change the shape of a to newshape. Return a new view object if possible\n otherwise return a copy.\n \"\"\"\n try:\n reshape = a.reshape\n except AttributeError:\n return _wrapit(a, 'reshape', newshape, order=order)\n return reshape(newshape, order=order)\n\ndef choose(a, choices):\n try:\n choose = a.choose\n except AttributeError:\n return _wrapit(a, 'choose', choices)\n return choose(choices)\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n If repeats is an integer, it is interpreted as\n a tuple of length a.shape[axis] containing repeats.\n The argument a can be anything array(a) will accept.\n \"\"\"\n try:\n repeat = a.repeat\n except AttributeError:\n return _wrapit(a, 'repeat', repeats, axis)\n return repeat(repeats, axis)\n\ndef put (a, ind, v):\n \"\"\"put(a, ind, v) results in a[n] = v[n] for all n in ind\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n The routine put is the equivalent of the following (although the loop\n is in C for speed):\n\n ind = array(indices, copy=False)\n v = array(values, copy=False).astype(a.dtype)\n for i in ind: a.flat[i] = v[i]\n a must be a contiguous numpy array.\n \"\"\"\n return a.put(v,ind)\n\ndef putmask (a, mask, v):\n \"\"\"putmask(a, mask, v) results in a = v for all places mask is true.\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n \"\"\"\n return a.putmask(v, mask)\n\ndef swapaxes(a, axis1, axis2):\n \"\"\"swapaxes(a, axis1, axis2) returns array a with axis1 and axis2\n interchanged.\n \"\"\"\n try:\n swapaxes = a.swapaxes\n except AttributeError:\n return _wrapit(a, 'swapaxes', axis1, axis2)\n return swapaxes(axis1, axis2)\n\ndef transpose(a, axes=None):\n \"\"\"transpose(a, axes=None) returns a view of the array with\n dimensions permuted according to axes. If axes is None\n (default) returns array with dimensions reversed.\n \"\"\"\n try:\n transpose = a.transpose\n except AttributeError:\n return _wrapit(a, 'transpose', axes)\n return transpose(axes)\n\ndef sort(a, axis=-1):\n \"\"\"sort(a,axis=-1) returns array with elements sorted along given axis.\n \"\"\"\n a = asanyarray(a).copy()\n a.sort(axis)\n return a\n\ndef argsort(a, axis=-1):\n \"\"\"argsort(a,axis=-1) return the indices into a of the sorted array\n along the given axis, so that take(a,result,axis) is the sorted array.\n \"\"\"\n try:\n argsort = a.argsort\n except AttributeError:\n return _wrapit(a, 'argsort', axis)\n return argsort(axis)\n\ndef argmax(a, axis=-1):\n \"\"\"argmax(a,axis=-1) returns the indices to the maximum value of the\n 1-D arrays along the given axis.\n \"\"\"\n try:\n argmax = a.argmax\n except AttributeError:\n return _wrapit(a, 'argmax', axis)\n return argmax(axis)\n\ndef argmin(a, axis=-1):\n \"\"\"argmin(a,axis=-1) returns the indices to the minimum value of the\n 1-D arrays along the given axis.\n \"\"\"\n try:\n argmin = a.argmin\n except AttributeError:\n return _wrapit(a, 'argmin', axis)\n return argmin(axis)\n \ndef searchsorted(a, v):\n \"\"\"searchsorted(a, v)\n \"\"\"\n try:\n searchsorted = a.searchsorted\n except AttributeError:\n return _wrapit(a, 'searchsorted', v)\n return searchsorted(v)\n\ndef resize(a, new_shape):\n \"\"\"resize(a,new_shape) returns a new array with the specified shape.\n The original array's total size can be any size. It\n fills the new array with repeated copies of a.\n\n Note that a.resize(new_shape) will fill array with 0's\n beyond current definition of a.\n \"\"\"\n\n if isinstance(new_shape, (int, nt.integer)):\n new_shape = (new_shape,)\n a = ravel(a)\n Na = len(a)\n if not Na: return mu.zeros(new_shape, a.dtype.char)\n total_size = um.multiply.reduce(new_shape)\n n_copies = int(total_size / Na)\n extra = total_size % Na\n\n if total_size == 0:\n return a[:0]\n\n if extra != 0:\n n_copies = n_copies+1\n extra = Na-extra\n\n a = concatenate( (a,)*n_copies)\n if extra > 0:\n a = a[:-extra]\n\n return reshape(a, new_shape)\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n try:\n squeeze = a.squeeze\n except AttributeError:\n return _wrapit(a, 'squeeze')\n return squeeze()\n\ndef diagonal(a, offset=0, axis1=0, axis2=1):\n \"\"\"diagonal(a, offset=0, axis1=0, axis2=1) returns the given diagonals\n defined by the last two dimensions of the array.\n \"\"\"\n return asarray(a).diagonal(offset, axis1, axis2)\n\ndef trace(a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return asarray(a).trace(offset, axis1, axis2, dtype)\n\n# not deprecated --- always returns a 1-d array. Copy-if-necessary.\ndef ravel(m,order='C'):\n \"\"\"ravel(m) returns a 1d array corresponding to all the elements of it's\n argument. The new array is a view of m if possible, otherwise it is\n a copy.\n \"\"\"\n a = asarray(m)\n return a.ravel(order)\n\ndef nonzero(a):\n \"\"\"nonzero(a) returns the indices of the elements of a which are not zero,\n a must be 1d\n \"\"\"\n try:\n nonzero = a.nonzero\n except AttributeError:\n return _wrapit(a, 'nonzero')\n return nonzero()\n\ndef shape(a):\n \"\"\"shape(a) returns the shape of a (as a function call which\n also works on nested sequences).\n \"\"\"\n try:\n result = a.shape\n except AttributeError:\n result = asarray(a).shape\n return result\n\ndef compress(condition, m, axis=-1):\n \"\"\"compress(condition, x, axis=-1) = those elements of x corresponding\n to those elements of condition that are \"true\". condition must be the\n same size as the given dimension of x.\"\"\"\n try:\n compress = m.compress\n except AttributeError:\n return _wrapit(m, 'compress', condition, axis)\n return compress(condition, axis)\n\ndef clip(m, m_min, m_max):\n \"\"\"clip(m, m_min, m_max) = every entry in m that is less than m_min is\n replaced by m_min, and every entry greater than m_max is replaced by\n m_max.\n \"\"\"\n try:\n clip = m.clip\n except AttributeError:\n return _wrapit(m, 'clip', m_min, m_max)\n return clip(m_min, m_max)\n\ndef sum(x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis. The optional dtype argument\n is the data type for intermediate calculations.\n\n The default is to upcast (promote) smaller integer types to the\n platform-dependent Int. For example, on 32-bit platforms:\n\n x.dtype default sum() dtype\n ---------------------------------------------------\n bool, Int8, Int16, Int32 Int32\n\n Examples:\n >>> sum([0.5, 1.5])\n 2.0\n >>> sum([0.5, 1.5], dtype=Int32)\n 1\n >>> sum([[0, 1], [0, 5]])\n array([0, 6])\n >>> sum([[0, 1], [0, 5]], axis=1)\n array([1, 5])\n \"\"\"\n if isinstance(x, _gentype):\n return _sum_(x)\n try:\n sum = x.sum\n except AttributeError:\n return _wrapit(x, 'sum', axis, dtype)\n return sum(axis, dtype)\n\ndef product (x, axis=0, dtype=None):\n \"\"\"Product of the array elements over the given axis.\"\"\"\n try:\n prod = x.prod\n except AttributeError:\n return _wrapit(x, 'prod', axis, dtype)\n return prod(axis, dtype)\n\ndef sometrue (x, axis=0):\n \"\"\"Perform a logical_or over the given axis.\"\"\"\n try:\n any = x.any\n except AttributeError:\n return _wrapit(x, 'any', axis)\n return any(axis)\n\ndef alltrue (x, axis=0):\n \"\"\"Perform a logical_and over the given axis.\"\"\"\n try:\n all = x.all\n except AttributeError:\n return _wrapit(x, 'all', axis)\n return all(axis)\n\ndef any(x,axis=None):\n \"\"\"Return true if any elements of x are true: \n \"\"\"\n try:\n any = x.any\n except AttributeError:\n return _wrapit(x, 'any', axis)\n return any(axis)\n\ndef all(x,axis=None):\n \"\"\"Return true if all elements of x are true: \n \"\"\"\n try:\n all = x.all\n except AttributeError:\n return _wrapit(x, 'all', axis)\n return all(axis)\n\ndef cumsum (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n try:\n cumsum = x.cumsum\n except AttributeError:\n return _wrapit(x, 'cumsum', axis, dtype)\n return cumsum(axis, dtype)\n\ndef cumproduct (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n try:\n cumprod = x.cumprod\n except AttributeError:\n return _wrapit(x, 'cumprod', axis, dtype)\n return cumprod(axis, dtype)\n\ndef ptp(a, axis=0):\n \"\"\"Return maximum - minimum along the the given dimension\n \"\"\"\n try:\n ptp = a.ptp\n except AttributeError:\n return _wrapit(a, 'ptp', axis)\n return ptp(axis)\n\ndef amax(a, axis=0):\n \"\"\"Return the maximum of 'a' along dimension axis.\n \"\"\"\n try:\n max = a.max\n except AttributeError:\n return _wrapit(a, 'max', axis)\n return max(axis)\n\ndef amin(a, axis=0):\n \"\"\"Return the minimum of a along dimension axis.\n \"\"\"\n try:\n min = a.min\n except AttributeError:\n return _wrapit(a, 'min', axis)\n return min(axis)\n\ndef alen(a):\n \"\"\"Return the length of a Python object interpreted as an array\n of at least 1 dimension.\n \"\"\"\n try:\n return len(a)\n except TypeError:\n return len(array(a,ndmin=1))\n\ndef prod(a, axis=0, dtype=None):\n \"\"\"Return the product of the elements along the given axis\n \"\"\"\n try:\n prod = a.prod\n except AttributeError:\n return _wrapit(a, 'prod', axis, dtype)\n return prod(axis, dtype)\n\ndef cumprod(a, axis=0, dtype=None):\n \"\"\"Return the cumulative product of the elments along the given axis\n \"\"\"\n try:\n cumprod = a.cumprod\n except AttributeError:\n return _wrapit(a, 'cumprod', axis, dtype)\n return cumprod(axis, dtype)\n\ndef ndim(a):\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef rank(a):\n \"\"\"Get the rank of sequence a (the number of dimensions, not a matrix rank)\n The rank of a scalar is zero.\n \"\"\"\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef size (a, axis=None):\n \"Get the number of elements in sequence a, or along a certain axis.\"\n if axis is None:\n try:\n return a.size\n except AttributeError:\n return asarray(a).size\n else:\n try:\n return a.shape[axis]\n except AttributeError:\n return asarray(a).shape[axis]\n\ndef round_(a, decimals=0):\n \"\"\"Round 'a' to the given number of decimal places. Rounding\n behaviour is equivalent to Python.\n\n Return 'a' if the array is not floating point. Round both the real\n and imaginary parts separately if the array is complex.\n \"\"\"\n try:\n round = a.round\n except AttributeError:\n return _wrapit(a, 'round', decimals)\n return round(decimals)\n\naround = round_\n\ndef mean(a, axis=0, dtype=None):\n try:\n mean = a.mean\n except AttributeError:\n return _wrapit(a, 'mean', axis, dtype)\n return mean(axis, dtype) \n\ndef std(a, axis=0, dtype=None):\n try:\n std = a.std\n except AttributeError:\n return _wrapit(a, 'std', axis, dtype)\n return std(axis, dtype)\n\ndef var(a, axis=0, dtype=None):\n try:\n var = a.var\n except AttributeError:\n return _wrapit(a, 'var', axis, dtype)\n return var(axis, dtype)\n", + "source_code_before": "# Compatibility module containing deprecated names\n\n__all__ = ['asarray', 'array', 'concatenate',\n 'NewAxis',\n 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',\n 'LittleEndian', 'Bool',\n 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',\n 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger',\n # UnsignedInt64 and Unsigned128 added below if possible\n # same for Int64 and Int128, Float128, and Complex128\n 'Int8', 'Int16', 'Int32',\n 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',\n 'PyObject', 'Float32', 'Float64', 'Float16', 'Float8',\n 'Complex32', 'Complex64', 'Complex8', 'Complex16',\n 'typecodes', 'sarray', 'arrayrange', 'cross_correlate',\n 'matrixmultiply', 'outerproduct', 'innerproduct',\n # from cPickle\n 'dump', 'dumps',\n # functions that are now methods\n 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask',\n 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin',\n 'searchsorted', 'alen',\n 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape',\n 'compress', 'clip', 'sum', 'product', 'prod', 'sometrue', 'alltrue',\n 'any', 'all', 'cumsum', 'cumproduct', 'cumprod', 'ptp', 'ndim',\n 'rank', 'size', 'around', 'round_', 'mean', 'std', 'var', 'squeeze',\n 'amax', 'amin',\n ]\n\nimport multiarray as mu\nimport umath as um\nimport numerictypes as nt\nfrom numeric import asarray, array, asanyarray, correlate, outer, concatenate\nfrom umath import sign, absolute, multiply\nimport numeric as _nx\nimport sys\n_dt_ = nt.sctype2char\n\nimport types\n\ntry:\n _gentype = types.GeneratorType\nexcept AttributeError:\n _gentype = types.NoneType\n#Use this to add a new axis to an array\n#compatibility only\nNewAxis = None\n\n#deprecated\nUFuncType = type(um.sin)\nUfuncType = type(um.sin)\nArrayType = mu.ndarray\narraytype = mu.ndarray\n\nLittleEndian = (sys.byteorder == 'little')\n\n# save away Python sum\n_sum_ = sum\n\n# backward compatible names from old Precision.py\n\nCharacter = 'S1'\nUnsignedInt8 = _dt_(nt.uint8)\nUInt8 = UnsignedInt8\nUnsignedInt16 = _dt_(nt.uint16)\nUInt16 = UnsignedInt16\nUnsignedInt32 = _dt_(nt.uint32)\nUInt32 = UnsignedInt32\nUnsignedInt = _dt_(nt.uint)\n\ntry:\n UnsignedInt64 = _dt_(nt.uint64)\nexcept AttributeError:\n pass\nelse:\n UInt64 = UnsignedInt64\n __all__ += ['UnsignedInt64', 'UInt64']\ntry:\n UnsignedInt128 = _dt_(nt.uint128)\nexcept AttributeError:\n pass\nelse:\n UInt128 = UnsignedInt128\n __all__ += ['UnsignedInt128','UInt128']\n\nInt8 = _dt_(nt.int8)\nInt16 = _dt_(nt.int16)\nInt32 = _dt_(nt.int32)\n\ntry:\n Int64 = _dt_(nt.int64)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int64']\n\ntry:\n Int128 = _dt_(nt.int128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int128']\n\nBool = _dt_(bool)\nInt0 = _dt_(int)\nInt = _dt_(int)\nFloat0 = _dt_(float)\nFloat = _dt_(float)\nComplex0 = _dt_(complex)\nComplex = _dt_(complex)\nPyObject = _dt_(nt.object_)\nFloat32 = _dt_(nt.float32)\nFloat64 = _dt_(nt.float64)\n\nFloat16='f'\nFloat8='f'\nUnsignedInteger='L'\nComplex8='F'\nComplex16='F'\n\ntry:\n Float128 = _dt_(nt.float128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Float128']\n\nComplex32 = _dt_(nt.complex64)\nComplex64 = _dt_(nt.complex128)\n\ntry:\n Complex128 = _dt_(nt.complex256)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Complex128']\n\ntypecodes = {'Character':'S1',\n 'Integer':'bhilqp',\n 'UnsignedInteger':'BHILQP',\n 'Float':'fdg',\n 'Complex':'FDG',\n 'AllInteger':'bBhHiIlLqQpP',\n 'AllFloat':'fdgFDG',\n 'All':'?bhilqpBHILQPfdgFDGSUVO'}\n\ndef sarray(a, dtype=None, copy=False):\n return array(a, dtype, copy)\n\n# backward compatibility\narrayrange = mu.arange\ncross_correlate = correlate\n\n# deprecated names\nmatrixmultiply = mu.dot\nouterproduct = outer\ninnerproduct = mu.inner\n\nfrom cPickle import dump, dumps\n\n# functions that are now methods\n\ndef _wrapit(obj, method, *args, **kwds):\n try:\n wrap = obj.__array_wrap__\n except AttributeError:\n wrap = None\n result = getattr(asarray(obj),method)(*args, **kwds)\n if wrap:\n\tif not isinstance(result, mu.ndarray):\n result = asarray(result)\n result = wrap(result)\n return result\n\ndef take(a, indices, axis=0):\n try:\n take = a.take\n except AttributeError:\n return _wrapit(a, 'take', indices, axis)\n return take(indices, axis)\n\n# not deprecated --- copy if necessary, view otherwise\ndef reshape(a, newshape, order='C'):\n \"\"\"Change the shape of a to newshape. Return a new view object if possible\n otherwise return a copy.\n \"\"\"\n try:\n reshape = a.reshape\n except AttributeError:\n return _wrapit(a, 'reshape', newshape, order=order)\n return reshape(newshape, order=order)\n\ndef choose(a, choices):\n try:\n choose = a.choose\n except AttributeError:\n return _wrapit(a, 'choose', choices)\n return choose(choices)\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n If repeats is an integer, it is interpreted as\n a tuple of length a.shape[axis] containing repeats.\n The argument a can be anything array(a) will accept.\n \"\"\"\n try:\n repeat = a.repeat\n except AttributeError:\n return _wrapit(a, 'repeat', repeats, axis)\n return repeat(repeats, axis)\n\ndef put (a, ind, v):\n \"\"\"put(a, ind, v) results in a[n] = v[n] for all n in ind\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n The routine put is the equivalent of the following (although the loop\n is in C for speed):\n\n ind = array(indices, copy=False)\n v = array(values, copy=False).astype(a.dtype)\n for i in ind: a.flat[i] = v[i]\n a must be a contiguous numpy array.\n \"\"\"\n return a.put(v,ind)\n\ndef putmask (a, mask, v):\n \"\"\"putmask(a, mask, v) results in a = v for all places mask is true.\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n \"\"\"\n return a.putmask(v, mask)\n\ndef swapaxes(a, axis1, axis2):\n \"\"\"swapaxes(a, axis1, axis2) returns array a with axis1 and axis2\n interchanged.\n \"\"\"\n try:\n swapaxes = a.swapaxes\n except AttributeError:\n return _wrapit(a, 'swapaxes', axis1, axis2)\n return swapaxes(axis1, axis2)\n\ndef transpose(a, axes=None):\n \"\"\"transpose(a, axes=None) returns a view of the array with\n dimensions permuted according to axes. If axes is None\n (default) returns array with dimensions reversed.\n \"\"\"\n try:\n transpose = a.transpose\n except AttributeError:\n return _wrapit(a, 'transpose', axes)\n return transpose(axes)\n\ndef sort(a, axis=-1):\n \"\"\"sort(a,axis=-1) returns array with elements sorted along given axis.\n \"\"\"\n a = asanyarray(a).copy()\n a.sort(axis)\n return a\n\ndef argsort(a, axis=-1):\n \"\"\"argsort(a,axis=-1) return the indices into a of the sorted array\n along the given axis, so that take(a,result,axis) is the sorted array.\n \"\"\"\n try:\n argsort = a.argsort\n except AttributeError:\n return _wrapit(a, 'argsort', axis)\n return argsort(axis)\n\ndef argmax(a, axis=-1):\n \"\"\"argmax(a,axis=-1) returns the indices to the maximum value of the\n 1-D arrays along the given axis.\n \"\"\"\n try:\n argmax = a.argmax\n except AttributeError:\n return _wrapit(a, 'argmax', axis)\n return argmax(axis)\n\ndef argmin(a, axis=-1):\n \"\"\"argmin(a,axis=-1) returns the indices to the minimum value of the\n 1-D arrays along the given axis.\n \"\"\"\n try:\n argmin = a.argmin\n except AttributeError:\n return _wrapit(a, 'argmin', axis)\n return argmin(axis)\n \ndef searchsorted(a, v):\n \"\"\"searchsorted(a, v)\n \"\"\"\n try:\n searchsorted = a.searchsorted\n except AttributeError:\n return _wrapit(a, 'searchsorted', v)\n return searchsorted(v)\n\ndef resize(a, new_shape):\n \"\"\"resize(a,new_shape) returns a new array with the specified shape.\n The original array's total size can be any size. It\n fills the new array with repeated copies of a.\n\n Note that a.resize(new_shape) will fill array with 0's\n beyond current definition of a.\n \"\"\"\n\n if isinstance(new_shape, (int, nt.integer)):\n new_shape = (new_shape,)\n a = ravel(a)\n Na = len(a)\n if not Na: return mu.zeros(new_shape, a.dtype.char)\n total_size = um.multiply.reduce(new_shape)\n n_copies = int(total_size / Na)\n extra = total_size % Na\n\n if total_size == 0:\n return a[:0]\n\n if extra != 0:\n n_copies = n_copies+1\n extra = Na-extra\n\n a = concatenate( (a,)*n_copies)\n if extra > 0:\n a = a[:-extra]\n\n return reshape(a, new_shape)\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n try:\n squeeze = a.squeeze\n except AttributeError:\n return _wrapit(a, 'squeeze')\n return squeeze()\n\ndef diagonal(a, offset=0, axis1=0, axis2=1):\n \"\"\"diagonal(a, offset=0, axis1=0, axis2=1) returns the given diagonals\n defined by the last two dimensions of the array.\n \"\"\"\n return asarray(a).diagonal(offset, axis1, axis2)\n\ndef trace(a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return asarray(a).trace(offset, axis1, axis2, dtype)\n\n# not deprecated --- always returns a 1-d array. Copy-if-necessary.\ndef ravel(m,order='C'):\n \"\"\"ravel(m) returns a 1d array corresponding to all the elements of it's\n argument. The new array is a view of m if possible, otherwise it is\n a copy.\n \"\"\"\n a = asarray(m)\n return a.ravel(order)\n\ndef nonzero(a):\n \"\"\"nonzero(a) returns the indices of the elements of a which are not zero,\n a must be 1d\n \"\"\"\n try:\n nonzero = a.nonzero\n except AttributeError:\n return _wrapit(a, 'nonzero')\n return nonzero()\n\ndef shape(a):\n \"\"\"shape(a) returns the shape of a (as a function call which\n also works on nested sequences).\n \"\"\"\n try:\n result = a.shape\n except AttributeError:\n result = asarray(a).shape\n return result\n\ndef compress(condition, m, axis=-1):\n \"\"\"compress(condition, x, axis=-1) = those elements of x corresponding\n to those elements of condition that are \"true\". condition must be the\n same size as the given dimension of x.\"\"\"\n try:\n compress = m.compress\n except AttributeError:\n return _wrapit(m, 'compress', condition, axis)\n return compress(condition, axis)\n\ndef clip(m, m_min, m_max):\n \"\"\"clip(m, m_min, m_max) = every entry in m that is less than m_min is\n replaced by m_min, and every entry greater than m_max is replaced by\n m_max.\n \"\"\"\n try:\n clip = m.clip\n except AttributeError:\n return _wrapit(m, 'clip', m_min, m_max)\n return clip(m_min, m_max)\n\ndef sum(x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis. The optional dtype argument\n is the data type for intermediate calculations.\n\n The default is to upcast (promote) smaller integer types to the\n platform-dependent Int. For example, on 32-bit platforms:\n\n x.dtype default sum() dtype\n ---------------------------------------------------\n bool, Int8, Int16, Int32 Int32\n\n Examples:\n >>> sum([0.5, 1.5])\n 2.0\n >>> sum([0.5, 1.5], dtype=Int32)\n 1\n >>> sum([[0, 1], [0, 5]])\n array([0, 6])\n >>> sum([[0, 1], [0, 5]], axis=1)\n array([1, 5])\n \"\"\"\n if isinstance(x, _gentype):\n return _sum_(x)\n try:\n sum = x.sum\n except AttributeError:\n return _wrapit(x, 'sum', axis, dtype)\n return sum(axis, dtype)\n\ndef product (x, axis=0, dtype=None):\n \"\"\"Product of the array elements over the given axis.\"\"\"\n try:\n prod = x.prod\n except AttributeError:\n return _wrapit(x, 'prod', axis, dtype)\n return prod(axis, dtype)\n\ndef sometrue (x, axis=0):\n \"\"\"Perform a logical_or over the given axis.\"\"\"\n try:\n any = x.any\n except AttributeError:\n return _wrapit(x, 'any', axis)\n return any(axis)\n\ndef alltrue (x, axis=0):\n \"\"\"Perform a logical_and over the given axis.\"\"\"\n try:\n all = x.all\n except AttributeError:\n return _wrapit(x, 'all', axis)\n return all(axis)\n\ndef any(x,axis=None):\n \"\"\"Return true if any elements of x are true: \n \"\"\"\n try:\n any = x.any\n except AttributeError:\n return _wrapit(x, 'any', axis)\n return any(axis)\n\ndef all(x,axis=None):\n \"\"\"Return true if all elements of x are true: \n \"\"\"\n try:\n all = x.all\n except AttributeError:\n return _wrapit(x, 'all', axis)\n return all(axis)\n\ndef cumsum (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n try:\n cumsum = x.cumsum\n except AttributeError:\n return _wrapit(x, 'cumsum', axis, dtype)\n return cumsum(axis, dtype)\n\ndef cumproduct (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n try:\n cumprod = x.cumprod\n except AttributeError:\n return _wrapit(x, 'cumprod', axis, dtype)\n return cumprod(axis, dtype)\n\ndef ptp(a, axis=0):\n \"\"\"Return maximum - minimum along the the given dimension\n \"\"\"\n try:\n ptp = a.ptp\n except AttributeError:\n return _wrapit(a, 'ptp', axis)\n return ptp(axis)\n\ndef amax(a, axis=0):\n \"\"\"Return the maximum of 'a' along dimension axis.\n \"\"\"\n try:\n max = a.max\n except AttributeError:\n return _wrapit(a, 'max', axis)\n return max(axis)\n\ndef amin(a, axis=0):\n \"\"\"Return the minimum of a along dimension axis.\n \"\"\"\n try:\n min = a.min\n except AttributeError:\n return _wrapit(a, 'min', axis)\n return min(axis)\n\ndef alen(a):\n \"\"\"Return the length of a Python object interpreted as an array\n of at least 1 dimension.\n \"\"\"\n try:\n return len(a)\n except TypeError:\n return len(array(a,ndmin=1))\n\ndef prod(a, axis=0, dtype=None):\n \"\"\"Return the product of the elements along the given axis\n \"\"\"\n try:\n prod = a.prod\n except AttributeError:\n return _wrapit(a, 'prod', axis, dtype)\n return prod(axis, dtype)\n\ndef cumprod(a, axis=0, dtype=None):\n \"\"\"Return the cumulative product of the elments along the given axis\n \"\"\"\n try:\n cumprod = a.cumprod\n except AttributeError:\n return _wrapit(a, 'cumprod', axis, dtype)\n return cumprod(axis, dtype)\n\ndef ndim(a):\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef rank(a):\n \"\"\"Get the rank of sequence a (the number of dimensions, not a matrix rank)\n The rank of a scalar is zero.\n \"\"\"\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef size (a, axis=None):\n \"Get the number of elements in sequence a, or along a certain axis.\"\n if axis is None:\n try:\n return a.size\n except AttributeError:\n return asarray(a).size\n else:\n try:\n return a.shape[axis]\n except AttributeError:\n return asarray(a).shape[axis]\n\ndef round_(a, decimals=0):\n \"\"\"Round 'a' to the given number of decimal places. Rounding\n behaviour is equivalent to Python.\n\n Return 'a' if the array is not floating point. Round both the real\n and imaginary parts separately if the array is complex.\n \"\"\"\n try:\n round = a.round\n except AttributeError:\n return _wrapit(a, 'round', decimals)\n return round(decimals)\n\naround = round_\n\ndef mean(a, axis=0, dtype=None):\n try:\n mean = a.mean\n except AttributeError:\n return _wrapit(a, 'mean', axis, dtype)\n return mean(axis, dtype) \n\ndef std(a, axis=0, dtype=None):\n try:\n std = a.std\n except AttributeError:\n return _wrapit(a, 'std', axis, dtype)\n return std(axis, dtype)\n\ndef var(a, axis=0, dtype=None):\n try:\n var = a.var\n except AttributeError:\n return _wrapit(a, 'var', axis, dtype)\n return var(axis, dtype)\n", + "methods": [ + { + "name": "sarray", + "long_name": "sarray( a , dtype = None , copy = False )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "a", + "dtype", + "copy" + ], + "start_line": 147, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_wrapit", + "long_name": "_wrapit( obj , method , * args , ** kwds )", + "filename": "oldnumeric.py", + "nloc": 11, + "complexity": 5, + "token_count": 81, + "parameters": [ + "obj", + "method", + "args", + "kwds" + ], + "start_line": 163, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 175, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , newshape , order = 'C' )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "a", + "newshape", + "order" + ], + "start_line": 183, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "choose", + "long_name": "choose( a , choices )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "a", + "choices" + ], + "start_line": 193, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 200, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , ind , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "ind", + "v" + ], + "start_line": 214, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "mask", + "v" + ], + "start_line": 228, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 38, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axes" + ], + "start_line": 245, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "sort", + "long_name": "sort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "axis" + ], + "start_line": 256, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 263, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 273, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 283, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "searchsorted", + "long_name": "searchsorted( a , v )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "a", + "v" + ], + "start_line": 293, + "end_line": 300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "oldnumeric.py", + "nloc": 18, + "complexity": 6, + "token_count": 137, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 302, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "squeeze", + "long_name": "squeeze( a )", + "filename": "oldnumeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 27, + "parameters": [ + "a" + ], + "start_line": 333, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , offset = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "offset", + "axis1", + "axis2" + ], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 347, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( m , order = 'C' )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "m", + "order" + ], + "start_line": 354, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "nonzero", + "long_name": "nonzero( a )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 27, + "parameters": [ + "a" + ], + "start_line": 362, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( a )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 26, + "parameters": [ + "a" + ], + "start_line": 372, + "end_line": 380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , m , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "condition", + "m", + "axis" + ], + "start_line": 382, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "clip", + "long_name": "clip( m , m_min , m_max )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m", + "m_min", + "m_max" + ], + "start_line": 392, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "sum", + "long_name": "sum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 55, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 403, + "end_line": 430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 432, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "sometrue", + "long_name": "sometrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 440, + "end_line": 446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "alltrue", + "long_name": "alltrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 448, + "end_line": 454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "any", + "long_name": "any( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 456, + "end_line": 463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "all", + "long_name": "all( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 465, + "end_line": 472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 474, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 482, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ptp", + "long_name": "ptp( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 490, + "end_line": 497, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "amax", + "long_name": "amax( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 499, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "amin", + "long_name": "amin( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 508, + "end_line": 515, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "alen", + "long_name": "alen( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "a" + ], + "start_line": 517, + "end_line": 524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "prod", + "long_name": "prod( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 526, + "end_line": 533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cumprod", + "long_name": "cumprod( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 535, + "end_line": 542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ndim", + "long_name": "ndim( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 544, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a" + ], + "start_line": 550, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( a , axis = None )", + "filename": "oldnumeric.py", + "nloc": 12, + "complexity": 4, + "token_count": 55, + "parameters": [ + "a", + "axis" + ], + "start_line": 559, + "end_line": 570, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "round_", + "long_name": "round_( a , decimals = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "decimals" + ], + "start_line": 572, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "mean", + "long_name": "mean( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 587, + "end_line": 592, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "std", + "long_name": "std( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 594, + "end_line": 599, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "var", + "long_name": "var( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 601, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "sarray", + "long_name": "sarray( a , dtype = None , copy = False )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "a", + "dtype", + "copy" + ], + "start_line": 147, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_wrapit", + "long_name": "_wrapit( obj , method , * args , ** kwds )", + "filename": "oldnumeric.py", + "nloc": 11, + "complexity": 4, + "token_count": 72, + "parameters": [ + "obj", + "method", + "args", + "kwds" + ], + "start_line": 163, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 175, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , newshape , order = 'C' )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "a", + "newshape", + "order" + ], + "start_line": 183, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "choose", + "long_name": "choose( a , choices )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "a", + "choices" + ], + "start_line": 193, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 200, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , ind , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "ind", + "v" + ], + "start_line": 214, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "mask", + "v" + ], + "start_line": 228, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 38, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axes" + ], + "start_line": 245, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "sort", + "long_name": "sort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "axis" + ], + "start_line": 256, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 263, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 273, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "a", + "axis" + ], + "start_line": 283, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "searchsorted", + "long_name": "searchsorted( a , v )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "a", + "v" + ], + "start_line": 293, + "end_line": 300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "oldnumeric.py", + "nloc": 18, + "complexity": 6, + "token_count": 137, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 302, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "squeeze", + "long_name": "squeeze( a )", + "filename": "oldnumeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 27, + "parameters": [ + "a" + ], + "start_line": 333, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , offset = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "offset", + "axis1", + "axis2" + ], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 347, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( m , order = 'C' )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "m", + "order" + ], + "start_line": 354, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "nonzero", + "long_name": "nonzero( a )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 27, + "parameters": [ + "a" + ], + "start_line": 362, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( a )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 26, + "parameters": [ + "a" + ], + "start_line": 372, + "end_line": 380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , m , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "condition", + "m", + "axis" + ], + "start_line": 382, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "clip", + "long_name": "clip( m , m_min , m_max )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m", + "m_min", + "m_max" + ], + "start_line": 392, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "sum", + "long_name": "sum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 55, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 403, + "end_line": 430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 432, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "sometrue", + "long_name": "sometrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 440, + "end_line": 446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "alltrue", + "long_name": "alltrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 448, + "end_line": 454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "any", + "long_name": "any( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 456, + "end_line": 463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "all", + "long_name": "all( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "x", + "axis" + ], + "start_line": 465, + "end_line": 472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 474, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 482, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ptp", + "long_name": "ptp( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 490, + "end_line": 497, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "amax", + "long_name": "amax( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 499, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "amin", + "long_name": "amin( a , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 508, + "end_line": 515, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "alen", + "long_name": "alen( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "a" + ], + "start_line": 517, + "end_line": 524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "prod", + "long_name": "prod( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 526, + "end_line": 533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cumprod", + "long_name": "cumprod( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 42, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 535, + "end_line": 542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ndim", + "long_name": "ndim( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 544, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a" + ], + "start_line": 550, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( a , axis = None )", + "filename": "oldnumeric.py", + "nloc": 12, + "complexity": 4, + "token_count": 55, + "parameters": [ + "a", + "axis" + ], + "start_line": 559, + "end_line": 570, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "round_", + "long_name": "round_( a , decimals = 0 )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "decimals" + ], + "start_line": 572, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "mean", + "long_name": "mean( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 587, + "end_line": 592, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "std", + "long_name": "std( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 594, + "end_line": 599, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "var", + "long_name": "var( a , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "a", + "axis", + "dtype" + ], + "start_line": 601, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_wrapit", + "long_name": "_wrapit( obj , method , * args , ** kwds )", + "filename": "oldnumeric.py", + "nloc": 11, + "complexity": 5, + "token_count": 81, + "parameters": [ + "obj", + "method", + "args", + "kwds" + ], + "start_line": 163, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "nloc": 391, + "complexity": 93, + "token_count": 2406, + "diff_parsed": { + "added": [ + " if wrap and isinstance(result, mu.ndarray):" + ], + "deleted": [ + " if wrap:" + ] + } + }, + { + "old_path": "numpy/core/tests/test_oldnumeric.py", + "new_path": "numpy/core/tests/test_oldnumeric.py", + "filename": "test_oldnumeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,6 +1,6 @@\n from numpy.testing import *\n \n-from numpy import array\n+from numpy import array, ndarray, arange, argmax\n from numpy.core.oldnumeric import put\n \n class test_put(ScipyTestCase):\n@@ -9,7 +9,21 @@ def check_bug_r2089(self, level=1):\n put(a,[1],[1.2])\n assert_array_equal(a,[0,1,0])\n put(a,[1],array([2.2]))\n- assert_array_equal(a,[0,2,0])\n+ assert_array_equal(a,[0,2,0])\r\n+ \r\n+class test_wrapit(ScipyTestCase):\r\n+ def check_array_subclass(self, level=1):\r\n+ class subarray(ndarray):\n+ def get_argmax(self):\r\n+ raise AttributeError\r\n+ argmax = property(get_argmax)\r\n+ a = subarray([3], int, arange(3))\r\n+ assert_equal(argmax(a), 2)\r\n+ b = subarray([3, 3], int, arange(9))\r\n+ bmax = argmax(b)\r\n+ assert_array_equal(bmax, [2,2,2])\r\n+ assert_equal(type(bmax), subarray)\r\n+\n \n if __name__ == \"__main__\":\n ScipyTest().run()\n", + "added_lines": 16, + "deleted_lines": 2, + "source_code": "from numpy.testing import *\n\nfrom numpy import array, ndarray, arange, argmax\nfrom numpy.core.oldnumeric import put\n\nclass test_put(ScipyTestCase):\n def check_bug_r2089(self, level=1):\n a = array([0,0,0])\n put(a,[1],[1.2])\n assert_array_equal(a,[0,1,0])\n put(a,[1],array([2.2]))\n assert_array_equal(a,[0,2,0])\r\n \r\nclass test_wrapit(ScipyTestCase):\r\n def check_array_subclass(self, level=1):\r\n class subarray(ndarray):\n def get_argmax(self):\r\n raise AttributeError\r\n argmax = property(get_argmax)\r\n a = subarray([3], int, arange(3))\r\n assert_equal(argmax(a), 2)\r\n b = subarray([3, 3], int, arange(9))\r\n bmax = argmax(b)\r\n assert_array_equal(bmax, [2,2,2])\r\n assert_equal(type(bmax), subarray)\r\n\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "from numpy.testing import *\n\nfrom numpy import array\nfrom numpy.core.oldnumeric import put\n\nclass test_put(ScipyTestCase):\n def check_bug_r2089(self, level=1):\n a = array([0,0,0])\n put(a,[1],[1.2])\n assert_array_equal(a,[0,1,0])\n put(a,[1],array([2.2]))\n assert_array_equal(a,[0,2,0])\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_bug_r2089", + "long_name": "check_bug_r2089( self , level = 1 )", + "filename": "test_oldnumeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 76, + "parameters": [ + "self", + "level" + ], + "start_line": 7, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_array_subclass.get_argmax", + "long_name": "check_array_subclass.get_argmax( self )", + "filename": "test_oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 17, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_array_subclass", + "long_name": "check_array_subclass( self , level = 1 )", + "filename": "test_oldnumeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self", + "level" + ], + "start_line": 15, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_bug_r2089", + "long_name": "check_bug_r2089( self , level = 1 )", + "filename": "test_oldnumeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 76, + "parameters": [ + "self", + "level" + ], + "start_line": 7, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_array_subclass", + "long_name": "check_array_subclass( self , level = 1 )", + "filename": "test_oldnumeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self", + "level" + ], + "start_line": 15, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_bug_r2089", + "long_name": "check_bug_r2089( self , level = 1 )", + "filename": "test_oldnumeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 76, + "parameters": [ + "self", + "level" + ], + "start_line": 7, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_array_subclass.get_argmax", + "long_name": "check_array_subclass.get_argmax( self )", + "filename": "test_oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 17, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + } + ], + "nloc": 24, + "complexity": 3, + "token_count": 223, + "diff_parsed": { + "added": [ + "from numpy import array, ndarray, arange, argmax", + " assert_array_equal(a,[0,2,0])", + "", + "class test_wrapit(ScipyTestCase):", + " def check_array_subclass(self, level=1):", + " class subarray(ndarray):", + " def get_argmax(self):", + " raise AttributeError", + " argmax = property(get_argmax)", + " a = subarray([3], int, arange(3))", + " assert_equal(argmax(a), 2)", + " b = subarray([3, 3], int, arange(9))", + " bmax = argmax(b)", + " assert_array_equal(bmax, [2,2,2])", + " assert_equal(type(bmax), subarray)", + "" + ], + "deleted": [ + "from numpy import array", + " assert_array_equal(a,[0,2,0])" + ] + } + } + ] + }, + { + "hash": "8680d6f6df88d32e07a25c441fa29ac7a1095919", + "msg": "Fix typo.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-03-31T20:19:17+00:00", + "author_timezone": 0, + "committer_date": "2006-03-31T20:19:17+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "827b79a954d3f222bb1f618fd0a14e606dbd7e6e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/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": "numpy/distutils/misc_util.py", + "new_path": "numpy/distutils/misc_util.py", + "filename": "misc_util.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -865,7 +865,7 @@ def add_data_files(self,*files):\n raise TypeError,`type(files)`\n \n if d is None:\n- if callable(file):\n+ if callable(filepat):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return is_string(s) and ('*' in s or '?' is s)\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if callable(filepat):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return is_string(s) and ('*' in s or '?' is s)\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if callable(file):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "methods": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 912, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 923, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 945, + "end_line": 951, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 953, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 962, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1027, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1051, + "end_line": 1060, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1079, + "end_line": 1089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1091, + "end_line": 1100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1102, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1107, + "end_line": 1118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1120, + "end_line": 1131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1133, + "end_line": 1146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1148, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1161, + "end_line": 1207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1230, + "end_line": 1234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1219, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1209, + "end_line": 1239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1241, + "end_line": 1246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1248, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1258, + "end_line": 1268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1270, + "end_line": 1284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1288, + "end_line": 1299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1302, + "end_line": 1307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1309, + "end_line": 1328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1330, + "end_line": 1363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 912, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 923, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 945, + "end_line": 951, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 953, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 962, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1027, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1051, + "end_line": 1060, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1079, + "end_line": 1089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1091, + "end_line": 1100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1102, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1107, + "end_line": 1118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1120, + "end_line": 1131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1133, + "end_line": 1146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1148, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1161, + "end_line": 1207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1230, + "end_line": 1234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1219, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1209, + "end_line": 1239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1241, + "end_line": 1246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1248, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1258, + "end_line": 1268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1270, + "end_line": 1284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1288, + "end_line": 1299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1302, + "end_line": 1307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1309, + "end_line": 1328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1330, + "end_line": 1363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + } + ], + "nloc": 1024, + "complexity": 325, + "token_count": 7085, + "diff_parsed": { + "added": [ + " if callable(filepat):" + ], + "deleted": [ + " if callable(file):" + ] + } + } + ] + }, + { + "hash": "6cc9da7aea03502abbccf7454f73e0fc308358f5", + "msg": "Reorg. code so that numpy.distutils could be used from cwd that contains math.py.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-01T14:25:19+00:00", + "author_timezone": 0, + "committer_date": "2006-04-01T14:25:19+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "8680d6f6df88d32e07a25c441fa29ac7a1095919" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 3, + "insertions": 6, + "lines": 9, + "files": 3, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.75, + "dmm_unit_interfacing": 0.25, + "modified_files": [ + { + "old_path": "numpy/distutils/core.py", + "new_path": "numpy/distutils/core.py", + "filename": "core.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,6 +4,8 @@\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n+ # easy_install imports math, it may be picked up from cwd\n+ from setuptools.command import develop, easy_install\n have_setuptools = 1\n except ImportError:\n from distutils.core import setup as old_setup\n@@ -40,7 +42,6 @@\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\n if have_setuptools:\n- from setuptools.command import bdist_egg, develop, easy_install\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n # easy_install imports math, it may be picked up from cwd\n from setuptools.command import develop, easy_install\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef _dict_append(d, **kws):\n for k,v in kws.items():\n if not d.has_key(k):\n d[k] = v\n continue\n dv = d[k]\n if isinstance(dv, tuple):\n dv += tuple(v)\n continue\n if isinstance(dv, list):\n dv += list(v)\n continue\n if isinstance(dv, dict):\n _dict_append(dv, **v)\n continue\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n raise TypeError,`type(dv)`\n return\n\ndef _command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n if new_attr.has_key('configuration'):\n # To avoid calling configuration if there are any errors\n # or help request in command in the line.\n configuration = new_attr.pop('configuration')\n\n import distutils.core\n old_dist = distutils.core._setup_distribution\n old_stop = distutils.core._setup_stop_after\n distutils.core._setup_distribution = None\n distutils.core._setup_stop_after = \"commandline\"\n try:\n dist = setup(**new_attr)\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n except Exception,msg:\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n raise msg\n if dist.help or not _command_line_ok():\n # probably displayed help, skip running any commands\n return dist\n\n # create setup dictionary and append to new_attr\n config = configuration()\n if hasattr(config,'todict'): config = config.todict()\n _dict_append(new_attr, **config)\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "source_code_before": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from setuptools.command import bdist_egg, develop, easy_install\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef _dict_append(d, **kws):\n for k,v in kws.items():\n if not d.has_key(k):\n d[k] = v\n continue\n dv = d[k]\n if isinstance(dv, tuple):\n dv += tuple(v)\n continue\n if isinstance(dv, list):\n dv += list(v)\n continue\n if isinstance(dv, dict):\n _dict_append(dv, **v)\n continue\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n raise TypeError,`type(dv)`\n return\n\ndef _command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n if new_attr.has_key('configuration'):\n # To avoid calling configuration if there are any errors\n # or help request in command in the line.\n configuration = new_attr.pop('configuration')\n\n import distutils.core\n old_dist = distutils.core._setup_distribution\n old_stop = distutils.core._setup_stop_after\n distutils.core._setup_distribution = None\n distutils.core._setup_stop_after = \"commandline\"\n try:\n dist = setup(**new_attr)\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n except Exception,msg:\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n raise msg\n if dist.help or not _command_line_ok():\n # probably displayed help, skip running any commands\n return dist\n\n # create setup dictionary and append to new_attr\n config = configuration()\n if hasattr(config,'todict'): config = config.todict()\n _dict_append(new_attr, **config)\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "methods": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 20, + "complexity": 7, + "token_count": 125, + "parameters": [ + "d", + "kws" + ], + "start_line": 51, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 72, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 90, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 154, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 182, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 20, + "complexity": 7, + "token_count": 125, + "parameters": [ + "d", + "kws" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 71, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 89, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 153, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 181, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 170, + "complexity": 49, + "token_count": 1064, + "diff_parsed": { + "added": [ + " # easy_install imports math, it may be picked up from cwd", + " from setuptools.command import develop, easy_install" + ], + "deleted": [ + " from setuptools.command import bdist_egg, develop, easy_install" + ] + } + }, + { + "old_path": "numpy/distutils/exec_command.py", + "new_path": "numpy/distutils/exec_command.py", + "filename": "exec_command.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -51,7 +51,6 @@\n import os\n import re\n import sys\n-import tempfile\n \n from numpy.distutils.misc_util import is_sequence\n \n@@ -269,6 +268,7 @@ def _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n+ import tempfile\n log.debug('_exec_command_posix(...)')\n \n if is_sequence(command):\n@@ -320,6 +320,7 @@ def _exec_command_posix( command,\n \n def _exec_command_python(command,\n exec_command_dir='', **env):\n+ import tempfile\n log.debug('_exec_command_python(...)')\n \n python_exe = get_pythonexe()\n@@ -600,6 +601,7 @@ def test_posix(**kws):\n print 'ok'\n \n def test_execute_in(**kws):\n+ import tempfile\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n", + "added_lines": 3, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\nexec_command\n\nImplements exec_command function that is (almost) equivalent to\ncommands.getstatusoutput function but on NT, DOS systems the\nreturned status is actually correct (though, the returned status\nvalues may be different by a factor). In addition, exec_command\ntakes keyword arguments for (re-)defining environment variables.\n\nProvides functions:\n exec_command --- execute command in a specified directory and\n in the modified environment.\n splitcmdline --- inverse of ' '.join(argv)\n find_executable --- locate a command using info from environment\n variable PATH. Equivalent to posix `which`\n command.\n\nAuthor: Pearu Peterson \nCreated: 11 January 2003\n\nRequires: Python 2.x\n\nSuccesfully tested on:\n os.name | sys.platform | comments\n --------+--------------+----------\n posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n PyCrust 0.9.3, Idle 1.0.2\n posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n posix | darwin | Darwin 7.2.0, Python 2.3\n nt | win32 | Windows Me\n Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n Python 2.1.1 Idle 0.8\n nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n fail i.e. redefining environment variables may\n not work. FIXED: don't use cygwin echo!\n Comment: also `cmd /c echo` will not work\n but redefining environment variables do work.\n posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n nt | win32 | Windows XP, Python 2.3.3\n\nKnown bugs:\n- Tests, that send messages to stderr, fail when executed from MSYS prompt\n because the messages are lost at some point.\n\"\"\"\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\n\nfrom numpy.distutils.misc_util import is_sequence\n\n############################################################\n\nfrom log import _global_log as log\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.debug('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'], repr(l)\n l = splitcmdline('a')\n assert l==['a'], repr(l)\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'], repr(l)\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'], repr(l)\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'], repr(l)\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'], repr(l)\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'], repr(l)\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.debug('find_executable(%r)' % exe)\n orig_exe = exe\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n if os.name=='posix' and sys.version[:3]>'2.1':\n realpath = os.path.realpath\n else:\n realpath = lambda a:a\n if exe[0]=='\"':\n exe = exe[1:-1]\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if 0 and os.name == 'nt':\n new_paths = []\n cygwin_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n cygwin_paths.append(path)\n else:\n new_paths.append(path)\n paths = new_paths + cygwin_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if not os.path.islink(f_ext):\n # see comment below.\n f_ext = realpath(f_ext)\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if os.path.islink(exe):\n # Don't follow symbolic links. E.g. when using colorgcc then\n # gcc -> /usr/bin/colorgcc\n # g77 -> /usr/bin/colorgcc\n pass\n else:\n exe = realpath(exe)\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % orig_exe)\n return orig_exe\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.debug('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell,\n use_tee=use_tee,**env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n import tempfile\n log.debug('_exec_command_posix(...)')\n\n if is_sequence(command):\n command_str = ' '.join(list(command))\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n\n if stsfile is not None:\n f = open(stsfile,'r')\n status_text = f.read()\n status = int(status_text)\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n\n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n import tempfile\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n if status:\n raise RuntimeError(\"%r failed\" % (cmd,))\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n\n return status, text\n\ndef quote_arg(arg):\n if arg[0]!='\"' and ' ' in arg:\n return '\"%s\"' % arg\n return arg\n\ndef _exec_command( command, use_shell=None, use_tee = None, **env ):\n log.debug('_exec_command(...)')\n\n if use_shell is None:\n use_shell = os.name=='posix'\n if use_tee is None:\n use_tee = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if is_sequence(command):\n argv = [sh,'-c',' '.join(list(command))]\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if is_sequence(command):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n\n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C'] + argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n argv0 = argv[0]\n if not using_command:\n argv[0] = quote_arg(argv0)\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n #XXX: disabled for now as it does not work from cmd under win32.\n # Tests fail on msys\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n try:\n status = spawn_command(os.P_WAIT,argv0,argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n # Not sure how to handle the case where errmess\n # contains only warning messages and that should\n # not be treated as errors.\n #status = 998\n if text:\n text = text + '\\n'\n #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n text = text + errmess\n print errmess\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n if use_tee:\n print text\n\n return status, text\n\n\ndef test_nt(**kws):\n pythonexe = get_pythonexe()\n echo = find_executable('echo')\n using_cygwin_echo = echo != 'echo'\n if using_cygwin_echo:\n log.warn('Using cygwin echo in win32 environment is not supported')\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\',\\'\\')\"')\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\')\"',\n AAA='Tere')\n assert s==0 and o=='Tere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"',\n BBB='Hey')\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n elif 0:\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_execute_in(**kws):\n import tempfile\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore the following IOError:\\','\\\n 'open(%r,\\'r\\')\"' % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\ndef test_svn(**kws):\n s,o = exec_command(['svn','status'],**kws)\n assert s,(s,o)\n print 'svn ok'\n\ndef test_cl(**kws):\n if os.name=='nt':\n s,o = exec_command(['cl','/V'],**kws)\n assert s,(s,o)\n print 'cl ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n test_svn(use_tee=1)\n test_cl(use_tee=1)\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nexec_command\n\nImplements exec_command function that is (almost) equivalent to\ncommands.getstatusoutput function but on NT, DOS systems the\nreturned status is actually correct (though, the returned status\nvalues may be different by a factor). In addition, exec_command\ntakes keyword arguments for (re-)defining environment variables.\n\nProvides functions:\n exec_command --- execute command in a specified directory and\n in the modified environment.\n splitcmdline --- inverse of ' '.join(argv)\n find_executable --- locate a command using info from environment\n variable PATH. Equivalent to posix `which`\n command.\n\nAuthor: Pearu Peterson \nCreated: 11 January 2003\n\nRequires: Python 2.x\n\nSuccesfully tested on:\n os.name | sys.platform | comments\n --------+--------------+----------\n posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n PyCrust 0.9.3, Idle 1.0.2\n posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n posix | darwin | Darwin 7.2.0, Python 2.3\n nt | win32 | Windows Me\n Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n Python 2.1.1 Idle 0.8\n nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n fail i.e. redefining environment variables may\n not work. FIXED: don't use cygwin echo!\n Comment: also `cmd /c echo` will not work\n but redefining environment variables do work.\n posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n nt | win32 | Windows XP, Python 2.3.3\n\nKnown bugs:\n- Tests, that send messages to stderr, fail when executed from MSYS prompt\n because the messages are lost at some point.\n\"\"\"\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\nfrom numpy.distutils.misc_util import is_sequence\n\n############################################################\n\nfrom log import _global_log as log\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.debug('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'], repr(l)\n l = splitcmdline('a')\n assert l==['a'], repr(l)\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'], repr(l)\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'], repr(l)\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'], repr(l)\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'], repr(l)\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'], repr(l)\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.debug('find_executable(%r)' % exe)\n orig_exe = exe\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n if os.name=='posix' and sys.version[:3]>'2.1':\n realpath = os.path.realpath\n else:\n realpath = lambda a:a\n if exe[0]=='\"':\n exe = exe[1:-1]\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if 0 and os.name == 'nt':\n new_paths = []\n cygwin_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n cygwin_paths.append(path)\n else:\n new_paths.append(path)\n paths = new_paths + cygwin_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if not os.path.islink(f_ext):\n # see comment below.\n f_ext = realpath(f_ext)\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if os.path.islink(exe):\n # Don't follow symbolic links. E.g. when using colorgcc then\n # gcc -> /usr/bin/colorgcc\n # g77 -> /usr/bin/colorgcc\n pass\n else:\n exe = realpath(exe)\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % orig_exe)\n return orig_exe\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.debug('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell,\n use_tee=use_tee,**env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if is_sequence(command):\n command_str = ' '.join(list(command))\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n\n if stsfile is not None:\n f = open(stsfile,'r')\n status_text = f.read()\n status = int(status_text)\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n\n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n if status:\n raise RuntimeError(\"%r failed\" % (cmd,))\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n\n return status, text\n\ndef quote_arg(arg):\n if arg[0]!='\"' and ' ' in arg:\n return '\"%s\"' % arg\n return arg\n\ndef _exec_command( command, use_shell=None, use_tee = None, **env ):\n log.debug('_exec_command(...)')\n\n if use_shell is None:\n use_shell = os.name=='posix'\n if use_tee is None:\n use_tee = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if is_sequence(command):\n argv = [sh,'-c',' '.join(list(command))]\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if is_sequence(command):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n\n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C'] + argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n argv0 = argv[0]\n if not using_command:\n argv[0] = quote_arg(argv0)\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n #XXX: disabled for now as it does not work from cmd under win32.\n # Tests fail on msys\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n try:\n status = spawn_command(os.P_WAIT,argv0,argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n # Not sure how to handle the case where errmess\n # contains only warning messages and that should\n # not be treated as errors.\n #status = 998\n if text:\n text = text + '\\n'\n #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n text = text + errmess\n print errmess\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n if use_tee:\n print text\n\n return status, text\n\n\ndef test_nt(**kws):\n pythonexe = get_pythonexe()\n echo = find_executable('echo')\n using_cygwin_echo = echo != 'echo'\n if using_cygwin_echo:\n log.warn('Using cygwin echo in win32 environment is not supported')\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\',\\'\\')\"')\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\')\"',\n AAA='Tere')\n assert s==0 and o=='Tere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"',\n BBB='Hey')\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n elif 0:\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore the following IOError:\\','\\\n 'open(%r,\\'r\\')\"' % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\ndef test_svn(**kws):\n s,o = exec_command(['svn','status'],**kws)\n assert s,(s,o)\n print 'svn ok'\n\ndef test_cl(**kws):\n if os.name=='nt':\n s,o = exec_command(['cl','/V'],**kws)\n assert s,(s,o)\n print 'cl ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n test_svn(use_tee=1)\n test_cl(use_tee=1)\n", + "methods": [ + { + "name": "get_pythonexe", + "long_name": "get_pythonexe( )", + "filename": "exec_command.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [], + "start_line": 63, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "splitcmdline", + "long_name": "splitcmdline( line )", + "filename": "exec_command.py", + "nloc": 29, + "complexity": 25, + "token_count": 211, + "parameters": [ + "line" + ], + "start_line": 74, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "test_splitcmdline", + "long_name": "test_splitcmdline( )", + "filename": "exec_command.py", + "nloc": 15, + "complexity": 1, + "token_count": 141, + "parameters": [], + "start_line": 106, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "find_executable", + "long_name": "find_executable( exe , path = None )", + "filename": "exec_command.py", + "nloc": 48, + "complexity": 20, + "token_count": 372, + "parameters": [ + "exe", + "path" + ], + "start_line": 124, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_preserve_environment", + "long_name": "_preserve_environment( names )", + "filename": "exec_command.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "names" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_update_environment", + "long_name": "_update_environment( ** env )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "env" + ], + "start_line": 188, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "exec_command", + "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", + "filename": "exec_command.py", + "nloc": 46, + "complexity": 14, + "token_count": 335, + "parameters": [ + "command", + "execute_in", + "use_shell", + "use_tee", + "_with_python", + "env" + ], + "start_line": 193, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 42, + "complexity": 8, + "token_count": 243, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 267, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 34, + "complexity": 2, + "token_count": 238, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "quote_arg", + "long_name": "quote_arg( arg )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 23, + "parameters": [ + "arg" + ], + "start_line": 362, + "end_line": 365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_exec_command", + "long_name": "_exec_command( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 83, + "complexity": 20, + "token_count": 564, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 367, + "end_line": 476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 110, + "top_nesting_level": 0 + }, + { + "name": "test_nt", + "long_name": "test_nt( ** kws )", + "filename": "exec_command.py", + "nloc": 57, + "complexity": 22, + "token_count": 507, + "parameters": [ + "kws" + ], + "start_line": 479, + "end_line": 553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "test_posix", + "long_name": "test_posix( ** kws )", + "filename": "exec_command.py", + "nloc": 31, + "complexity": 15, + "token_count": 372, + "parameters": [ + "kws" + ], + "start_line": 555, + "end_line": 601, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 17, + "complexity": 3, + "token_count": 133, + "parameters": [ + "kws" + ], + "start_line": 603, + "end_line": 620, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "test_svn", + "long_name": "test_svn( ** kws )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "kws" + ], + "start_line": 622, + "end_line": 625, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "test_cl", + "long_name": "test_cl( ** kws )", + "filename": "exec_command.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "kws" + ], + "start_line": 627, + "end_line": 631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_pythonexe", + "long_name": "get_pythonexe( )", + "filename": "exec_command.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [], + "start_line": 64, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "splitcmdline", + "long_name": "splitcmdline( line )", + "filename": "exec_command.py", + "nloc": 29, + "complexity": 25, + "token_count": 211, + "parameters": [ + "line" + ], + "start_line": 75, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "test_splitcmdline", + "long_name": "test_splitcmdline( )", + "filename": "exec_command.py", + "nloc": 15, + "complexity": 1, + "token_count": 141, + "parameters": [], + "start_line": 107, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "find_executable", + "long_name": "find_executable( exe , path = None )", + "filename": "exec_command.py", + "nloc": 48, + "complexity": 20, + "token_count": 372, + "parameters": [ + "exe", + "path" + ], + "start_line": 125, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_preserve_environment", + "long_name": "_preserve_environment( names )", + "filename": "exec_command.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "names" + ], + "start_line": 182, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_update_environment", + "long_name": "_update_environment( ** env )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "env" + ], + "start_line": 189, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "exec_command", + "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", + "filename": "exec_command.py", + "nloc": 46, + "complexity": 14, + "token_count": 335, + "parameters": [ + "command", + "execute_in", + "use_shell", + "use_tee", + "_with_python", + "env" + ], + "start_line": 194, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 41, + "complexity": 8, + "token_count": 241, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 268, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 33, + "complexity": 2, + "token_count": 236, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "quote_arg", + "long_name": "quote_arg( arg )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 23, + "parameters": [ + "arg" + ], + "start_line": 361, + "end_line": 364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_exec_command", + "long_name": "_exec_command( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 83, + "complexity": 20, + "token_count": 564, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 366, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 110, + "top_nesting_level": 0 + }, + { + "name": "test_nt", + "long_name": "test_nt( ** kws )", + "filename": "exec_command.py", + "nloc": 57, + "complexity": 22, + "token_count": 507, + "parameters": [ + "kws" + ], + "start_line": 478, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "test_posix", + "long_name": "test_posix( ** kws )", + "filename": "exec_command.py", + "nloc": 31, + "complexity": 15, + "token_count": 372, + "parameters": [ + "kws" + ], + "start_line": 554, + "end_line": 600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 16, + "complexity": 3, + "token_count": 131, + "parameters": [ + "kws" + ], + "start_line": 602, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "test_svn", + "long_name": "test_svn( ** kws )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "kws" + ], + "start_line": 620, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "test_cl", + "long_name": "test_cl( ** kws )", + "filename": "exec_command.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "kws" + ], + "start_line": 625, + "end_line": 629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 42, + "complexity": 8, + "token_count": 243, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 267, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 17, + "complexity": 3, + "token_count": 133, + "parameters": [ + "kws" + ], + "start_line": 603, + "end_line": 620, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 34, + "complexity": 2, + "token_count": 238, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + } + ], + "nloc": 499, + "complexity": 143, + "token_count": 3478, + "diff_parsed": { + "added": [ + " import tempfile", + " import tempfile", + " import tempfile" + ], + "deleted": [ + "import tempfile" + ] + } + }, + { + "old_path": "numpy/f2py/__init__.py", + "new_path": "numpy/f2py/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -3,7 +3,6 @@\n __all__ = ['run_main','compile','f2py_testing']\n \n import os\n-import tempfile\n import sys\n import commands\n \n@@ -24,6 +23,7 @@ def compile(source,\n Read the source of this function for more information.\n '''\n from numpy.distutils.exec_command import exec_command\n+ import tempfile\n if source_fn is None:\n fname = os.path.join(tempfile.mktemp()+'.f')\n else:\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\n__all__ = ['run_main','compile','f2py_testing']\n\nimport os\nimport sys\nimport commands\n\nfrom info import __doc__\n\nimport f2py2e\nrun_main = f2py2e.run_main\nmain = f2py2e.main\nimport f2py_testing\n\ndef compile(source,\n modulename = 'untitled',\n extra_args = '',\n verbose = 1,\n source_fn = None\n ):\n ''' Build extension module from processing source with f2py.\n Read the source of this function for more information.\n '''\n from numpy.distutils.exec_command import exec_command\n import tempfile\n if source_fn is None:\n fname = os.path.join(tempfile.mktemp()+'.f')\n else:\n fname = source_fn\n\n f = open(fname,'w')\n f.write(source)\n f.close()\n\n args = ' -c -m %s %s %s'%(modulename,fname,extra_args)\n c = '%s -c \"import numpy.f2py as f2py2e;f2py2e.main()\" %s' %(sys.executable,args)\n s,o = exec_command(c)\n if source_fn is None:\n try: os.remove(fname)\n except OSError: pass\n return s\n", + "source_code_before": "#!/usr/bin/env python\n\n__all__ = ['run_main','compile','f2py_testing']\n\nimport os\nimport tempfile\nimport sys\nimport commands\n\nfrom info import __doc__\n\nimport f2py2e\nrun_main = f2py2e.run_main\nmain = f2py2e.main\nimport f2py_testing\n\ndef compile(source,\n modulename = 'untitled',\n extra_args = '',\n verbose = 1,\n source_fn = None\n ):\n ''' Build extension module from processing source with f2py.\n Read the source of this function for more information.\n '''\n from numpy.distutils.exec_command import exec_command\n if source_fn is None:\n fname = os.path.join(tempfile.mktemp()+'.f')\n else:\n fname = source_fn\n\n f = open(fname,'w')\n f.write(source)\n f.close()\n\n args = ' -c -m %s %s %s'%(modulename,fname,extra_args)\n c = '%s -c \"import numpy.f2py as f2py2e;f2py2e.main()\" %s' %(sys.executable,args)\n s,o = exec_command(c)\n if source_fn is None:\n try: os.remove(fname)\n except OSError: pass\n return s\n", + "methods": [ + { + "name": "compile", + "long_name": "compile( source , modulename = 'untitled' , extra_args = '' , verbose = 1 , source_fn = None )", + "filename": "__init__.py", + "nloc": 22, + "complexity": 4, + "token_count": 126, + "parameters": [ + "source", + "modulename", + "extra_args", + "verbose", + "source_fn" + ], + "start_line": 16, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "compile", + "long_name": "compile( source , modulename = 'untitled' , extra_args = '' , verbose = 1 , source_fn = None )", + "filename": "__init__.py", + "nloc": 21, + "complexity": 4, + "token_count": 124, + "parameters": [ + "source", + "modulename", + "extra_args", + "verbose", + "source_fn" + ], + "start_line": 17, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "compile", + "long_name": "compile( source , modulename = 'untitled' , extra_args = '' , verbose = 1 , source_fn = None )", + "filename": "__init__.py", + "nloc": 22, + "complexity": 4, + "token_count": 126, + "parameters": [ + "source", + "modulename", + "extra_args", + "verbose", + "source_fn" + ], + "start_line": 16, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + } + ], + "nloc": 31, + "complexity": 4, + "token_count": 160, + "diff_parsed": { + "added": [ + " import tempfile" + ], + "deleted": [ + "import tempfile" + ] + } + } + ] + }, + { + "hash": "7c0eef63f9429ead37f628984de22177b08a5597", + "msg": "Workaround strage tempfile problem.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-03T14:23:19+00:00", + "author_timezone": 0, + "committer_date": "2006-04-03T14:23:19+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "6cc9da7aea03502abbccf7454f73e0fc308358f5" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 3, + "insertions": 1, + "lines": 4, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 0.3333333333333333, + "dmm_unit_interfacing": 0.6666666666666666, + "modified_files": [ + { + "old_path": "numpy/distutils/exec_command.py", + "new_path": "numpy/distutils/exec_command.py", + "filename": "exec_command.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -51,6 +51,7 @@\n import os\n import re\n import sys\n+import tempfile\n \n from numpy.distutils.misc_util import is_sequence\n \n@@ -268,7 +269,6 @@ def _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n- import tempfile\n log.debug('_exec_command_posix(...)')\n \n if is_sequence(command):\n@@ -320,7 +320,6 @@ def _exec_command_posix( command,\n \n def _exec_command_python(command,\n exec_command_dir='', **env):\n- import tempfile\n log.debug('_exec_command_python(...)')\n \n python_exe = get_pythonexe()\n@@ -601,7 +600,6 @@ def test_posix(**kws):\n print 'ok'\n \n def test_execute_in(**kws):\n- import tempfile\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n", + "added_lines": 1, + "deleted_lines": 3, + "source_code": "#!/usr/bin/env python\n\"\"\"\nexec_command\n\nImplements exec_command function that is (almost) equivalent to\ncommands.getstatusoutput function but on NT, DOS systems the\nreturned status is actually correct (though, the returned status\nvalues may be different by a factor). In addition, exec_command\ntakes keyword arguments for (re-)defining environment variables.\n\nProvides functions:\n exec_command --- execute command in a specified directory and\n in the modified environment.\n splitcmdline --- inverse of ' '.join(argv)\n find_executable --- locate a command using info from environment\n variable PATH. Equivalent to posix `which`\n command.\n\nAuthor: Pearu Peterson \nCreated: 11 January 2003\n\nRequires: Python 2.x\n\nSuccesfully tested on:\n os.name | sys.platform | comments\n --------+--------------+----------\n posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n PyCrust 0.9.3, Idle 1.0.2\n posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n posix | darwin | Darwin 7.2.0, Python 2.3\n nt | win32 | Windows Me\n Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n Python 2.1.1 Idle 0.8\n nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n fail i.e. redefining environment variables may\n not work. FIXED: don't use cygwin echo!\n Comment: also `cmd /c echo` will not work\n but redefining environment variables do work.\n posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n nt | win32 | Windows XP, Python 2.3.3\n\nKnown bugs:\n- Tests, that send messages to stderr, fail when executed from MSYS prompt\n because the messages are lost at some point.\n\"\"\"\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\nimport tempfile\n\nfrom numpy.distutils.misc_util import is_sequence\n\n############################################################\n\nfrom log import _global_log as log\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.debug('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'], repr(l)\n l = splitcmdline('a')\n assert l==['a'], repr(l)\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'], repr(l)\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'], repr(l)\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'], repr(l)\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'], repr(l)\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'], repr(l)\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.debug('find_executable(%r)' % exe)\n orig_exe = exe\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n if os.name=='posix' and sys.version[:3]>'2.1':\n realpath = os.path.realpath\n else:\n realpath = lambda a:a\n if exe[0]=='\"':\n exe = exe[1:-1]\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if 0 and os.name == 'nt':\n new_paths = []\n cygwin_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n cygwin_paths.append(path)\n else:\n new_paths.append(path)\n paths = new_paths + cygwin_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if not os.path.islink(f_ext):\n # see comment below.\n f_ext = realpath(f_ext)\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if os.path.islink(exe):\n # Don't follow symbolic links. E.g. when using colorgcc then\n # gcc -> /usr/bin/colorgcc\n # g77 -> /usr/bin/colorgcc\n pass\n else:\n exe = realpath(exe)\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % orig_exe)\n return orig_exe\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.debug('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell,\n use_tee=use_tee,**env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n log.debug('_exec_command_posix(...)')\n\n if is_sequence(command):\n command_str = ' '.join(list(command))\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n\n if stsfile is not None:\n f = open(stsfile,'r')\n status_text = f.read()\n status = int(status_text)\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n\n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n if status:\n raise RuntimeError(\"%r failed\" % (cmd,))\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n\n return status, text\n\ndef quote_arg(arg):\n if arg[0]!='\"' and ' ' in arg:\n return '\"%s\"' % arg\n return arg\n\ndef _exec_command( command, use_shell=None, use_tee = None, **env ):\n log.debug('_exec_command(...)')\n\n if use_shell is None:\n use_shell = os.name=='posix'\n if use_tee is None:\n use_tee = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if is_sequence(command):\n argv = [sh,'-c',' '.join(list(command))]\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if is_sequence(command):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n\n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C'] + argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n argv0 = argv[0]\n if not using_command:\n argv[0] = quote_arg(argv0)\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n #XXX: disabled for now as it does not work from cmd under win32.\n # Tests fail on msys\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n try:\n status = spawn_command(os.P_WAIT,argv0,argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n # Not sure how to handle the case where errmess\n # contains only warning messages and that should\n # not be treated as errors.\n #status = 998\n if text:\n text = text + '\\n'\n #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n text = text + errmess\n print errmess\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n if use_tee:\n print text\n\n return status, text\n\n\ndef test_nt(**kws):\n pythonexe = get_pythonexe()\n echo = find_executable('echo')\n using_cygwin_echo = echo != 'echo'\n if using_cygwin_echo:\n log.warn('Using cygwin echo in win32 environment is not supported')\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\',\\'\\')\"')\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\')\"',\n AAA='Tere')\n assert s==0 and o=='Tere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"',\n BBB='Hey')\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n elif 0:\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_execute_in(**kws):\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore the following IOError:\\','\\\n 'open(%r,\\'r\\')\"' % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\ndef test_svn(**kws):\n s,o = exec_command(['svn','status'],**kws)\n assert s,(s,o)\n print 'svn ok'\n\ndef test_cl(**kws):\n if os.name=='nt':\n s,o = exec_command(['cl','/V'],**kws)\n assert s,(s,o)\n print 'cl ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n test_svn(use_tee=1)\n test_cl(use_tee=1)\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nexec_command\n\nImplements exec_command function that is (almost) equivalent to\ncommands.getstatusoutput function but on NT, DOS systems the\nreturned status is actually correct (though, the returned status\nvalues may be different by a factor). In addition, exec_command\ntakes keyword arguments for (re-)defining environment variables.\n\nProvides functions:\n exec_command --- execute command in a specified directory and\n in the modified environment.\n splitcmdline --- inverse of ' '.join(argv)\n find_executable --- locate a command using info from environment\n variable PATH. Equivalent to posix `which`\n command.\n\nAuthor: Pearu Peterson \nCreated: 11 January 2003\n\nRequires: Python 2.x\n\nSuccesfully tested on:\n os.name | sys.platform | comments\n --------+--------------+----------\n posix | linux2 | Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3\n PyCrust 0.9.3, Idle 1.0.2\n posix | linux2 | Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2\n posix | sunos5 | SunOS 5.9, Python 2.2, 2.3.2\n posix | darwin | Darwin 7.2.0, Python 2.3\n nt | win32 | Windows Me\n Python 2.3(EE), Idle 1.0, PyCrust 0.7.2\n Python 2.1.1 Idle 0.8\n nt | win32 | Windows 98, Python 2.1.1. Idle 0.8\n nt | win32 | Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests\n fail i.e. redefining environment variables may\n not work. FIXED: don't use cygwin echo!\n Comment: also `cmd /c echo` will not work\n but redefining environment variables do work.\n posix | cygwin | Cygwin 98-4.10, Python 2.3.3(cygming special)\n nt | win32 | Windows XP, Python 2.3.3\n\nKnown bugs:\n- Tests, that send messages to stderr, fail when executed from MSYS prompt\n because the messages are lost at some point.\n\"\"\"\n\n__all__ = ['exec_command','find_executable']\n\nimport os\nimport re\nimport sys\n\nfrom numpy.distutils.misc_util import is_sequence\n\n############################################################\n\nfrom log import _global_log as log\n\n############################################################\n\ndef get_pythonexe():\n pythonexe = sys.executable\n if os.name in ['nt','dos']:\n fdir,fn = os.path.split(pythonexe)\n fn = fn.upper().replace('PYTHONW','PYTHON')\n pythonexe = os.path.join(fdir,fn)\n assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)\n return pythonexe\n\n############################################################\n\ndef splitcmdline(line):\n \"\"\" Inverse of ' '.join(sys.argv).\n \"\"\"\n log.debug('splitcmdline(%r)' % (line))\n lst = []\n flag = 0\n s,pc,cc = '','',''\n for nc in line+' ':\n if flag==0:\n flag = (pc != '\\\\' and \\\n ((cc=='\"' and 1) or (cc==\"'\" and 2) or \\\n (cc==' ' and pc!=' ' and -2))) or flag\n elif flag==1:\n flag = (cc=='\"' and pc!='\\\\' and nc==' ' and -1) or flag\n elif flag==2:\n flag = (cc==\"'\" and pc!='\\\\' and nc==' ' and -1) or flag\n if flag!=-2:\n s += cc\n if flag<0:\n flag = 0\n s = s.strip()\n if s:\n lst.append(s)\n s = ''\n pc,cc = cc,nc\n else:\n s = s.strip()\n if s:\n lst.append(s)\n log.debug('splitcmdline -> %r' % (lst))\n return lst\n\ndef test_splitcmdline():\n l = splitcmdline('a b cc')\n assert l==['a','b','cc'], repr(l)\n l = splitcmdline('a')\n assert l==['a'], repr(l)\n l = splitcmdline('a \" b cc\"')\n assert l==['a','\" b cc\"'], repr(l)\n l = splitcmdline('\"a bcc\" -h')\n assert l==['\"a bcc\"','-h'], repr(l)\n l = splitcmdline(r'\"\\\"a \\\" bcc\" -h')\n assert l==[r'\"\\\"a \\\" bcc\"','-h'], repr(l)\n l = splitcmdline(\" 'a bcc' -h\")\n assert l==[\"'a bcc'\",'-h'], repr(l)\n l = splitcmdline(r\"'\\'a \\' bcc' -h\")\n assert l==[r\"'\\'a \\' bcc'\",'-h'], repr(l)\n\n############################################################\n\ndef find_executable(exe, path=None):\n \"\"\" Return full path of a executable.\n \"\"\"\n log.debug('find_executable(%r)' % exe)\n orig_exe = exe\n if path is None:\n path = os.environ.get('PATH',os.defpath)\n if os.name=='posix' and sys.version[:3]>'2.1':\n realpath = os.path.realpath\n else:\n realpath = lambda a:a\n if exe[0]=='\"':\n exe = exe[1:-1]\n suffices = ['']\n if os.name in ['nt','dos','os2']:\n fn,ext = os.path.splitext(exe)\n extra_suffices = ['.exe','.com','.bat']\n if ext.lower() not in extra_suffices:\n suffices = extra_suffices\n if os.path.isabs(exe):\n paths = ['']\n else:\n paths = map(os.path.abspath, path.split(os.pathsep))\n if 0 and os.name == 'nt':\n new_paths = []\n cygwin_paths = []\n for path in paths:\n d,p = os.path.splitdrive(path)\n if p.lower().find('cygwin') >= 0:\n cygwin_paths.append(path)\n else:\n new_paths.append(path)\n paths = new_paths + cygwin_paths\n for path in paths:\n fn = os.path.join(path,exe)\n for s in suffices:\n f_ext = fn+s\n if not os.path.islink(f_ext):\n # see comment below.\n f_ext = realpath(f_ext)\n if os.path.isfile(f_ext) and os.access(f_ext,os.X_OK):\n log.debug('Found executable %s' % f_ext)\n return f_ext\n if os.path.islink(exe):\n # Don't follow symbolic links. E.g. when using colorgcc then\n # gcc -> /usr/bin/colorgcc\n # g77 -> /usr/bin/colorgcc\n pass\n else:\n exe = realpath(exe)\n if not os.path.isfile(exe) or os.access(exe,os.X_OK):\n log.warn('Could not locate executable %s' % orig_exe)\n return orig_exe\n return exe\n\n############################################################\n\ndef _preserve_environment( names ):\n log.debug('_preserve_environment(%r)' % (names))\n env = {}\n for name in names:\n env[name] = os.environ.get(name)\n return env\n\ndef _update_environment( **env ):\n log.debug('_update_environment(...)')\n for name,value in env.items():\n os.environ[name] = value or ''\n\ndef exec_command( command,\n execute_in='', use_shell=None, use_tee = None,\n _with_python = 1,\n **env ):\n \"\"\" Return (status,output) of executed command.\n\n command is a concatenated string of executable and arguments.\n The output contains both stdout and stderr messages.\n The following special keyword arguments can be used:\n use_shell - execute `sh -c command`\n use_tee - pipe the output of command through tee\n execute_in - before command `cd execute_in` and after `cd -`.\n\n On NT, DOS systems the returned status is correct for external commands.\n Wild cards will not work for non-posix systems or when use_shell=0.\n \"\"\"\n log.debug('exec_command(%r,%s)' % (command,\\\n ','.join(['%s=%r'%kv for kv in env.items()])))\n\n if use_tee is None:\n use_tee = os.name=='posix'\n if use_shell is None:\n use_shell = os.name=='posix'\n execute_in = os.path.abspath(execute_in)\n oldcwd = os.path.abspath(os.getcwd())\n\n if __name__[-12:] == 'exec_command':\n exec_dir = os.path.dirname(os.path.abspath(__file__))\n elif os.path.isfile('exec_command.py'):\n exec_dir = os.path.abspath('.')\n else:\n exec_dir = os.path.abspath(sys.argv[0])\n if os.path.isfile(exec_dir):\n exec_dir = os.path.dirname(exec_dir)\n\n if oldcwd!=execute_in:\n os.chdir(execute_in)\n log.debug('New cwd: %s' % execute_in)\n else:\n log.debug('Retaining cwd: %s' % oldcwd)\n\n oldenv = _preserve_environment( env.keys() )\n _update_environment( **env )\n\n try:\n # _exec_command is robust but slow, it relies on\n # usable sys.std*.fileno() descriptors. If they\n # are bad (like in win32 Idle, PyCrust environments)\n # then _exec_command_python (even slower)\n # will be used as a last resort.\n #\n # _exec_command_posix uses os.system and is faster\n # but not on all platforms os.system will return\n # a correct status.\n if _with_python and (0 or sys.__stdout__.fileno()==-1):\n st = _exec_command_python(command,\n exec_command_dir = exec_dir,\n **env)\n elif os.name=='posix':\n st = _exec_command_posix(command,\n use_shell=use_shell,\n use_tee=use_tee,\n **env)\n else:\n st = _exec_command(command, use_shell=use_shell,\n use_tee=use_tee,**env)\n finally:\n if oldcwd!=execute_in:\n os.chdir(oldcwd)\n log.debug('Restored cwd to %s' % oldcwd)\n _update_environment(**oldenv)\n\n return st\n\ndef _exec_command_posix( command,\n use_shell = None,\n use_tee = None,\n **env ):\n import tempfile\n log.debug('_exec_command_posix(...)')\n\n if is_sequence(command):\n command_str = ' '.join(list(command))\n else:\n command_str = command\n\n tmpfile = tempfile.mktemp()\n stsfile = None\n if use_tee:\n stsfile = tempfile.mktemp()\n filter = ''\n if use_tee == 2:\n filter = r'| tr -cd \"\\n\" | tr \"\\n\" \".\"; echo'\n command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\\\n % (command_str,stsfile,tmpfile,filter)\n else:\n stsfile = tempfile.mktemp()\n command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\\\n % (command_str,stsfile,tmpfile)\n #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)\n\n log.debug('Running os.system(%r)' % (command_posix))\n status = os.system(command_posix)\n\n if use_tee:\n if status:\n # if command_tee fails then fall back to robust exec_command\n log.warn('_exec_command_posix failed (status=%s)' % status)\n return _exec_command(command, use_shell=use_shell, **env)\n\n if stsfile is not None:\n f = open(stsfile,'r')\n status_text = f.read()\n status = int(status_text)\n f.close()\n os.remove(stsfile)\n\n f = open(tmpfile,'r')\n text = f.read()\n f.close()\n os.remove(tmpfile)\n\n if text[-1:]=='\\n':\n text = text[:-1]\n\n return status, text\n\n\ndef _exec_command_python(command,\n exec_command_dir='', **env):\n import tempfile\n log.debug('_exec_command_python(...)')\n\n python_exe = get_pythonexe()\n cmdfile = tempfile.mktemp()\n stsfile = tempfile.mktemp()\n outfile = tempfile.mktemp()\n\n f = open(cmdfile,'w')\n f.write('import os\\n')\n f.write('import sys\\n')\n f.write('sys.path.insert(0,%r)\\n' % (exec_command_dir))\n f.write('from exec_command import exec_command\\n')\n f.write('del sys.path[0]\\n')\n f.write('cmd = %r\\n' % command)\n f.write('os.environ = %r\\n' % (os.environ))\n f.write('s,o = exec_command(cmd, _with_python=0, **%r)\\n' % (env))\n f.write('f=open(%r,\"w\")\\nf.write(str(s))\\nf.close()\\n' % (stsfile))\n f.write('f=open(%r,\"w\")\\nf.write(o)\\nf.close()\\n' % (outfile))\n f.close()\n\n cmd = '%s %s' % (python_exe, cmdfile)\n status = os.system(cmd)\n if status:\n raise RuntimeError(\"%r failed\" % (cmd,))\n os.remove(cmdfile)\n\n f = open(stsfile,'r')\n status = int(f.read())\n f.close()\n os.remove(stsfile)\n\n f = open(outfile,'r')\n text = f.read()\n f.close()\n os.remove(outfile)\n\n return status, text\n\ndef quote_arg(arg):\n if arg[0]!='\"' and ' ' in arg:\n return '\"%s\"' % arg\n return arg\n\ndef _exec_command( command, use_shell=None, use_tee = None, **env ):\n log.debug('_exec_command(...)')\n\n if use_shell is None:\n use_shell = os.name=='posix'\n if use_tee is None:\n use_tee = os.name=='posix'\n\n using_command = 0\n if use_shell:\n # We use shell (unless use_shell==0) so that wildcards can be\n # used.\n sh = os.environ.get('SHELL','/bin/sh')\n if is_sequence(command):\n argv = [sh,'-c',' '.join(list(command))]\n else:\n argv = [sh,'-c',command]\n else:\n # On NT, DOS we avoid using command.com as it's exit status is\n # not related to the exit status of a command.\n if is_sequence(command):\n argv = command[:]\n else:\n argv = splitcmdline(command)\n\n if hasattr(os,'spawnvpe'):\n spawn_command = os.spawnvpe\n else:\n spawn_command = os.spawnve\n argv[0] = find_executable(argv[0])\n if not os.path.isfile(argv[0]):\n log.warn('Executable %s does not exist' % (argv[0]))\n if os.name in ['nt','dos']:\n # argv[0] might be internal command\n argv = [os.environ['COMSPEC'],'/C'] + argv\n using_command = 1\n\n # sys.__std*__ is used instead of sys.std* because environments\n # like IDLE, PyCrust, etc overwrite sys.std* commands.\n so_fileno = sys.__stdout__.fileno()\n se_fileno = sys.__stderr__.fileno()\n so_flush = sys.__stdout__.flush\n se_flush = sys.__stderr__.flush\n so_dup = os.dup(so_fileno)\n se_dup = os.dup(se_fileno)\n\n outfile = tempfile.mktemp()\n fout = open(outfile,'w')\n if using_command:\n errfile = tempfile.mktemp()\n ferr = open(errfile,'w')\n\n log.debug('Running %s(%s,%r,%r,os.environ)' \\\n % (spawn_command.__name__,os.P_WAIT,argv[0],argv))\n\n argv0 = argv[0]\n if not using_command:\n argv[0] = quote_arg(argv0)\n\n so_flush()\n se_flush()\n os.dup2(fout.fileno(),so_fileno)\n if using_command:\n #XXX: disabled for now as it does not work from cmd under win32.\n # Tests fail on msys\n os.dup2(ferr.fileno(),se_fileno)\n else:\n os.dup2(fout.fileno(),se_fileno)\n try:\n status = spawn_command(os.P_WAIT,argv0,argv,os.environ)\n except OSError,errmess:\n status = 999\n sys.stderr.write('%s: %s'%(errmess,argv[0]))\n\n so_flush()\n se_flush()\n os.dup2(so_dup,so_fileno)\n os.dup2(se_dup,se_fileno)\n\n fout.close()\n fout = open(outfile,'r')\n text = fout.read()\n fout.close()\n os.remove(outfile)\n\n if using_command:\n ferr.close()\n ferr = open(errfile,'r')\n errmess = ferr.read()\n ferr.close()\n os.remove(errfile)\n if errmess and not status:\n # Not sure how to handle the case where errmess\n # contains only warning messages and that should\n # not be treated as errors.\n #status = 998\n if text:\n text = text + '\\n'\n #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)\n text = text + errmess\n print errmess\n if text[-1:]=='\\n':\n text = text[:-1]\n if status is None:\n status = 0\n\n if use_tee:\n print text\n\n return status, text\n\n\ndef test_nt(**kws):\n pythonexe = get_pythonexe()\n echo = find_executable('echo')\n using_cygwin_echo = echo != 'echo'\n if using_cygwin_echo:\n log.warn('Using cygwin echo in win32 environment is not supported')\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\',\\'\\')\"')\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'AAA\\')\"',\n AAA='Tere')\n assert s==0 and o=='Tere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"',\n BBB='Hey')\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command(pythonexe\\\n +' -c \"import os;print os.environ.get(\\'BBB\\',\\'\\')\"')\n assert s==0 and o=='Hi',(s,o)\n elif 0:\n s,o=exec_command('echo Hello')\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo a%AAA%')\n assert s==0 and o=='a',(s,o)\n\n s,o=exec_command('echo a%AAA%',AAA='Tere')\n assert s==0 and o=='aTere',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('echo a%BBB%',BBB='Hey')\n assert s==0 and o=='aHey', (s,o)\n s,o=exec_command('echo a%BBB%')\n assert s==0 and o=='aHi',(s,o)\n\n s,o=exec_command('this_is_not_a_command')\n assert s and o!='',(s,o)\n\n s,o=exec_command('type not_existing_file')\n assert s and o!='',(s,o)\n\n s,o=exec_command('echo path=%path%')\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(sys.platform)\"' \\\n % pythonexe)\n assert s==0 and o=='win32',(s,o)\n\n s,o=exec_command('%s -c \"raise \\'Ignore me.\\'\"' % pythonexe)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"'\\\n % pythonexe)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('%s -c \"import sys;sys.exit(15)\"' % pythonexe)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('%s -c \"print \\'Heipa\\'\"' % pythonexe)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_posix(**kws):\n s,o=exec_command(\"echo Hello\",**kws)\n assert s==0 and o=='Hello',(s,o)\n\n s,o=exec_command('echo $AAA',**kws)\n assert s==0 and o=='',(s,o)\n\n s,o=exec_command('echo \"$AAA\"',AAA='Tere',**kws)\n assert s==0 and o=='Tere',(s,o)\n\n\n s,o=exec_command('echo \"$AAA\"',**kws)\n assert s==0 and o=='',(s,o)\n\n os.environ['BBB'] = 'Hi'\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',BBB='Hey',**kws)\n assert s==0 and o=='Hey',(s,o)\n\n s,o=exec_command('echo \"$BBB\"',**kws)\n assert s==0 and o=='Hi',(s,o)\n\n\n s,o=exec_command('this_is_not_a_command',**kws)\n assert s!=0 and o!='',(s,o)\n\n s,o=exec_command('echo path=$PATH',**kws)\n assert s==0 and o!='',(s,o)\n\n s,o=exec_command('python -c \"import sys,os;sys.stderr.write(os.name)\"',**kws)\n assert s==0 and o=='posix',(s,o)\n\n s,o=exec_command('python -c \"raise \\'Ignore me.\\'\"',**kws)\n assert s==1 and o,(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.stderr.write(\\'0\\');sys.stderr.write(\\'1\\');sys.stderr.write(\\'2\\')\"',**kws)\n assert s==0 and o=='012',(s,o)\n\n s,o=exec_command('python -c \"import sys;sys.exit(15)\"',**kws)\n assert s==15 and o=='',(s,o)\n\n s,o=exec_command('python -c \"print \\'Heipa\\'\"',**kws)\n assert s==0 and o=='Heipa',(s,o)\n\n print 'ok'\n\ndef test_execute_in(**kws):\n import tempfile\n pythonexe = get_pythonexe()\n tmpfile = tempfile.mktemp()\n fn = os.path.basename(tmpfile)\n tmpdir = os.path.dirname(tmpfile)\n f = open(tmpfile,'w')\n f.write('Hello')\n f.close()\n\n s,o = exec_command('%s -c \"print \\'Ignore the following IOError:\\','\\\n 'open(%r,\\'r\\')\"' % (pythonexe,fn),**kws)\n assert s and o!='',(s,o)\n s,o = exec_command('%s -c \"print open(%r,\\'r\\').read()\"' % (pythonexe,fn),\n execute_in = tmpdir,**kws)\n assert s==0 and o=='Hello',(s,o)\n os.remove(tmpfile)\n print 'ok'\n\ndef test_svn(**kws):\n s,o = exec_command(['svn','status'],**kws)\n assert s,(s,o)\n print 'svn ok'\n\ndef test_cl(**kws):\n if os.name=='nt':\n s,o = exec_command(['cl','/V'],**kws)\n assert s,(s,o)\n print 'cl ok'\n\nif os.name=='posix':\n test = test_posix\nelif os.name in ['nt','dos']:\n test = test_nt\nelse:\n raise NotImplementedError,'exec_command tests for '+os.name\n\n############################################################\n\nif __name__ == \"__main__\":\n\n test_splitcmdline()\n test(use_tee=0)\n test(use_tee=1)\n test_execute_in(use_tee=0)\n test_execute_in(use_tee=1)\n test_svn(use_tee=1)\n test_cl(use_tee=1)\n", + "methods": [ + { + "name": "get_pythonexe", + "long_name": "get_pythonexe( )", + "filename": "exec_command.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [], + "start_line": 64, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "splitcmdline", + "long_name": "splitcmdline( line )", + "filename": "exec_command.py", + "nloc": 29, + "complexity": 25, + "token_count": 211, + "parameters": [ + "line" + ], + "start_line": 75, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "test_splitcmdline", + "long_name": "test_splitcmdline( )", + "filename": "exec_command.py", + "nloc": 15, + "complexity": 1, + "token_count": 141, + "parameters": [], + "start_line": 107, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "find_executable", + "long_name": "find_executable( exe , path = None )", + "filename": "exec_command.py", + "nloc": 48, + "complexity": 20, + "token_count": 372, + "parameters": [ + "exe", + "path" + ], + "start_line": 125, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_preserve_environment", + "long_name": "_preserve_environment( names )", + "filename": "exec_command.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "names" + ], + "start_line": 182, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_update_environment", + "long_name": "_update_environment( ** env )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "env" + ], + "start_line": 189, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "exec_command", + "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", + "filename": "exec_command.py", + "nloc": 46, + "complexity": 14, + "token_count": 335, + "parameters": [ + "command", + "execute_in", + "use_shell", + "use_tee", + "_with_python", + "env" + ], + "start_line": 194, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 41, + "complexity": 8, + "token_count": 241, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 268, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 33, + "complexity": 2, + "token_count": 236, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "quote_arg", + "long_name": "quote_arg( arg )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 23, + "parameters": [ + "arg" + ], + "start_line": 361, + "end_line": 364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_exec_command", + "long_name": "_exec_command( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 83, + "complexity": 20, + "token_count": 564, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 366, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 110, + "top_nesting_level": 0 + }, + { + "name": "test_nt", + "long_name": "test_nt( ** kws )", + "filename": "exec_command.py", + "nloc": 57, + "complexity": 22, + "token_count": 507, + "parameters": [ + "kws" + ], + "start_line": 478, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "test_posix", + "long_name": "test_posix( ** kws )", + "filename": "exec_command.py", + "nloc": 31, + "complexity": 15, + "token_count": 372, + "parameters": [ + "kws" + ], + "start_line": 554, + "end_line": 600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 16, + "complexity": 3, + "token_count": 131, + "parameters": [ + "kws" + ], + "start_line": 602, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "test_svn", + "long_name": "test_svn( ** kws )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "kws" + ], + "start_line": 620, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "test_cl", + "long_name": "test_cl( ** kws )", + "filename": "exec_command.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "kws" + ], + "start_line": 625, + "end_line": 629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_pythonexe", + "long_name": "get_pythonexe( )", + "filename": "exec_command.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [], + "start_line": 63, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "splitcmdline", + "long_name": "splitcmdline( line )", + "filename": "exec_command.py", + "nloc": 29, + "complexity": 25, + "token_count": 211, + "parameters": [ + "line" + ], + "start_line": 74, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "test_splitcmdline", + "long_name": "test_splitcmdline( )", + "filename": "exec_command.py", + "nloc": 15, + "complexity": 1, + "token_count": 141, + "parameters": [], + "start_line": 106, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "find_executable", + "long_name": "find_executable( exe , path = None )", + "filename": "exec_command.py", + "nloc": 48, + "complexity": 20, + "token_count": 372, + "parameters": [ + "exe", + "path" + ], + "start_line": 124, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_preserve_environment", + "long_name": "_preserve_environment( names )", + "filename": "exec_command.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "names" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_update_environment", + "long_name": "_update_environment( ** env )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "env" + ], + "start_line": 188, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "exec_command", + "long_name": "exec_command( command , execute_in = '' , use_shell = None , use_tee = None , _with_python = 1 , ** env )", + "filename": "exec_command.py", + "nloc": 46, + "complexity": 14, + "token_count": 335, + "parameters": [ + "command", + "execute_in", + "use_shell", + "use_tee", + "_with_python", + "env" + ], + "start_line": 193, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 42, + "complexity": 8, + "token_count": 243, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 267, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 34, + "complexity": 2, + "token_count": 238, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "quote_arg", + "long_name": "quote_arg( arg )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 3, + "token_count": 23, + "parameters": [ + "arg" + ], + "start_line": 362, + "end_line": 365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_exec_command", + "long_name": "_exec_command( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 83, + "complexity": 20, + "token_count": 564, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 367, + "end_line": 476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 110, + "top_nesting_level": 0 + }, + { + "name": "test_nt", + "long_name": "test_nt( ** kws )", + "filename": "exec_command.py", + "nloc": 57, + "complexity": 22, + "token_count": 507, + "parameters": [ + "kws" + ], + "start_line": 479, + "end_line": 553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 75, + "top_nesting_level": 0 + }, + { + "name": "test_posix", + "long_name": "test_posix( ** kws )", + "filename": "exec_command.py", + "nloc": 31, + "complexity": 15, + "token_count": 372, + "parameters": [ + "kws" + ], + "start_line": 555, + "end_line": 601, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 17, + "complexity": 3, + "token_count": 133, + "parameters": [ + "kws" + ], + "start_line": 603, + "end_line": 620, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "test_svn", + "long_name": "test_svn( ** kws )", + "filename": "exec_command.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "kws" + ], + "start_line": 622, + "end_line": 625, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "test_cl", + "long_name": "test_cl( ** kws )", + "filename": "exec_command.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "kws" + ], + "start_line": 627, + "end_line": 631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_exec_command_posix", + "long_name": "_exec_command_posix( command , use_shell = None , use_tee = None , ** env )", + "filename": "exec_command.py", + "nloc": 42, + "complexity": 8, + "token_count": 243, + "parameters": [ + "command", + "use_shell", + "use_tee", + "env" + ], + "start_line": 267, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "test_execute_in", + "long_name": "test_execute_in( ** kws )", + "filename": "exec_command.py", + "nloc": 17, + "complexity": 3, + "token_count": 133, + "parameters": [ + "kws" + ], + "start_line": 603, + "end_line": 620, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_exec_command_python", + "long_name": "_exec_command_python( command , exec_command_dir = '' , ** env )", + "filename": "exec_command.py", + "nloc": 34, + "complexity": 2, + "token_count": 238, + "parameters": [ + "command", + "exec_command_dir", + "env" + ], + "start_line": 321, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + } + ], + "nloc": 497, + "complexity": 143, + "token_count": 3474, + "diff_parsed": { + "added": [ + "import tempfile" + ], + "deleted": [ + " import tempfile", + " import tempfile", + " import tempfile" + ] + } + } + ] + }, + { + "hash": "163d94675ef2b4e37700c2293d800b858b698b4a", + "msg": "Applied Bryce patch to support TestCase proxy classes.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-04T06:11:39+00:00", + "author_timezone": 0, + "committer_date": "2006-04-04T06:11:39+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "7c0eef63f9429ead37f628984de22177b08a5597" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 2, + "insertions": 5, + "lines": 7, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/testing/numpytest.py", + "new_path": "numpy/testing/numpytest.py", + "filename": "numpytest.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -139,10 +139,13 @@ def __call__(self, result=None):\n unittest.TestCase.__call__(self, result)\n if nof_errors != len(result.errors):\n test, errstr = result.errors[-1]\n- if type(errstr) is type(()):\n+ if isinstance(errstr, tuple):\n errstr = str(errstr[0])\n- else:\n+ elif isinstance(errstr, str):\n errstr = errstr.split('\\n')[-2]\n+ else:\n+ # allow for proxy classes\n+ errstr = str(errstr).split('\\n')[-2]\n l = len(result.stream.data)\n if errstr.startswith('IgnoreException:'):\n if l==1:\n", + "added_lines": 5, + "deleted_lines": 2, + "source_code": "\nimport os\nimport re\nimport sys\nimport imp\nimport glob\nimport types\nimport unittest\nimport traceback\n\n__all__ = ['set_package_path', 'set_local_path', 'restore_path',\n 'IgnoreException', 'NumpyTestCase', 'NumpyTest',\n 'ScipyTestCase', 'ScipyTest', # for backward compatibility\n ]\n\nDEBUG=0\nget_frame = sys._getframe\nfrom utils import jiffies\n\n\nclass IgnoreException(Exception):\n \"Ignoring this exception due to disabled feature\"\n\n\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 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 for test_file %r' % (d1, testfile)\n sys.path.insert(0,d1)\n return\n\n\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 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 return\n\n\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n return\n\n\ndef output_exception(printstream = sys.stdout):\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>>printstream, \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n return\n\n\nclass _dummy_stream:\n def __init__(self,stream):\n self.data = []\n self.stream = stream\n def write(self,message):\n if not self.data and not message.startswith('E'):\n self.stream.write(message)\n self.stream.flush()\n message = ''\n self.data.append(message)\n def writeln(self,message):\n self.write(message+'\\n')\n\n\nclass NumpyTestCase (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 = get_frame(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'NumpyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>sys.stderr,yellow_text('Warning: %s' % (message))\n sys.stderr.flush()\n def info(self, message):\n print>>sys.stdout, message\n sys.stdout.flush()\n\nScipyTestCase = NumpyTestCase\n\ndef _get_all_method_names(cls):\n names = dir(cls)\n if sys.version[:3]<='2.1':\n for b in cls.__bases__:\n for n in dir(b)+_get_all_method_names(b):\n if n not in names:\n names.append(n)\n return names\n\n\n# for debug build--check for memory leaks during the test.\nclass _SciPyTextTestResult(unittest._TextTestResult):\n def startTest(self, test):\n unittest._TextTestResult.startTest(self, test)\n if self.showAll:\n N = len(sys.getobjects(0))\n self._totnumobj = N\n self._totrefcnt = sys.gettotalrefcount()\n return\n\n def stopTest(self, test):\n if self.showAll:\n N = len(sys.getobjects(0))\n self.stream.write(\"objects: %d ===> %d; \" % (self._totnumobj, N))\n self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n sys.gettotalrefcount()))\n return\n\nclass SciPyTextTestRunner(unittest.TextTestRunner):\n def _makeResult(self):\n return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n\n\nclass NumpyTest:\n \"\"\" Numpy tests site manager.\n\n Usage:\n >>> NumpyTest().test(level=1,verbosity=1)\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 See .rename() method to redefine name mapping between test_*.py files\n and names of submodules. Pattern test_*.py can be overwritten by\n redefining .get_testfile() method.\n\n test_*.py files are supposed to define a classes, derived\n from NumpyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check. The names of TestCase\n classes must have a prefix test. This can be overwritten by\n redefining .check_testcase_name() method.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported.\n \"\"\"\n _check_testcase_name = re.compile(r'test.*').match\n def check_testcase_name(self, name):\n \"\"\" Return True if name matches TestCase class.\n \"\"\"\n return not not self._check_testcase_name(name)\n\n testfile_patterns = ['test_%(modulename)s.py']\n def get_testfile(self, module, verbosity = 0):\n \"\"\" Return path to module test file.\n \"\"\"\n mstr = self._module_str\n short_module_name = self._get_short_module_name(module)\n d = os.path.split(module.__file__)[0]\n test_dir = os.path.join(d,'tests')\n local_test_dir = os.path.join(os.getcwd(),'tests')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)):\n test_dir = local_test_dir\n for pat in self.testfile_patterns:\n fn = os.path.join(test_dir, pat % {'modulename':short_module_name})\n if os.path.isfile(fn):\n return fn\n if verbosity>1:\n self.warn('No test file found in %s for module %s' \\\n % (test_dir, mstr(module)))\n return\n\n def __init__(self, package=None):\n if package is None:\n from numpy.distutils.misc_util import get_frame\n f = get_frame(1)\n package = f.f_locals.get('__name__',f.f_globals.get('__name__',None))\n assert package is not None\n self.package = package\n self._rename_map = {}\n\n def rename(self, **kws):\n \"\"\" Apply renaming submodule test file test_.py to test_.py.\n Usage: self.rename(name='newname') before calling self.test() method.\n If 'newname' is None, then no tests will be executed for a given module.\n \"\"\"\n for k,v in kws.items():\n self._rename_map[k] = v\n return\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_short_module_name(self, module):\n d,f = os.path.split(module.__file__)\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n if short_module_name=='__init__':\n short_module_name = module.__name__.split('.')[-1]\n short_module_name = self._rename_map.get(short_module_name,short_module_name)\n return short_module_name\n\n def _get_module_tests(self,module,level,verbosity):\n mstr = self._module_str\n\n short_module_name = self._get_short_module_name(module)\n if short_module_name is None:\n return []\n\n test_file = self.get_testfile(module, verbosity)\n\n if test_file is None:\n return []\n\n if not os.path.isfile(test_file):\n if short_module_name[:5]=='info_' \\\n and short_module_name[5:]==module.__name__.split('.')[-2]:\n return []\n if short_module_name in ['__cvs_version__','__svn_version__']:\n return []\n if short_module_name[-8:]=='_version' \\\n and short_module_name[:-8]==module.__name__.split('.')[-2]:\n return []\n if verbosity>1:\n self.warn(test_file)\n self.warn(' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module)))\n return []\n\n if test_file in self.test_files:\n return []\n\n parent_module_name = '.'.join(module.__name__.split('.')[:-1])\n test_module_name,ext = os.path.splitext(os.path.basename(test_file))\n test_dir_module = parent_module_name+'.tests'\n test_module_name = test_dir_module+'.'+test_module_name\n\n if not sys.modules.has_key(test_dir_module):\n sys.modules[test_dir_module] = imp.new_module(test_dir_module)\n\n old_sys_path = sys.path[:]\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(test_module_name, f,\n test_file, ('.py', 'r', 1))\n f.close()\n except:\n sys.path[:] = old_sys_path\n self.warn('FAILURE importing tests for %s' % (mstr(module)))\n output_exception(sys.stderr)\n return []\n sys.path[:] = old_sys_path\n\n self.test_files.append(test_file)\n\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 verbosity=1):\n mstr = self._module_str\n suite_list = []\n if hasattr(test_module,'test_suite'):\n suite_list.extend(test_module.test_suite(level)._tests)\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 not self.check_testcase_name(obj.__name__):\n continue\n for mthname in self._get_method_names(obj,level):\n suite = obj(mthname)\n if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n suite_list.append(suite)\n if verbosity>=0:\n self.info(' Found %s tests for %s' % (len(suite_list),module_name))\n return suite_list\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Numpy module test suite with level and verbosity.\n\n level:\n None --- do nothing, return None\n < 0 --- scan for tests of level=abs(level),\n don't run them, return TestSuite-list\n > 0 --- scan for tests of level, run them,\n return TestRunner\n\n verbosity:\n >= 0 --- show information messages\n > 1 --- show warnings on missing tests\n \"\"\"\n if level is None: # Do nothing.\n return\n\n if isinstance(self.package, str):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n package_name = this_package.__name__\n\n modules = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None:\n continue\n if not hasattr(module,'__file__'):\n continue\n if os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n modules.append(module)\n\n self.test_files = []\n suites = []\n for module in modules:\n suites.extend(self._get_module_tests(module, abs(level), verbosity))\n\n suites.extend(self._get_suite_list(sys.modules[package_name],\n abs(level), verbosity=verbosity))\n\n all_tests = unittest.TestSuite(suites)\n if level<0:\n return all_tests\n\n runner = unittest.TextTestRunner(verbosity=verbosity)\n # Use the builtin displayhook. If the tests are being run\n # under IPython (for instance), any doctest test suites will\n # fail otherwise.\n old_displayhook = sys.displayhook\n sys.displayhook = sys.__displayhook__\n try:\n runner.run(all_tests)\n finally:\n sys.displayhook = old_displayhook\n return runner\n\n def run(self):\n \"\"\" Run Numpy 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 self.warn('Failed to import optparse module, ignoring.')\n return self.test()\n usage = r'usage: %prog [-v ] [-l ]'\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 return\n\n def warn(self, message):\n from numpy.distutils.misc_util import yellow_text\n print>>sys.stderr,yellow_text('Warning: %s' % (message))\n sys.stderr.flush()\n def info(self, message):\n print>>sys.stdout, message\n sys.stdout.flush()\n\nScipyTest = NumpyTest\n", + "source_code_before": "\nimport os\nimport re\nimport sys\nimport imp\nimport glob\nimport types\nimport unittest\nimport traceback\n\n__all__ = ['set_package_path', 'set_local_path', 'restore_path',\n 'IgnoreException', 'NumpyTestCase', 'NumpyTest',\n 'ScipyTestCase', 'ScipyTest', # for backward compatibility\n ]\n\nDEBUG=0\nget_frame = sys._getframe\nfrom utils import jiffies\n\n\nclass IgnoreException(Exception):\n \"Ignoring this exception due to disabled feature\"\n\n\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 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 for test_file %r' % (d1, testfile)\n sys.path.insert(0,d1)\n return\n\n\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 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 return\n\n\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n return\n\n\ndef output_exception(printstream = sys.stdout):\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>>printstream, \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n return\n\n\nclass _dummy_stream:\n def __init__(self,stream):\n self.data = []\n self.stream = stream\n def write(self,message):\n if not self.data and not message.startswith('E'):\n self.stream.write(message)\n self.stream.flush()\n message = ''\n self.data.append(message)\n def writeln(self,message):\n self.write(message+'\\n')\n\n\nclass NumpyTestCase (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 = get_frame(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'NumpyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>sys.stderr,yellow_text('Warning: %s' % (message))\n sys.stderr.flush()\n def info(self, message):\n print>>sys.stdout, message\n sys.stdout.flush()\n\nScipyTestCase = NumpyTestCase\n\ndef _get_all_method_names(cls):\n names = dir(cls)\n if sys.version[:3]<='2.1':\n for b in cls.__bases__:\n for n in dir(b)+_get_all_method_names(b):\n if n not in names:\n names.append(n)\n return names\n\n\n# for debug build--check for memory leaks during the test.\nclass _SciPyTextTestResult(unittest._TextTestResult):\n def startTest(self, test):\n unittest._TextTestResult.startTest(self, test)\n if self.showAll:\n N = len(sys.getobjects(0))\n self._totnumobj = N\n self._totrefcnt = sys.gettotalrefcount()\n return\n\n def stopTest(self, test):\n if self.showAll:\n N = len(sys.getobjects(0))\n self.stream.write(\"objects: %d ===> %d; \" % (self._totnumobj, N))\n self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n sys.gettotalrefcount()))\n return\n\nclass SciPyTextTestRunner(unittest.TextTestRunner):\n def _makeResult(self):\n return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n\n\nclass NumpyTest:\n \"\"\" Numpy tests site manager.\n\n Usage:\n >>> NumpyTest().test(level=1,verbosity=1)\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 See .rename() method to redefine name mapping between test_*.py files\n and names of submodules. Pattern test_*.py can be overwritten by\n redefining .get_testfile() method.\n\n test_*.py files are supposed to define a classes, derived\n from NumpyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check. The names of TestCase\n classes must have a prefix test. This can be overwritten by\n redefining .check_testcase_name() method.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported.\n \"\"\"\n _check_testcase_name = re.compile(r'test.*').match\n def check_testcase_name(self, name):\n \"\"\" Return True if name matches TestCase class.\n \"\"\"\n return not not self._check_testcase_name(name)\n\n testfile_patterns = ['test_%(modulename)s.py']\n def get_testfile(self, module, verbosity = 0):\n \"\"\" Return path to module test file.\n \"\"\"\n mstr = self._module_str\n short_module_name = self._get_short_module_name(module)\n d = os.path.split(module.__file__)[0]\n test_dir = os.path.join(d,'tests')\n local_test_dir = os.path.join(os.getcwd(),'tests')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)):\n test_dir = local_test_dir\n for pat in self.testfile_patterns:\n fn = os.path.join(test_dir, pat % {'modulename':short_module_name})\n if os.path.isfile(fn):\n return fn\n if verbosity>1:\n self.warn('No test file found in %s for module %s' \\\n % (test_dir, mstr(module)))\n return\n\n def __init__(self, package=None):\n if package is None:\n from numpy.distutils.misc_util import get_frame\n f = get_frame(1)\n package = f.f_locals.get('__name__',f.f_globals.get('__name__',None))\n assert package is not None\n self.package = package\n self._rename_map = {}\n\n def rename(self, **kws):\n \"\"\" Apply renaming submodule test file test_.py to test_.py.\n Usage: self.rename(name='newname') before calling self.test() method.\n If 'newname' is None, then no tests will be executed for a given module.\n \"\"\"\n for k,v in kws.items():\n self._rename_map[k] = v\n return\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_short_module_name(self, module):\n d,f = os.path.split(module.__file__)\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n if short_module_name=='__init__':\n short_module_name = module.__name__.split('.')[-1]\n short_module_name = self._rename_map.get(short_module_name,short_module_name)\n return short_module_name\n\n def _get_module_tests(self,module,level,verbosity):\n mstr = self._module_str\n\n short_module_name = self._get_short_module_name(module)\n if short_module_name is None:\n return []\n\n test_file = self.get_testfile(module, verbosity)\n\n if test_file is None:\n return []\n\n if not os.path.isfile(test_file):\n if short_module_name[:5]=='info_' \\\n and short_module_name[5:]==module.__name__.split('.')[-2]:\n return []\n if short_module_name in ['__cvs_version__','__svn_version__']:\n return []\n if short_module_name[-8:]=='_version' \\\n and short_module_name[:-8]==module.__name__.split('.')[-2]:\n return []\n if verbosity>1:\n self.warn(test_file)\n self.warn(' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module)))\n return []\n\n if test_file in self.test_files:\n return []\n\n parent_module_name = '.'.join(module.__name__.split('.')[:-1])\n test_module_name,ext = os.path.splitext(os.path.basename(test_file))\n test_dir_module = parent_module_name+'.tests'\n test_module_name = test_dir_module+'.'+test_module_name\n\n if not sys.modules.has_key(test_dir_module):\n sys.modules[test_dir_module] = imp.new_module(test_dir_module)\n\n old_sys_path = sys.path[:]\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(test_module_name, f,\n test_file, ('.py', 'r', 1))\n f.close()\n except:\n sys.path[:] = old_sys_path\n self.warn('FAILURE importing tests for %s' % (mstr(module)))\n output_exception(sys.stderr)\n return []\n sys.path[:] = old_sys_path\n\n self.test_files.append(test_file)\n\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 verbosity=1):\n mstr = self._module_str\n suite_list = []\n if hasattr(test_module,'test_suite'):\n suite_list.extend(test_module.test_suite(level)._tests)\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 not self.check_testcase_name(obj.__name__):\n continue\n for mthname in self._get_method_names(obj,level):\n suite = obj(mthname)\n if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n suite_list.append(suite)\n if verbosity>=0:\n self.info(' Found %s tests for %s' % (len(suite_list),module_name))\n return suite_list\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Numpy module test suite with level and verbosity.\n\n level:\n None --- do nothing, return None\n < 0 --- scan for tests of level=abs(level),\n don't run them, return TestSuite-list\n > 0 --- scan for tests of level, run them,\n return TestRunner\n\n verbosity:\n >= 0 --- show information messages\n > 1 --- show warnings on missing tests\n \"\"\"\n if level is None: # Do nothing.\n return\n\n if isinstance(self.package, str):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n package_name = this_package.__name__\n\n modules = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None:\n continue\n if not hasattr(module,'__file__'):\n continue\n if os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n modules.append(module)\n\n self.test_files = []\n suites = []\n for module in modules:\n suites.extend(self._get_module_tests(module, abs(level), verbosity))\n\n suites.extend(self._get_suite_list(sys.modules[package_name],\n abs(level), verbosity=verbosity))\n\n all_tests = unittest.TestSuite(suites)\n if level<0:\n return all_tests\n\n runner = unittest.TextTestRunner(verbosity=verbosity)\n # Use the builtin displayhook. If the tests are being run\n # under IPython (for instance), any doctest test suites will\n # fail otherwise.\n old_displayhook = sys.displayhook\n sys.displayhook = sys.__displayhook__\n try:\n runner.run(all_tests)\n finally:\n sys.displayhook = old_displayhook\n return runner\n\n def run(self):\n \"\"\" Run Numpy 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 self.warn('Failed to import optparse module, ignoring.')\n return self.test()\n usage = r'usage: %prog [-v ] [-l ]'\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 return\n\n def warn(self, message):\n from numpy.distutils.misc_util import yellow_text\n print>>sys.stderr,yellow_text('Warning: %s' % (message))\n sys.stderr.flush()\n def info(self, message):\n print>>sys.stdout, message\n sys.stdout.flush()\n\nScipyTest = NumpyTest\n", + "methods": [ + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "numpytest.py", + "nloc": 15, + "complexity": 4, + "token_count": 143, + "parameters": [ + "level" + ], + "start_line": 25, + "end_line": 56, + "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": "numpytest.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "reldir", + "level" + ], + "start_line": 59, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "numpytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 26, + "parameters": [], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "output_exception", + "long_name": "output_exception( printstream = sys . stdout )", + "filename": "numpytest.py", + "nloc": 10, + "complexity": 2, + "token_count": 77, + "parameters": [ + "printstream" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 100, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "numpytest.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 103, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 109, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "numpytest.py", + "nloc": 13, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 115, + "end_line": 130, + "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": "numpytest.py", + "nloc": 27, + "complexity": 7, + "token_count": 248, + "parameters": [ + "self", + "result" + ], + "start_line": 132, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "message" + ], + "start_line": 162, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "message" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "numpytest.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 172, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self", + "test" + ], + "start_line": 184, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 60, + "parameters": [ + "self", + "test" + ], + "start_line": 192, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_testcase_name", + "long_name": "check_testcase_name( self , name )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "name" + ], + "start_line": 231, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "get_testfile", + "long_name": "get_testfile( self , module , verbosity = 0 )", + "filename": "numpytest.py", + "nloc": 17, + "complexity": 5, + "token_count": 164, + "parameters": [ + "self", + "module", + "verbosity" + ], + "start_line": 237, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "numpytest.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "package" + ], + "start_line": 257, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "rename", + "long_name": "rename( self , ** kws )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "kws" + ], + "start_line": 266, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "numpytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 275, + "end_line": 279, + "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": "numpytest.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 281, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_short_module_name", + "long_name": "_get_short_module_name( self , module )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "module" + ], + "start_line": 304, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "numpytest.py", + "nloc": 44, + "complexity": 13, + "token_count": 365, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 312, + "end_line": 365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' , verbosity = 1 )", + "filename": "numpytest.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "self", + "test_module", + "level", + "module_name", + "verbosity" + ], + "start_line": 367, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "numpytest.py", + "nloc": 35, + "complexity": 11, + "token_count": 235, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 387, + "end_line": 444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "numpytest.py", + "nloc": 21, + "complexity": 2, + "token_count": 109, + "parameters": [ + "self" + ], + "start_line": 446, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "message" + ], + "start_line": 471, + "end_line": 474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "message" + ], + "start_line": 475, + "end_line": 477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "numpytest.py", + "nloc": 15, + "complexity": 4, + "token_count": 143, + "parameters": [ + "level" + ], + "start_line": 25, + "end_line": 56, + "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": "numpytest.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "reldir", + "level" + ], + "start_line": 59, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "numpytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 26, + "parameters": [], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "output_exception", + "long_name": "output_exception( printstream = sys . stdout )", + "filename": "numpytest.py", + "nloc": 10, + "complexity": 2, + "token_count": 77, + "parameters": [ + "printstream" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 100, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "numpytest.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 103, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 109, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "numpytest.py", + "nloc": 13, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 115, + "end_line": 130, + "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": "numpytest.py", + "nloc": 25, + "complexity": 6, + "token_count": 229, + "parameters": [ + "self", + "result" + ], + "start_line": 132, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "message" + ], + "start_line": 159, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "message" + ], + "start_line": 163, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "numpytest.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 169, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self", + "test" + ], + "start_line": 181, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 60, + "parameters": [ + "self", + "test" + ], + "start_line": 189, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 198, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_testcase_name", + "long_name": "check_testcase_name( self , name )", + "filename": "numpytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "name" + ], + "start_line": 228, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "get_testfile", + "long_name": "get_testfile( self , module , verbosity = 0 )", + "filename": "numpytest.py", + "nloc": 17, + "complexity": 5, + "token_count": 164, + "parameters": [ + "self", + "module", + "verbosity" + ], + "start_line": 234, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "numpytest.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "package" + ], + "start_line": 254, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "rename", + "long_name": "rename( self , ** kws )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "kws" + ], + "start_line": 263, + "end_line": 270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "numpytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 272, + "end_line": 276, + "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": "numpytest.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 278, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_short_module_name", + "long_name": "_get_short_module_name( self , module )", + "filename": "numpytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "module" + ], + "start_line": 301, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "numpytest.py", + "nloc": 44, + "complexity": 13, + "token_count": 365, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 309, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' , verbosity = 1 )", + "filename": "numpytest.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "self", + "test_module", + "level", + "module_name", + "verbosity" + ], + "start_line": 364, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "numpytest.py", + "nloc": 35, + "complexity": 11, + "token_count": 235, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 384, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "numpytest.py", + "nloc": 21, + "complexity": 2, + "token_count": 109, + "parameters": [ + "self" + ], + "start_line": 443, + "end_line": 466, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "numpytest.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "message" + ], + "start_line": 468, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "numpytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "message" + ], + "start_line": 472, + "end_line": 474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "__call__", + "long_name": "__call__( self , result = None )", + "filename": "numpytest.py", + "nloc": 27, + "complexity": 7, + "token_count": 248, + "parameters": [ + "self", + "result" + ], + "start_line": 132, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + } + ], + "nloc": 364, + "complexity": 99, + "token_count": 2589, + "diff_parsed": { + "added": [ + " if isinstance(errstr, tuple):", + " elif isinstance(errstr, str):", + " else:", + " # allow for proxy classes", + " errstr = str(errstr).split('\\n')[-2]" + ], + "deleted": [ + " if type(errstr) is type(()):", + " else:" + ] + } + } + ] + }, + { + "hash": "4c0bf7da9c6c7c5e554fb62792ee0322a3846239", + "msg": "Fixed typo.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-04T12:25:03+00:00", + "author_timezone": 0, + "committer_date": "2006-04-04T12:25:03+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "163d94675ef2b4e37700c2293d800b858b698b4a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 0, + "insertions": 1, + "lines": 1, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/core.py", + "new_path": "numpy/distutils/core.py", + "filename": "core.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -66,6 +66,7 @@ def _dict_append(d, **kws):\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n+ continue\n raise TypeError,`type(dv)`\n return\n \n", + "added_lines": 1, + "deleted_lines": 0, + "source_code": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n # easy_install imports math, it may be picked up from cwd\n from setuptools.command import develop, easy_install\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef _dict_append(d, **kws):\n for k,v in kws.items():\n if not d.has_key(k):\n d[k] = v\n continue\n dv = d[k]\n if isinstance(dv, tuple):\n dv += tuple(v)\n continue\n if isinstance(dv, list):\n dv += list(v)\n continue\n if isinstance(dv, dict):\n _dict_append(dv, **v)\n continue\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n continue\n raise TypeError,`type(dv)`\n return\n\ndef _command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n if new_attr.has_key('configuration'):\n # To avoid calling configuration if there are any errors\n # or help request in command in the line.\n configuration = new_attr.pop('configuration')\n\n import distutils.core\n old_dist = distutils.core._setup_distribution\n old_stop = distutils.core._setup_stop_after\n distutils.core._setup_distribution = None\n distutils.core._setup_stop_after = \"commandline\"\n try:\n dist = setup(**new_attr)\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n except Exception,msg:\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n raise msg\n if dist.help or not _command_line_ok():\n # probably displayed help, skip running any commands\n return dist\n\n # create setup dictionary and append to new_attr\n config = configuration()\n if hasattr(config,'todict'): config = config.todict()\n _dict_append(new_attr, **config)\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "source_code_before": "\nfrom distutils.core import *\ntry:\n from setuptools import setup as old_setup\n # very old setuptools don't have this\n from setuptools.command import bdist_egg\n # easy_install imports math, it may be picked up from cwd\n from setuptools.command import develop, easy_install\n have_setuptools = 1\nexcept ImportError:\n from distutils.core import setup as old_setup\n have_setuptools = 0\n\nfrom numpy.distutils.extension import Extension\nfrom numpy.distutils.command import config\nfrom numpy.distutils.command import build\nfrom numpy.distutils.command import build_py\nfrom numpy.distutils.command import config_compiler\nfrom numpy.distutils.command import build_ext\nfrom numpy.distutils.command import build_clib\nfrom numpy.distutils.command import build_src\nfrom numpy.distutils.command import build_scripts\nfrom numpy.distutils.command import sdist\nfrom numpy.distutils.command import install_data\nfrom numpy.distutils.command import install_headers\nfrom numpy.distutils.command import install\nfrom numpy.distutils.command import bdist_rpm\nfrom numpy.distutils.misc_util import get_data_files, is_sequence, is_string\n\nnumpy_cmdclass = {'build': build.build,\n 'build_src': build_src.build_src,\n 'build_scripts': build_scripts.build_scripts,\n 'config_fc': config_compiler.config_fc,\n 'config': config.config,\n 'build_ext': build_ext.build_ext,\n 'build_py': build_py.build_py,\n 'build_clib': build_clib.build_clib,\n 'sdist': sdist.sdist,\n 'install_data': install_data.install_data,\n 'install_headers': install_headers.install_headers,\n 'install': install.install,\n 'bdist_rpm': bdist_rpm.bdist_rpm,\n }\nif have_setuptools:\n from numpy.distutils.command import egg_info\n numpy_cmdclass['bdist_egg'] = bdist_egg.bdist_egg\n numpy_cmdclass['develop'] = develop.develop\n numpy_cmdclass['easy_install'] = easy_install.easy_install\n numpy_cmdclass['egg_info'] = egg_info.egg_info\n\ndef _dict_append(d, **kws):\n for k,v in kws.items():\n if not d.has_key(k):\n d[k] = v\n continue\n dv = d[k]\n if isinstance(dv, tuple):\n dv += tuple(v)\n continue\n if isinstance(dv, list):\n dv += list(v)\n continue\n if isinstance(dv, dict):\n _dict_append(dv, **v)\n continue\n if isinstance(dv, str):\n assert isinstance(v,str),`type(v)`\n d[k] = v\n raise TypeError,`type(dv)`\n return\n\ndef _command_line_ok(_cache=[]):\n \"\"\" Return True if command line does not contain any\n help or display requests.\n \"\"\"\n if _cache:\n return _cache[0]\n ok = True\n display_opts = ['--'+n for n in Distribution.display_option_names]\n for o in Distribution.display_options:\n if o[1]:\n display_opts.append('-'+o[1])\n for arg in sys.argv:\n if arg.startswith('--help') or arg=='-h' or arg in display_opts:\n ok = False\n break\n _cache.append(ok)\n return ok\n\ndef setup(**attr):\n\n cmdclass = numpy_cmdclass.copy()\n\n new_attr = attr.copy()\n if new_attr.has_key('cmdclass'):\n cmdclass.update(new_attr['cmdclass'])\n new_attr['cmdclass'] = cmdclass\n\n if new_attr.has_key('configuration'):\n # To avoid calling configuration if there are any errors\n # or help request in command in the line.\n configuration = new_attr.pop('configuration')\n\n import distutils.core\n old_dist = distutils.core._setup_distribution\n old_stop = distutils.core._setup_stop_after\n distutils.core._setup_distribution = None\n distutils.core._setup_stop_after = \"commandline\"\n try:\n dist = setup(**new_attr)\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n except Exception,msg:\n distutils.core._setup_distribution = old_dist\n distutils.core._setup_stop_after = old_stop\n raise msg\n if dist.help or not _command_line_ok():\n # probably displayed help, skip running any commands\n return dist\n\n # create setup dictionary and append to new_attr\n config = configuration()\n if hasattr(config,'todict'): config = config.todict()\n _dict_append(new_attr, **config)\n\n # Move extension source libraries to libraries\n libraries = []\n for ext in new_attr.get('ext_modules',[]):\n new_libraries = []\n for item in ext.libraries:\n if is_sequence(item):\n lib_name, build_info = item\n _check_append_ext_library(libraries, item)\n new_libraries.append(lib_name)\n elif is_string(item):\n new_libraries.append(item)\n else:\n raise TypeError(\"invalid description of extension module \"\n \"library %r\" % (item,))\n ext.libraries = new_libraries\n if libraries:\n if not new_attr.has_key('libraries'):\n new_attr['libraries'] = []\n for item in libraries:\n _check_append_library(new_attr['libraries'], item)\n\n # sources in ext_modules or libraries may contain header files\n if (new_attr.has_key('ext_modules') or new_attr.has_key('libraries')) \\\n and not new_attr.has_key('headers'):\n new_attr['headers'] = []\n\n return old_setup(**new_attr)\n\ndef _check_append_library(libraries, item):\n import warnings\n for libitem in libraries:\n if is_sequence(libitem):\n if is_sequence(item):\n if item[0]==libitem[0]:\n if item[1] is libitem[1]:\n return\n warnings.warn(\"[0] libraries list contains %r with\"\n \" different build_info\" % (item[0],))\n break\n else:\n if item==libitem[0]:\n warnings.warn(\"[1] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if is_sequence(item):\n if item[0]==libitem:\n warnings.warn(\"[2] libraries list contains %r with\"\n \" no build_info\" % (item[0],))\n break\n else:\n if item==libitem:\n return\n libraries.append(item)\n return\n\ndef _check_append_ext_library(libraries, (lib_name,build_info)):\n import warnings\n for item in libraries:\n if is_sequence(item):\n if item[0]==lib_name:\n if item[1] is build_info:\n return\n warnings.warn(\"[3] libraries list contains %r with\"\n \" different build_info\" % (lib_name,))\n break\n elif item==lib_name:\n warnings.warn(\"[4] libraries list contains %r with\"\n \" no build_info\" % (lib_name,))\n break\n libraries.append((lib_name,build_info))\n return\n", + "methods": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 21, + "complexity": 7, + "token_count": 126, + "parameters": [ + "d", + "kws" + ], + "start_line": 51, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 73, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 91, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 155, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 183, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 20, + "complexity": 7, + "token_count": 125, + "parameters": [ + "d", + "kws" + ], + "start_line": 51, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_command_line_ok", + "long_name": "_command_line_ok( _cache = [ ] )", + "filename": "core.py", + "nloc": 14, + "complexity": 9, + "token_count": 92, + "parameters": [ + "_cache" + ], + "start_line": 72, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup", + "long_name": "setup( ** attr )", + "filename": "core.py", + "nloc": 49, + "complexity": 17, + "token_count": 327, + "parameters": [ + "attr" + ], + "start_line": 90, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_check_append_library", + "long_name": "_check_append_library( libraries , item )", + "filename": "core.py", + "nloc": 27, + "complexity": 10, + "token_count": 138, + "parameters": [ + "libraries", + "item" + ], + "start_line": 154, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_check_append_ext_library", + "long_name": "_check_append_ext_library( libraries , ( lib_name , build_info )", + "filename": "core.py", + "nloc": 16, + "complexity": 6, + "token_count": 83, + "parameters": [ + "libraries", + "lib_name", + "build_info" + ], + "start_line": 182, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_dict_append", + "long_name": "_dict_append( d , ** kws )", + "filename": "core.py", + "nloc": 21, + "complexity": 7, + "token_count": 126, + "parameters": [ + "d", + "kws" + ], + "start_line": 51, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "nloc": 171, + "complexity": 49, + "token_count": 1065, + "diff_parsed": { + "added": [ + " continue" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "17d7cfe350073ca04a17f76323fe813e361d74de", + "msg": "Fix version machinery and pkg information requests.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-04T12:26:14+00:00", + "author_timezone": 0, + "committer_date": "2006-04-04T12:26:14+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "4c0bf7da9c6c7c5e554fb62792ee0322a3846239" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 42, + "insertions": 56, + "lines": 98, + "files": 3, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0625, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "numpy/distutils/misc_util.py", + "new_path": "numpy/distutils/misc_util.py", + "filename": "misc_util.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -475,6 +475,7 @@ class Configuration(object):\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n+ _extra_keys = ['name', 'version']\n \n numpy_include_dirs = []\n \n@@ -499,6 +500,7 @@ def __init__(self,\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n+ self.version = None\n \n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n@@ -529,7 +531,7 @@ def __init__(self,\n setattr(self, n, v)\n \n known_keys = self.list_keys + self.dict_keys\n- self.extra_keys = []\n+ self.extra_keys = self._extra_keys[:]\n for n in attrs.keys():\n if n in known_keys:\n continue\n@@ -574,12 +576,11 @@ def todict(self):\n \"\"\"\n self._optimize_data_files()\n d = {}\n- for n in self.list_keys + self.dict_keys + self.extra_keys:\n+ known_keys = self.list_keys + self.dict_keys + self.extra_keys\n+ for n in known_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n- if self.name:\n- d['name'] = self.name\n return d\n \n def info(self, message):\n@@ -589,7 +590,6 @@ def info(self, message):\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n \n-\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n \n@@ -733,7 +733,7 @@ def add_subpackage(self,subpackage_name,\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n-\n+ \n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n@@ -1068,12 +1068,21 @@ def dict_append(self,**dict):\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n- if key not in known_keys and not hasattr(self,key):\n- if key not in ['version']:\n- self.warn('Inheriting attribute %r from %r' \\\n- % (key,dict.get('name','?')))\n+ if key not in known_keys:\n+ a = getattr(self, key, None)\n+ if a and a==dict[key]: continue\n+ self.warn('Inheriting attribute %r=%r from %r' \\\n+ % (key,dict[key],dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n+ elif key in self.extra_keys:\n+ self.info('Ignoring attempt to set %r (from %r to %r)' \\\n+ % (key, getattr(self,key), dict[key]))\n+ elif key in known_keys:\n+ # key is already processed above\n+ pass\n+ else:\n+ raise ValueError, \"Don't know about key=%r\" % (key)\n return\n \n def __str__(self):\n@@ -1081,6 +1090,7 @@ def __str__(self):\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n+ known_keys.sort()\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n@@ -1158,7 +1168,7 @@ def _get_svn_revision(self,path):\n revision = int(m.group('revision'))\n return revision\n \n- def get_version(self):\n+ def get_version(self, version_file=None, version_variable=None):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n@@ -1166,13 +1176,19 @@ def get_version(self):\n return version\n \n # Get version from version file.\n- files = ['__version__.py',\n- self.name.split('.')[-1]+'_version.py',\n- 'version.py',\n- '__svn_version__.py']\n- version_vars = ['version',\n- '__version__',\n- self.name.split('.')[-1]+'_version']\n+ if version_file is None:\n+ files = ['__version__.py',\n+ self.name.split('.')[-1]+'_version.py',\n+ 'version.py',\n+ '__svn_version__.py']\n+ else:\n+ files = [version_file]\n+ if version_variable is None:\n+ version_vars = ['version',\n+ '__version__',\n+ self.name.split('.')[-1]+'_version']\n+ else:\n+ version_vars = [version_variable]\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n", + "added_lines": 34, + "deleted_lines": 18, + "source_code": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return is_string(s) and ('*' in s or '?' is s)\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n _extra_keys = ['name', 'version']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n self.version = None\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = self._extra_keys[:]\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for n in known_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n \n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if callable(filepat):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys:\n a = getattr(self, key, None)\n if a and a==dict[key]: continue\n self.warn('Inheriting attribute %r=%r from %r' \\\n % (key,dict[key],dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n elif key in self.extra_keys:\n self.info('Ignoring attempt to set %r (from %r to %r)' \\\n % (key, getattr(self,key), dict[key]))\n elif key in known_keys:\n # key is already processed above\n pass\n else:\n raise ValueError, \"Don't know about key=%r\" % (key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n known_keys.sort()\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self, version_file=None, version_variable=None):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n if version_file is None:\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n else:\n files = [version_file]\n if version_variable is None:\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n else:\n version_vars = [version_variable]\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "source_code_before": "import os\nimport re\nimport sys\nimport imp\nimport copy\nimport glob\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',\n 'dict_append', 'appendpath', 'generate_config_py',\n 'get_cmd', 'allpath', 'get_mathlibs',\n 'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',\n 'blue_text', 'cyan_text', 'cyg2win32','mingw32','all_strings',\n 'has_f_sources', 'has_cxx_sources', 'filter_sources',\n 'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',\n 'get_script_files', 'get_lib_source_files', 'get_data_files',\n 'dot_join', 'get_frame', 'minrelpath','njoin',\n 'is_sequence', 'is_string', 'as_list', 'gpaths']\n\ndef allpath(name):\n \"Convert a /-separated pathname to one using the OS's path separator.\"\n splitted = name.split('/')\n return os.path.join(*splitted)\n\ndef rel_path(path, parent_path):\n \"\"\" Return path relative to parent_path.\n \"\"\"\n pd = os.path.abspath(parent_path)\n apath = os.path.abspath(path)\n if len(apath)= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None\n and curses.tigetstr(\"setb\") is not None)\n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None)):\n return 1\n except Exception,msg:\n pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\n#########################\n\ndef cyg2win32(path):\n if sys.platform=='cygwin' and path.startswith('/cygdrive'):\n path = path[10] + ':' + os.path.normcase(path[11:])\n return path\n\ndef mingw32():\n \"\"\" Return true when using mingw32 environment.\n \"\"\"\n if sys.platform=='win32':\n if os.environ.get('OSTYPE','')=='msys':\n return True\n if os.environ.get('MSYSTEM','')=='MINGW32':\n return True\n return False\n\n#########################\n\n#XXX need support for .C that is also C++\ncxx_ext_match = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_ext_match = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\nf90_ext_match = re.compile(r'.*[.](f90|f95)\\Z',re.I).match\nf90_module_name_match = re.compile(r'\\s*module\\s*(?P[\\w_]+)',re.I).match\ndef _get_f90_modules(source):\n \"\"\" Return a list of Fortran f90 module names that\n given source file defines.\n \"\"\"\n if not f90_ext_match(source):\n return []\n modules = []\n f = open(source,'r')\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = f90_module_name_match(line)\n if m:\n name = m.group('name')\n modules.append(name)\n # break # XXX can we assume that there is one module per file?\n f.close()\n return modules\n\ndef is_string(s):\n return isinstance(s, str)\n\ndef all_strings(lst):\n \"\"\" Return True if all items in lst are string objects. \"\"\"\n for item in lst:\n if not is_string(item):\n return False\n return True\n\ndef is_sequence(seq):\n if is_string(seq):\n return False\n try:\n len(seq)\n except:\n return False\n return True\n\ndef is_glob_pattern(s):\n return is_string(s) and ('*' in s or '?' is s)\n\ndef as_list(seq):\n if is_sequence(seq):\n return list(seq)\n else:\n return [seq]\n\ndef has_f_sources(sources):\n \"\"\" Return True if sources contains Fortran files \"\"\"\n for source in sources:\n if fortran_ext_match(source):\n return True\n return False\n\ndef has_cxx_sources(sources):\n \"\"\" Return True if sources contains C++ files \"\"\"\n for source in sources:\n if cxx_ext_match(source):\n return True\n return False\n\ndef filter_sources(sources):\n \"\"\" Return four lists of filenames containing\n C, C++, Fortran, and Fortran 90 module sources,\n respectively.\n \"\"\"\n c_sources = []\n cxx_sources = []\n f_sources = []\n fmodule_sources = []\n for source in sources:\n if fortran_ext_match(source):\n modules = _get_f90_modules(source)\n if modules:\n fmodule_sources.append(source)\n else:\n f_sources.append(source)\n elif cxx_ext_match(source):\n cxx_sources.append(source)\n else:\n c_sources.append(source)\n return c_sources, cxx_sources, f_sources, fmodule_sources\n\n\ndef _get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for d in directory_list:\n head = glob.glob(os.path.join(d,\"*.h\")) #XXX: *.hpp files??\n headers.extend(head)\n return headers\n\ndef _get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for f in list_of_sources:\n d = os.path.split(f)\n if d[0] != '' and not d[0] in direcs:\n direcs.append(d[0])\n return direcs\n\ndef get_dependencies(sources):\n #XXX scan sources for include statements\n return _get_headers(_get_directories(sources))\n\ndef is_local_src_dir(directory):\n \"\"\" Return true if directory is local directory.\n \"\"\"\n if not is_string(directory):\n return False\n abs_dir = os.path.abspath(directory)\n c = os.path.commonprefix([os.getcwd(),abs_dir])\n new_dir = abs_dir[len(c):].split(os.sep)\n if new_dir and not new_dir[0]:\n new_dir = new_dir[1:]\n if new_dir and new_dir[0]=='build':\n return False\n new_dir = os.sep.join(new_dir)\n return os.path.isdir(new_dir)\n\ndef general_source_files(top_path):\n pruned_directories = {'CVS':1, '.svn':1, 'build':1}\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for f in filenames:\n if not prune_file_pat.search(f):\n yield os.path.join(dirpath, f)\n\ndef general_source_directories_files(top_path):\n \"\"\" Return a directory name relative to top_path and\n files contained.\n \"\"\"\n pruned_directories = ['CVS','.svn','build']\n prune_file_pat = re.compile(r'(?:^\\..*|[~#]|\\.py[co]|\\.o)$')\n for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):\n pruned = [ d for d in dirnames if d not in pruned_directories ]\n dirnames[:] = pruned\n for d in dirnames:\n dpath = os.path.join(dirpath, d)\n rpath = rel_path(dpath, top_path)\n files = []\n for f in os.listdir(dpath):\n fn = os.path.join(dpath,f)\n if os.path.isfile(fn) and not prune_file_pat.search(fn):\n files.append(fn)\n yield rpath, files\n dpath = top_path\n rpath = rel_path(dpath, top_path)\n filenames = [os.path.join(dpath,f) for f in os.listdir(dpath) \\\n if not prune_file_pat.search(f)]\n files = [f for f in filenames if os.path.isfile(f)]\n yield rpath, files\n\n\ndef get_ext_source_files(ext):\n # Get sources and any include files in the same directory.\n filenames = []\n sources = filter(is_string, ext.sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n for d in ext.depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_script_files(scripts):\n scripts = filter(is_string, scripts)\n return scripts\n\ndef get_lib_source_files(lib):\n filenames = []\n sources = lib[1].get('sources',[])\n sources = filter(is_string, sources)\n filenames.extend(sources)\n filenames.extend(get_dependencies(sources))\n depends = lib[1].get('depends',[])\n for d in depends:\n if is_local_src_dir(d):\n filenames.extend(list(general_source_files(d)))\n elif os.path.isfile(d):\n filenames.append(d)\n return filenames\n\ndef get_data_files(data):\n if is_string(data):\n return [data]\n sources = data[1]\n filenames = []\n for s in sources:\n if callable(s):\n continue\n if is_local_src_dir(s):\n filenames.extend(list(general_source_files(s)))\n elif is_string(s):\n if os.path.isfile(s):\n filenames.append(s)\n else:\n print 'Not existing data file:',s\n else:\n raise TypeError,repr(s)\n return filenames\n\ndef dot_join(*args):\n return '.'.join([a for a in args if a])\n\ndef get_frame(level=0):\n \"\"\" Return frame object from call stack with given level.\n \"\"\"\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for _ in range(level+1):\n frame = frame.f_back\n return frame\n\n######################\n\nclass Configuration(object):\n\n _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',\n 'libraries', 'headers', 'scripts', 'py_modules']\n _dict_keys = ['package_dir']\n\n numpy_include_dirs = []\n\n def __init__(self,\n package_name=None,\n parent_name=None,\n top_path=None,\n package_path=None,\n caller_level=1,\n **attrs):\n \"\"\" Construct configuration instance of a package.\n\n package_name -- name of the package\n Ex.: 'distutils'\n parent_name -- name of the parent package\n Ex.: 'numpy'\n top_path -- directory of the toplevel package\n Ex.: the directory where the numpy package source sits\n package_path -- directory of package. Will be computed by magic from the\n directory of the caller module if not specified\n Ex.: the directory where numpy.distutils is\n caller_level -- frame level to caller namespace, internal parameter.\n \"\"\"\n self.name = dot_join(parent_name, package_name)\n\n caller_frame = get_frame(caller_level)\n caller_name = eval('__name__',caller_frame.f_globals,caller_frame.f_locals)\n self.local_path = get_path(caller_name, top_path)\n if top_path is None:\n top_path = self.local_path\n self.local_path = '.'\n if package_path is None:\n package_path = self.local_path\n elif os.path.isdir(njoin(self.local_path,package_path)):\n package_path = njoin(self.local_path,package_path)\n if not os.path.isdir(package_path):\n raise ValueError(\"%r is not a directory\" % (package_path,))\n self.top_path = top_path\n self.package_path = package_path\n # this is the relative path in the installed package\n self.path_in_package = os.path.join(*self.name.split('.'))\n\n self.list_keys = self._list_keys[:]\n self.dict_keys = self._dict_keys[:]\n\n for n in self.list_keys:\n v = copy.copy(attrs.get(n, []))\n setattr(self, n, as_list(v))\n\n for n in self.dict_keys:\n v = copy.copy(attrs.get(n, {}))\n setattr(self, n, v)\n\n known_keys = self.list_keys + self.dict_keys\n self.extra_keys = []\n for n in attrs.keys():\n if n in known_keys:\n continue\n a = attrs[n]\n setattr(self,n,a)\n if isinstance(a, list):\n self.list_keys.append(n)\n elif isinstance(a, dict):\n self.dict_keys.append(n)\n else:\n self.extra_keys.append(n)\n\n if os.path.exists(njoin(package_path,'__init__.py')):\n self.packages.append(self.name)\n self.package_dir[self.name] = package_path\n\n self.options = dict(\n ignore_setup_xxx_py = False,\n assume_default_configuration = False,\n delegate_options_to_subpackages = False,\n quiet = False,\n )\n\n caller_instance = None\n for i in range(1,3):\n try:\n f = get_frame(i)\n except ValueError:\n break\n try:\n caller_instance = eval('self',f.f_globals,f.f_locals)\n break\n except NameError:\n pass\n if isinstance(caller_instance, self.__class__):\n if caller_instance.options['delegate_options_to_subpackages']:\n self.set_options(**caller_instance.options)\n\n def todict(self):\n \"\"\" Return configuration distionary suitable for passing\n to distutils.core.setup() function.\n \"\"\"\n self._optimize_data_files()\n d = {}\n for n in self.list_keys + self.dict_keys + self.extra_keys:\n a = getattr(self,n)\n if a:\n d[n] = a\n if self.name:\n d['name'] = self.name\n return d\n\n def info(self, message):\n if not self.options['quiet']:\n print message\n\n def warn(self, message):\n print>>sys.stderr, 'Warning:',message\n\n\n def set_options(self, **options):\n \"\"\" Configure Configuration instance.\n\n The following options are available:\n - ignore_setup_xxx_py\n - assume_default_configuration\n - delegate_options_to_subpackages\n - quiet\n \"\"\"\n for key, value in options.items():\n if self.options.has_key(key):\n self.options[key] = value\n else:\n raise ValueError,'Unknown option: '+key\n\n def get_distribution(self):\n import distutils.core\n dist = distutils.core._setup_distribution\n return dist\n\n def _wildcard_get_subpackage(self, subpackage_name,\n parent_name,\n caller_level = 1):\n l = subpackage_name.split('.')\n subpackage_path = njoin([self.local_path]+l)\n dirs = filter(os.path.isdir,glob.glob(subpackage_path))\n config_list = []\n for d in dirs:\n if not os.path.isfile(njoin(d,'__init__.py')):\n continue\n if 'build' in d.split(os.sep):\n continue\n n = '.'.join(d.split(os.sep)[-len(l):])\n c = self.get_subpackage(n,\n parent_name = parent_name,\n caller_level = caller_level+1)\n config_list.extend(c)\n return config_list\n\n def _get_configuration_from_setup_py(self, setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = 1):\n # In case setup_py imports local modules:\n sys.path.insert(0,os.path.dirname(setup_py))\n try:\n fo_setup_py = open(setup_py, 'U')\n setup_name = os.path.splitext(os.path.basename(setup_py))[0]\n n = dot_join(self.name,subpackage_name,setup_name)\n setup_module = imp.load_module('_'.join(n.split('.')),\n fo_setup_py,\n setup_py,\n ('.py', 'U', 1))\n fo_setup_py.close()\n if not hasattr(setup_module,'configuration'):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s does not define configuration())'\\\n % (setup_module))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level + 1)\n else:\n args = (parent_name,)\n if setup_module.configuration.func_code.co_argcount > 1:\n args = args + (self.top_path,)\n config = setup_module.configuration(*args)\n finally:\n del sys.path[0]\n return config\n\n def get_subpackage(self,subpackage_name,\n subpackage_path=None,\n parent_name=None,\n caller_level = 1):\n \"\"\" Return list of subpackage configurations.\n\n '*' in subpackage_name is handled as a wildcard.\n \"\"\"\n if subpackage_name is None:\n if subpackage_path is None:\n raise ValueError(\n \"either subpackage_name or subpackage_path must be specified\")\n subpackage_name = os.path.basename(subpackage_path)\n\n # handle wildcards\n l = subpackage_name.split('.')\n if subpackage_path is None and '*' in subpackage_name:\n return self._wildcard_get_subpackage(subpackage_name,\n parent_name,\n caller_level = caller_level+1)\n\n if subpackage_path is None:\n subpackage_path = njoin([self.local_path] + l)\n else:\n subpackage_path = njoin([subpackage_path] + l[:-1])\n subpackage_path = self.paths([subpackage_path])[0]\n\n setup_py = njoin(subpackage_path, 'setup.py')\n if not self.options['ignore_setup_xxx_py']:\n if not os.path.isfile(setup_py):\n setup_py = njoin(subpackage_path,\n 'setup_%s.py' % (subpackage_name))\n if not os.path.isfile(setup_py):\n if not self.options['assume_default_configuration']:\n self.warn('Assuming default configuration '\\\n '(%s/{setup_%s,setup}.py was not found)' \\\n % (os.path.dirname(setup_py), subpackage_name))\n config = Configuration(subpackage_name, parent_name,\n self.top_path, subpackage_path,\n caller_level = caller_level+1)\n else:\n config = self._get_configuration_from_setup_py(\n setup_py,\n subpackage_name,\n subpackage_path,\n parent_name,\n caller_level = caller_level + 1)\n if config:\n return [config]\n else:\n return []\n\n def add_subpackage(self,subpackage_name,\n subpackage_path=None,\n standalone = False):\n \"\"\" Add subpackage to configuration.\n \"\"\"\n if standalone:\n parent_name = None\n else:\n parent_name = self.name\n config_list = self.get_subpackage(subpackage_name,subpackage_path,\n parent_name = parent_name,\n caller_level = 2)\n if not config_list:\n self.warn('No configuration returned, assuming unavailable.')\n for config in config_list:\n d = config\n if isinstance(config, Configuration):\n d = config.todict()\n assert isinstance(d,dict),`type(d)`\n\n self.info('Appending %s configuration to %s' \\\n % (d.get('name'), self.name))\n self.dict_append(**d)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a subpackage '+ subpackage_name)\n return\n\n def add_data_dir(self,data_path):\n \"\"\" Recursively add files under data_path to data_files list.\n Argument can be either\n - 2-sequence (,)\n - path to data directory where python datadir suffix defaults\n to package dir.\n\n Rules for installation paths:\n foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar\n (gun, foo/bar) -> parent/gun\n foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b\n (gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun\n (gun/*, foo/*) -> parent/gun/a, parent/gun/b\n /foo/bar -> (bar, /foo/bar) -> parent/bar\n (gun, /foo/bar) -> parent/gun\n (fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar\n \"\"\"\n if is_sequence(data_path):\n d, data_path = data_path\n else:\n d = None\n if is_sequence(data_path):\n [self.add_data_dir((d,p)) for p in data_path]\n return\n if not is_string(data_path):\n raise TypeError(\"not a string: %r\" % (data_path,))\n if d is None:\n if os.path.isabs(data_path):\n return self.add_data_dir((os.path.basename(data_path), data_path))\n return self.add_data_dir((data_path, data_path))\n paths = self.paths(data_path, include_non_existing=False)\n if is_glob_pattern(data_path):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n if i>=len(path_list):\n raise ValueError,'cannot fill pattern %r with %r' \\\n % (d, path)\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_dir((os.sep.join(target_list),path))\n else:\n for path in paths:\n self.add_data_dir((d,path))\n return\n assert not is_glob_pattern(d),`d`\n \n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n for path in paths:\n for d1,f in list(general_source_directories_files(path)):\n target_path = os.path.join(self.path_in_package,d,d1)\n data_files.append((target_path, f))\n return\n\n def _optimize_data_files(self):\n data_dict = {}\n for p,files in self.data_files:\n if not data_dict.has_key(p):\n data_dict[p] = set()\n map(data_dict[p].add,files)\n self.data_files[:] = [(p,list(files)) for p,files in data_dict.items()]\n return\n\n def add_data_files(self,*files):\n \"\"\" Add data files to configuration data_files.\n Argument(s) can be either\n - 2-sequence (,)\n - paths to data files where python datadir prefix defaults\n to package dir.\n\n Rules for installation paths:\n file.txt -> (., file.txt)-> parent/file.txt\n foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt\n /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt\n *.txt -> parent/a.txt, parent/b.txt\n foo/*.txt -> parent/foo/a.txt, parent/foo/b.txt\n */*.txt -> (*, */*.txt) -> parent/c/a.txt, parent/d/b.txt\n (sun, file.txt) -> parent/sun/file.txt\n (sun, bar/file.txt) -> parent/sun/file.txt\n (sun, /foo/bar/file.txt) -> parent/sun/file.txt\n (sun, *.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun, bar/*.txt) -> parent/sun/a.txt, parent/sun/b.txt\n (sun/*, */*.txt) -> parent/sun/c/a.txt, parent/d/b.txt\n \"\"\"\n\n if len(files)>1:\n map(self.add_data_files, files)\n return\n assert len(files)==1\n if is_sequence(files[0]):\n d,files = files[0]\n else:\n d = None\n if is_string(files):\n filepat = files\n elif is_sequence(files):\n if len(files)==1:\n filepat = files[0]\n else:\n for f in files:\n self.add_data_files((d,f))\n return\n else:\n raise TypeError,`type(files)`\n\n if d is None:\n if callable(filepat):\n d = ''\n elif os.path.isabs(filepat):\n d = ''\n else:\n d = os.path.dirname(filepat)\n self.add_data_files((d,files))\n return\n\n paths = self.paths(filepat, include_non_existing=False)\n if is_glob_pattern(filepat):\n if is_glob_pattern(d):\n pattern_list = d.split(os.sep)\n pattern_list.reverse()\n for path in paths:\n path_list = path.split(os.sep)\n path_list.reverse()\n path_list.pop() # filename\n target_list = []\n i = 0\n for s in pattern_list:\n if is_glob_pattern(s):\n target_list.append(path_list[i])\n i += 1\n else:\n target_list.append(s)\n target_list.reverse()\n self.add_data_files((os.sep.join(target_list), path))\n else:\n self.add_data_files((d,paths))\n return\n assert not is_glob_pattern(d),`d,filepat`\n\n dist = self.get_distribution()\n if dist is not None:\n data_files = dist.data_files\n else:\n data_files = self.data_files\n\n data_files.append((os.path.join(self.path_in_package,d),paths))\n return\n\n ### XXX Implement add_py_modules\n\n def add_include_dirs(self,*paths):\n \"\"\" Add paths to configuration include directories.\n \"\"\"\n include_dirs = self.paths(paths)\n dist = self.get_distribution()\n if dist is not None:\n dist.include_dirs.extend(include_dirs)\n else:\n self.include_dirs.extend(include_dirs)\n return\n\n def add_headers(self,*files):\n \"\"\" Add installable headers to configuration.\n Argument(s) can be either\n - 2-sequence (,)\n - path(s) to header file(s) where python includedir suffix will default\n to package name.\n \"\"\"\n headers = []\n for path in files:\n if is_string(path):\n [headers.append((self.name,p)) for p in self.paths(path)]\n else:\n if not isinstance(path, (tuple, list)) or len(path) != 2:\n raise TypeError(repr(path))\n [headers.append((path[0],p)) for p in self.paths(path[1])]\n dist = self.get_distribution()\n if dist is not None:\n dist.headers.extend(headers)\n else:\n self.headers.extend(headers)\n return\n\n def paths(self,*paths,**kws):\n \"\"\" Apply glob to paths and prepend local_path if needed.\n \"\"\"\n include_non_existing = kws.get('include_non_existing',True)\n return gpaths(paths,\n local_path = self.local_path,\n include_non_existing=include_non_existing)\n\n def _fix_paths_dict(self,kw):\n for k in kw.keys():\n v = kw[k]\n if k in ['sources','depends','include_dirs','library_dirs',\n 'module_dirs','extra_objects']:\n new_v = self.paths(v)\n kw[k] = new_v\n return\n\n def add_extension(self,name,sources,**kw):\n \"\"\" Add extension to configuration.\n\n Keywords:\n include_dirs, define_macros, undef_macros,\n library_dirs, libraries, runtime_library_dirs,\n extra_objects, extra_compile_args, extra_link_args,\n export_symbols, swig_opts, depends, language,\n f2py_options, module_dirs\n extra_info - dict or list of dict of keywords to be\n appended to keywords.\n \"\"\"\n ext_args = copy.copy(kw)\n ext_args['name'] = dot_join(self.name,name)\n ext_args['sources'] = sources\n\n if ext_args.has_key('extra_info'):\n extra_info = ext_args['extra_info']\n del ext_args['extra_info']\n if isinstance(extra_info, dict):\n extra_info = [extra_info]\n for info in extra_info:\n assert isinstance(info, dict), repr(info)\n dict_append(ext_args,**info)\n\n self._fix_paths_dict(ext_args)\n\n # Resolve out-of-tree dependencies\n libraries = ext_args.get('libraries',[])\n libnames = []\n ext_args['libraries'] = []\n for libname in libraries:\n if isinstance(libname,tuple):\n self._fix_paths_dict(libname[1])\n\n # Handle library names of the form libname@relative/path/to/library\n if '@' in libname:\n lname,lpath = libname.split('@',1)\n lpath = os.path.abspath(njoin(self.local_path,lpath))\n if os.path.isdir(lpath):\n c = self.get_subpackage(None,lpath,\n caller_level = 2)\n if isinstance(c,Configuration):\n c = c.todict()\n for l in [l[0] for l in c.get('libraries',[])]:\n llname = l.split('__OF__',1)[0]\n if llname == lname:\n c.pop('name',None)\n dict_append(ext_args,**c)\n break\n continue\n libnames.append(libname)\n\n ext_args['libraries'] = libnames + ext_args['libraries']\n\n from numpy.distutils.core import Extension\n ext = Extension(**ext_args)\n self.ext_modules.append(ext)\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add an extension '+name)\n return ext\n\n def add_library(self,name,sources,**build_info):\n \"\"\" Add library to configuration.\n\n Valid keywords for build_info:\n depends\n macros\n include_dirs\n extra_compiler_args\n f2py_options\n \"\"\"\n build_info = copy.copy(build_info)\n name = name #+ '__OF__' + self.name\n build_info['sources'] = sources\n\n self._fix_paths_dict(build_info)\n\n self.libraries.append((name,build_info))\n\n dist = self.get_distribution()\n if dist is not None:\n self.warn('distutils distribution has been initialized,'\\\n ' it may be too late to add a library '+ name)\n return\n\n def add_scripts(self,*files):\n \"\"\" Add scripts to configuration.\n \"\"\"\n scripts = self.paths(files)\n dist = self.get_distribution()\n if dist is not None:\n dist.scripts.extend(scripts)\n else:\n self.scripts.extend(scripts)\n return\n\n def dict_append(self,**dict):\n for key in self.list_keys:\n a = getattr(self,key)\n a.extend(dict.get(key,[]))\n for key in self.dict_keys:\n a = getattr(self,key)\n a.update(dict.get(key,{}))\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n for key in dict.keys():\n if key not in known_keys and not hasattr(self,key):\n if key not in ['version']:\n self.warn('Inheriting attribute %r from %r' \\\n % (key,dict.get('name','?')))\n setattr(self,key,dict[key])\n self.extra_keys.append(key)\n return\n\n def __str__(self):\n from pprint import pformat\n known_keys = self.list_keys + self.dict_keys + self.extra_keys\n s = '<'+5*'-' + '\\n'\n s += 'Configuration of '+self.name+':\\n'\n for k in known_keys:\n a = getattr(self,k,None)\n if a:\n s += '%s = %s\\n' % (k,pformat(a))\n s += 5*'-' + '>'\n return s\n\n def get_config_cmd(self):\n cmd = get_cmd('config')\n cmd.ensure_finalized()\n cmd.dump_source = 0\n cmd.noisy = 0\n old_path = os.environ.get('PATH')\n if old_path:\n path = os.pathsep.join(['.',old_path])\n os.environ['PATH'] = path\n return cmd\n\n def get_build_temp_dir(self):\n cmd = get_cmd('build')\n cmd.ensure_finalized()\n return cmd.build_temp\n\n def have_f77c(self):\n \"\"\" Check for availability of Fortran 77 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f77')\n return flag\n\n def have_f90c(self):\n \"\"\" Check for availability of Fortran 90 compiler.\n Use it inside source generating function to ensure that\n setup distribution instance has been initialized.\n \"\"\"\n simple_fortran_subroutine = '''\n subroutine simple\n end\n '''\n config_cmd = self.get_config_cmd()\n flag = config_cmd.try_compile(simple_fortran_subroutine,lang='f90')\n return flag\n\n def append_to(self, extlib):\n \"\"\" Append libraries, include_dirs to extension or library item.\n \"\"\"\n if is_sequence(extlib):\n lib_name, build_info = extlib\n dict_append(build_info,\n libraries=self.libraries,\n include_dirs=self.include_dirs)\n else:\n from numpy.distutils.core import Extension\n assert isinstance(extlib,Extension), repr(extlib)\n extlib.libraries.extend(self.libraries)\n extlib.include_dirs.extend(self.include_dirs)\n return\n\n def _get_svn_revision(self,path):\n \"\"\" Return path's SVN revision number.\n \"\"\"\n entries = njoin(path,'.svn','entries')\n revision = None\n if os.path.isfile(entries):\n f = open(entries)\n m = re.search(r'revision=\"(?P\\d+)\"',f.read())\n f.close()\n if m:\n revision = int(m.group('revision'))\n return revision\n\n def get_version(self):\n \"\"\" Try to get version string of a package.\n \"\"\"\n version = getattr(self,'version',None)\n if version is not None:\n return version\n\n # Get version from version file.\n files = ['__version__.py',\n self.name.split('.')[-1]+'_version.py',\n 'version.py',\n '__svn_version__.py']\n version_vars = ['version',\n '__version__',\n self.name.split('.')[-1]+'_version']\n for f in files:\n fn = njoin(self.local_path,f)\n if os.path.isfile(fn):\n info = (open(fn),fn,('.py','U',1))\n name = os.path.splitext(os.path.basename(fn))[0]\n n = dot_join(self.name,name)\n try:\n version_module = imp.load_module('_'.join(n.split('.')),*info)\n except ImportError,msg:\n self.warn(str(msg))\n version_module = None\n if version_module is None:\n continue\n\n for a in version_vars:\n version = getattr(version_module,a,None)\n if version is not None:\n break\n if version is not None:\n break\n\n if version is not None:\n self.version = version\n return version\n\n # Get version as SVN revision number\n revision = self._get_svn_revision(self.local_path)\n if revision is not None:\n version = str(revision)\n self.version = version\n\n return version\n\n def make_svn_version_py(self):\n \"\"\" Generate package __svn_version__.py file from SVN revision number,\n it will be removed after python exits but will be available\n when sdist, etc commands are executed.\n\n If __svn_version__.py existed before, nothing is done.\n \"\"\"\n target = njoin(self.local_path,'__svn_version__.py')\n if os.path.isfile(target):\n return\n def generate_svn_version_py():\n if not os.path.isfile(target):\n revision = self._get_svn_revision(self.local_path)\n assert revision is not None,'hmm, why I am not inside SVN tree???'\n version = str(revision)\n self.info('Creating %s (version=%r)' % (target,version))\n f = open(target,'w')\n f.write('version = %r\\n' % (version))\n f.close()\n\n import atexit\n def rm_file(f=target,p=self.info):\n try: os.remove(f); p('removed '+f)\n except OSError: pass\n try: os.remove(f+'c'); p('removed '+f+'c')\n except OSError: pass\n atexit.register(rm_file)\n\n return target\n\n self.add_data_files(('', generate_svn_version_py()))\n\n def make_config_py(self,name='__config__'):\n \"\"\" Generate package __config__.py file containing system_info\n information used during building the package.\n \"\"\"\n self.py_modules.append((self.name,name,generate_config_py))\n return\n\n def get_info(self,*names):\n \"\"\" Get resources information.\n \"\"\"\n from system_info import get_info, dict_append\n info_dict = {}\n for a in names:\n dict_append(info_dict,**get_info(a))\n return info_dict\n\n\ndef get_cmd(cmdname, _cache={}):\n if not _cache.has_key(cmdname):\n import distutils.core\n dist = distutils.core._setup_distribution\n if dist is None:\n from distutils.errors import DistutilsInternalError\n raise DistutilsInternalError(\n 'setup distribution instance not initialized')\n cmd = dist.get_command_obj(cmdname)\n _cache[cmdname] = cmd\n return _cache[cmdname]\n\ndef get_numpy_include_dirs():\n # numpy_include_dirs are set by numpy/core/setup.py, otherwise []\n include_dirs = Configuration.numpy_include_dirs[:]\n if not include_dirs:\n import numpy\n if numpy.show_config is None:\n # running from numpy_core source directory\n include_dirs.append(njoin(os.path.dirname(numpy.__file__),\n 'core', 'include'))\n else:\n # using installed numpy core headers\n import numpy.core as core\n include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))\n # else running numpy/core/setup.py\n return include_dirs\n\n#########################\n\ndef default_config_dict(name = None, parent_name = None, local_path=None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n import warnings\n warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\\\n 'deprecated default_config_dict(%r,%r,%r)'\n % (name, parent_name, local_path,\n name, parent_name, local_path,\n ))\n c = Configuration(name, parent_name, local_path)\n return c.todict()\n\n\ndef dict_append(d, **kws):\n for k, v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef appendpath(prefix, path):\n if os.path.sep != '/':\n prefix = prefix.replace('/', os.path.sep)\n path = path.replace('/', os.path.sep)\n drive = ''\n if os.path.isabs(path):\n drive = os.path.splitdrive(prefix)[0]\n absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]\n pathdrive, path = os.path.splitdrive(path)\n d = os.path.commonprefix([absprefix, path])\n if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \\\n or os.path.join(path[:len(d)], path[len(d):]) != path:\n # Handle invalid paths\n d = os.path.dirname(d)\n subpath = path[len(d):]\n if os.path.isabs(subpath):\n subpath = subpath[1:]\n else:\n subpath = path\n return os.path.normpath(njoin(drive + prefix, subpath))\n\ndef generate_config_py(target):\n \"\"\" Generate config.py file containing system_info information\n used during building the package.\n\n Usage:\\\n config['py_modules'].append((packagename, '__config__',generate_config_py))\n \"\"\"\n from numpy.distutils.system_info import system_info\n from distutils.dir_util import mkpath\n mkpath(os.path.dirname(target))\n f = open(target, 'w')\n f.write('# This file is generated by %s\\n' % (os.path.abspath(sys.argv[0])))\n f.write('# It contains system_info results at the time of building this package.\\n')\n f.write('__all__ = [\"get_info\",\"show\"]\\n\\n')\n for k, i in system_info.saved_results.items():\n f.write('%s=%r\\n' % (k, i))\n f.write('\\ndef get_info(name): g=globals(); return g.get(name,g.get(name+\"_info\",{}))\\n')\n f.write('''\ndef show():\n for name,info_dict in globals().items():\n if name[0]==\"_\" or type(info_dict) is not type({}): continue\n print name+\":\"\n if not info_dict:\n print \" NOT AVAILABLE\"\n for k,v in info_dict.items():\n v = str(v)\n if k==\\'sources\\' and len(v)>200: v = v[:60]+\\' ...\\\\n... \\'+v[-60:]\n print \\' %s = %s\\'%(k,v)\n print\n return\n ''')\n\n f.close()\n return target\n", + "methods": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 68, + "complexity": 17, + "token_count": 483, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 482, + "end_line": 571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 573, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 586, + "end_line": 588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 590, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 912, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 923, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 945, + "end_line": 951, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 953, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 962, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1027, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1051, + "end_line": 1060, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 24, + "complexity": 9, + "token_count": 206, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1086, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 3, + "token_count": 84, + "parameters": [ + "self" + ], + "start_line": 1088, + "end_line": 1099, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1101, + "end_line": 1110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1112, + "end_line": 1115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1117, + "end_line": 1128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1130, + "end_line": 1141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1143, + "end_line": 1156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1158, + "end_line": 1169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self , version_file = None , version_variable = None )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 292, + "parameters": [ + "self", + "version_file", + "version_variable" + ], + "start_line": 1171, + "end_line": 1223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1246, + "end_line": 1250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1235, + "end_line": 1253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1225, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1257, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1264, + "end_line": 1271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1274, + "end_line": 1284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1286, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1304, + "end_line": 1315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1318, + "end_line": 1323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1325, + "end_line": 1344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1346, + "end_line": 1379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "allpath", + "long_name": "allpath( name )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "name" + ], + "start_line": 24, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "rel_path", + "long_name": "rel_path( path , parent_path )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 100, + "parameters": [ + "path", + "parent_path" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_path", + "long_name": "get_path( mod_name , parent_path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 113, + "parameters": [ + "mod_name", + "parent_path" + ], + "start_line": 43, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "njoin", + "long_name": "njoin( * path )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 5, + "token_count": 96, + "parameters": [ + "path" + ], + "start_line": 68, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "get_mathlibs", + "long_name": "get_mathlibs( path = None )", + "filename": "misc_util.py", + "nloc": 14, + "complexity": 5, + "token_count": 98, + "parameters": [ + "path" + ], + "start_line": 95, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "minrelpath", + "long_name": "minrelpath( path )", + "filename": "misc_util.py", + "nloc": 26, + "complexity": 9, + "token_count": 124, + "parameters": [ + "path" + ], + "start_line": 112, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_fix_paths", + "long_name": "_fix_paths( paths , local_path , include_non_existing )", + "filename": "misc_util.py", + "nloc": 35, + "complexity": 13, + "token_count": 222, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 141, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "gpaths", + "long_name": "gpaths( paths , local_path = '' , include_non_existing = True )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 2, + "token_count": 35, + "parameters": [ + "paths", + "local_path", + "include_non_existing" + ], + "start_line": 178, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "terminal_has_colors", + "long_name": "terminal_has_colors( )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 13, + "token_count": 137, + "parameters": [], + "start_line": 188, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "cyg2win32", + "long_name": "cyg2win32( path )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 3, + "token_count": 42, + "parameters": [ + "path" + ], + "start_line": 230, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "mingw32", + "long_name": "mingw32( )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 46, + "parameters": [], + "start_line": 235, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_get_f90_modules", + "long_name": "_get_f90_modules( source )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 77, + "parameters": [ + "source" + ], + "start_line": 252, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_string", + "long_name": "is_string( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "s" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "all_strings", + "long_name": "all_strings( lst )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 22, + "parameters": [ + "lst" + ], + "start_line": 273, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_sequence", + "long_name": "is_sequence( seq )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 25, + "parameters": [ + "seq" + ], + "start_line": 280, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "is_glob_pattern", + "long_name": "is_glob_pattern( s )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 20, + "parameters": [ + "s" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "as_list", + "long_name": "as_list( seq )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "seq" + ], + "start_line": 292, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "has_f_sources", + "long_name": "has_f_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 298, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "has_cxx_sources", + "long_name": "has_cxx_sources( sources )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 21, + "parameters": [ + "sources" + ], + "start_line": 305, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "filter_sources", + "long_name": "filter_sources( sources )", + "filename": "misc_util.py", + "nloc": 17, + "complexity": 5, + "token_count": 84, + "parameters": [ + "sources" + ], + "start_line": 312, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "_get_headers", + "long_name": "_get_headers( directory_list )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "directory_list" + ], + "start_line": 335, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_get_directories", + "long_name": "_get_directories( list_of_sources )", + "filename": "misc_util.py", + "nloc": 7, + "complexity": 4, + "token_count": 51, + "parameters": [ + "list_of_sources" + ], + "start_line": 343, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "get_dependencies", + "long_name": "get_dependencies( sources )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "sources" + ], + "start_line": 352, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "is_local_src_dir", + "long_name": "is_local_src_dir( directory )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 6, + "token_count": 107, + "parameters": [ + "directory" + ], + "start_line": 356, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "general_source_files", + "long_name": "general_source_files( top_path )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 6, + "token_count": 92, + "parameters": [ + "top_path" + ], + "start_line": 371, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "general_source_directories_files", + "long_name": "general_source_directories_files( top_path )", + "filename": "misc_util.py", + "nloc": 21, + "complexity": 12, + "token_count": 206, + "parameters": [ + "top_path" + ], + "start_line": 381, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "get_ext_source_files", + "long_name": "get_ext_source_files( ext )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 4, + "token_count": 77, + "parameters": [ + "ext" + ], + "start_line": 407, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "get_script_files", + "long_name": "get_script_files( scripts )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "scripts" + ], + "start_line": 420, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_lib_source_files", + "long_name": "get_lib_source_files( lib )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 4, + "token_count": 101, + "parameters": [ + "lib" + ], + "start_line": 424, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "get_data_files", + "long_name": "get_data_files( data )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 7, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 438, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "dot_join", + "long_name": "dot_join( * args )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 3, + "token_count": 21, + "parameters": [ + "args" + ], + "start_line": 457, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_frame", + "long_name": "get_frame( level = 0 )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "level" + ], + "start_line": 460, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 67, + "complexity": 17, + "token_count": 474, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 481, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 4, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 571, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , message )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self", + "message" + ], + "start_line": 585, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , message )", + "filename": "misc_util.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "message" + ], + "start_line": 589, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "set_options", + "long_name": "set_options( self , ** options )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "options" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "get_distribution", + "long_name": "get_distribution( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 608, + "end_line": 611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_wildcard_get_subpackage", + "long_name": "_wildcard_get_subpackage( self , subpackage_name , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 18, + "complexity": 4, + "token_count": 138, + "parameters": [ + "self", + "subpackage_name", + "parent_name", + "caller_level" + ], + "start_line": 613, + "end_line": 630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_get_configuration_from_setup_py", + "long_name": "_get_configuration_from_setup_py( self , setup_py , subpackage_name , subpackage_path , parent_name , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 31, + "complexity": 5, + "token_count": 211, + "parameters": [ + "self", + "setup_py", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 632, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "get_subpackage", + "long_name": "get_subpackage( self , subpackage_name , subpackage_path = None , parent_name = None , caller_level = 1 )", + "filename": "misc_util.py", + "nloc": 43, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "parent_name", + "caller_level" + ], + "start_line": 665, + "end_line": 715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "add_data_dir", + "long_name": "add_data_dir( self , data_path )", + "filename": "misc_util.py", + "nloc": 50, + "complexity": 17, + "token_count": 344, + "parameters": [ + "self", + "data_path" + ], + "start_line": 747, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 1 + }, + { + "name": "_optimize_data_files", + "long_name": "_optimize_data_files( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 4, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 816, + "end_line": 823, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_data_files", + "long_name": "add_data_files( self , * files )", + "filename": "misc_util.py", + "nloc": 59, + "complexity": 16, + "token_count": 359, + "parameters": [ + "self", + "files" + ], + "start_line": 825, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 1 + }, + { + "name": "add_include_dirs", + "long_name": "add_include_dirs( self , * paths )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "paths" + ], + "start_line": 912, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "add_headers", + "long_name": "add_headers( self , * files )", + "filename": "misc_util.py", + "nloc": 15, + "complexity": 8, + "token_count": 136, + "parameters": [ + "self", + "files" + ], + "start_line": 923, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "paths", + "long_name": "paths( self , * paths , ** kws )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "paths", + "kws" + ], + "start_line": 945, + "end_line": 951, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_fix_paths_dict", + "long_name": "_fix_paths_dict( self , kw )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "kw" + ], + "start_line": 953, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "add_extension", + "long_name": "add_extension( self , name , sources , ** kw )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 341, + "parameters": [ + "self", + "name", + "sources", + "kw" + ], + "start_line": 962, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 1 + }, + { + "name": "add_library", + "long_name": "add_library( self , name , sources , ** build_info )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "name", + "sources", + "build_info" + ], + "start_line": 1027, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "add_scripts", + "long_name": "add_scripts( self , * files )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "files" + ], + "start_line": 1051, + "end_line": 1060, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 16, + "complexity": 7, + "token_count": 150, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 1079, + "end_line": 1089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_config_cmd", + "long_name": "get_config_cmd( self )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 1091, + "end_line": 1100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_build_temp_dir", + "long_name": "get_build_temp_dir( self )", + "filename": "misc_util.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 1102, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "have_f77c", + "long_name": "have_f77c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1107, + "end_line": 1118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "have_f90c", + "long_name": "have_f90c( self )", + "filename": "misc_util.py", + "nloc": 8, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 1120, + "end_line": 1131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "append_to", + "long_name": "append_to( self , extlib )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "extlib" + ], + "start_line": 1133, + "end_line": 1146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "_get_svn_revision", + "long_name": "_get_svn_revision( self , path )", + "filename": "misc_util.py", + "nloc": 10, + "complexity": 3, + "token_count": 73, + "parameters": [ + "self", + "path" + ], + "start_line": 1148, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1161, + "end_line": 1207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file", + "long_name": "make_svn_version_py.make_svn_version_py.generate_svn_version_py.rm_file( f = target , p = self . info )", + "filename": "misc_util.py", + "nloc": 5, + "complexity": 3, + "token_count": 55, + "parameters": [ + "f", + "p" + ], + "start_line": 1230, + "end_line": 1234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "make_svn_version_py.generate_svn_version_py", + "long_name": "make_svn_version_py.generate_svn_version_py( )", + "filename": "misc_util.py", + "nloc": 13, + "complexity": 2, + "token_count": 85, + "parameters": [], + "start_line": 1219, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 2 + }, + { + "name": "make_svn_version_py", + "long_name": "make_svn_version_py( self )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1209, + "end_line": 1239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "make_config_py", + "long_name": "make_config_py( self , name = '__config__' )", + "filename": "misc_util.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "name" + ], + "start_line": 1241, + "end_line": 1246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self , * names )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "self", + "names" + ], + "start_line": 1248, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "get_cmd", + "long_name": "get_cmd( cmdname , _cache = { } )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 65, + "parameters": [ + "cmdname", + "_cache" + ], + "start_line": 1258, + "end_line": 1268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "get_numpy_include_dirs", + "long_name": "get_numpy_include_dirs( )", + "filename": "misc_util.py", + "nloc": 11, + "complexity": 3, + "token_count": 77, + "parameters": [], + "start_line": 1270, + "end_line": 1284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "default_config_dict", + "long_name": "default_config_dict( name = None , parent_name = None , local_path = None )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "name", + "parent_name", + "local_path" + ], + "start_line": 1288, + "end_line": 1299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "misc_util.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 1302, + "end_line": 1307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "appendpath", + "long_name": "appendpath( prefix , path )", + "filename": "misc_util.py", + "nloc": 19, + "complexity": 6, + "token_count": 230, + "parameters": [ + "prefix", + "path" + ], + "start_line": 1309, + "end_line": 1328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generate_config_py", + "long_name": "generate_config_py( target )", + "filename": "misc_util.py", + "nloc": 27, + "complexity": 2, + "token_count": 117, + "parameters": [ + "target" + ], + "start_line": 1330, + "end_line": 1363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__init__", + "long_name": "__init__( self , package_name = None , parent_name = None , top_path = None , package_path = None , caller_level = 1 , ** attrs )", + "filename": "misc_util.py", + "nloc": 68, + "complexity": 17, + "token_count": 483, + "parameters": [ + "self", + "package_name", + "parent_name", + "top_path", + "package_path", + "caller_level", + "attrs" + ], + "start_line": 482, + "end_line": 571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "misc_util.py", + "nloc": 12, + "complexity": 3, + "token_count": 84, + "parameters": [ + "self" + ], + "start_line": 1088, + "end_line": 1099, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self )", + "filename": "misc_util.py", + "nloc": 38, + "complexity": 11, + "token_count": 260, + "parameters": [ + "self" + ], + "start_line": 1161, + "end_line": 1207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 1 + }, + { + "name": "get_version", + "long_name": "get_version( self , version_file = None , version_variable = None )", + "filename": "misc_util.py", + "nloc": 44, + "complexity": 13, + "token_count": 292, + "parameters": [ + "self", + "version_file", + "version_variable" + ], + "start_line": 1171, + "end_line": 1223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "add_subpackage", + "long_name": "add_subpackage( self , subpackage_name , subpackage_path = None , standalone = False )", + "filename": "misc_util.py", + "nloc": 25, + "complexity": 6, + "token_count": 145, + "parameters": [ + "self", + "subpackage_name", + "subpackage_path", + "standalone" + ], + "start_line": 717, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dict_append", + "long_name": "dict_append( self , ** dict )", + "filename": "misc_util.py", + "nloc": 24, + "complexity": 9, + "token_count": 206, + "parameters": [ + "self", + "dict" + ], + "start_line": 1062, + "end_line": 1086, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "todict", + "long_name": "todict( self )", + "filename": "misc_util.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 573, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + } + ], + "nloc": 1040, + "complexity": 328, + "token_count": 7184, + "diff_parsed": { + "added": [ + " _extra_keys = ['name', 'version']", + " self.version = None", + " self.extra_keys = self._extra_keys[:]", + " known_keys = self.list_keys + self.dict_keys + self.extra_keys", + " for n in known_keys:", + "", + " if key not in known_keys:", + " a = getattr(self, key, None)", + " if a and a==dict[key]: continue", + " self.warn('Inheriting attribute %r=%r from %r' \\", + " % (key,dict[key],dict.get('name','?')))", + " elif key in self.extra_keys:", + " self.info('Ignoring attempt to set %r (from %r to %r)' \\", + " % (key, getattr(self,key), dict[key]))", + " elif key in known_keys:", + " # key is already processed above", + " pass", + " else:", + " raise ValueError, \"Don't know about key=%r\" % (key)", + " known_keys.sort()", + " def get_version(self, version_file=None, version_variable=None):", + " if version_file is None:", + " files = ['__version__.py',", + " self.name.split('.')[-1]+'_version.py',", + " 'version.py',", + " '__svn_version__.py']", + " else:", + " files = [version_file]", + " if version_variable is None:", + " version_vars = ['version',", + " '__version__',", + " self.name.split('.')[-1]+'_version']", + " else:", + " version_vars = [version_variable]" + ], + "deleted": [ + " self.extra_keys = []", + " for n in self.list_keys + self.dict_keys + self.extra_keys:", + " if self.name:", + " d['name'] = self.name", + "", + "", + " if key not in known_keys and not hasattr(self,key):", + " if key not in ['version']:", + " self.warn('Inheriting attribute %r from %r' \\", + " % (key,dict.get('name','?')))", + " def get_version(self):", + " files = ['__version__.py',", + " self.name.split('.')[-1]+'_version.py',", + " 'version.py',", + " '__svn_version__.py']", + " version_vars = ['version',", + " '__version__',", + " self.name.split('.')[-1]+'_version']" + ] + } + }, + { + "old_path": "numpy/setup.py", + "new_path": "numpy/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,5 +1,4 @@\n #!/usr/bin/env python\n-import os\n \n def configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n@@ -14,8 +13,7 @@ def configuration(parent_package='',top_path=None):\n config.add_subpackage('random')\n config.add_data_dir('doc')\n config.make_config_py() # installs __config__.py\n-\n- return config.todict()\n+ return config\n \n if __name__ == '__main__':\n # Remove current working directory from sys.path\n@@ -24,4 +22,4 @@ def configuration(parent_package='',top_path=None):\n sys.path.remove(os.getcwd())\n \n from numpy.distutils.core import setup\n- setup(**configuration(top_path=''))\n+ setup(configuration=configuration)\n", + "added_lines": 2, + "deleted_lines": 4, + "source_code": "#!/usr/bin/env python\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n config = Configuration('numpy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('testing')\n config.add_subpackage('f2py')\n config.add_subpackage('core')\n config.add_subpackage('lib')\n config.add_subpackage('dft')\n config.add_subpackage('linalg')\n config.add_subpackage('random')\n config.add_data_dir('doc')\n config.make_config_py() # installs __config__.py\n return config\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing numpy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from numpy.distutils.core import setup\n setup(configuration=configuration)\n", + "source_code_before": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n config = Configuration('numpy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('testing')\n config.add_subpackage('f2py')\n config.add_subpackage('core')\n config.add_subpackage('lib')\n config.add_subpackage('dft')\n config.add_subpackage('linalg')\n config.add_subpackage('random')\n config.add_data_dir('doc')\n config.make_config_py() # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing numpy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from numpy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 14, + "complexity": 1, + "token_count": 90, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 14, + "complexity": 1, + "token_count": 94, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 14, + "complexity": 1, + "token_count": 90, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + } + ], + "nloc": 19, + "complexity": 1, + "token_count": 126, + "diff_parsed": { + "added": [ + " return config", + " setup(configuration=configuration)" + ], + "deleted": [ + "import os", + "", + " return config.todict()", + " setup(**configuration(top_path=''))" + ] + } + }, + { + "old_path": "setup.py", + "new_path": "setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -34,33 +34,18 @@\n def configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n \n- config = Configuration(None, parent_package, top_path,\n- maintainer = \"NumPy Developers\",\n- maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n- description = DOCLINES[0],\n- long_description = \"\\n\".join(DOCLINES[2:]),\n- url = \"http://numeric.scipy.org\",\n- download_url = \"http://sourceforge.net/projects/numpy\",\n- license = 'BSD',\n- classifiers=filter(None, CLASSIFIERS.split('\\n')),\n- author = \"Travis E. Oliphant, et.al.\",\n- author_email = \"oliphant@ee.byu.edu\",\n- platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n- )\n+ config = Configuration(None, parent_package, top_path)\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n-\n- config.name = 'numpy' # used in generated file names\n- \n- from numpy.version import version\n- config.dict_append(version=version)\n- \n+ \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n+\n+ config.get_version('numpy/version.py') # sets config.version\n \n return config\n \n@@ -74,7 +59,22 @@ def setup_package():\n sys.path.insert(0,local_path)\n \n try:\n- setup( configuration=configuration )\n+ from numpy.version import version\n+ setup(\n+ name = 'numpy',\n+ version = version, # will be overwritten by configuration version\n+ maintainer = \"NumPy Developers\",\n+ maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n+ description = DOCLINES[0],\n+ long_description = \"\\n\".join(DOCLINES[2:]),\n+ url = \"http://numeric.scipy.org\",\n+ download_url = \"http://sourceforge.net/projects/numpy\",\n+ license = 'BSD',\n+ classifiers=filter(None, CLASSIFIERS.split('\\n')),\n+ author = \"Travis E. Oliphant, et.al.\",\n+ author_email = \"oliphant@ee.byu.edu\",\n+ platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"], \n+ configuration=configuration )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n", + "added_lines": 20, + "deleted_lines": 20, + "source_code": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n\n config = Configuration(None, parent_package, top_path)\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n\n config.get_version('numpy/version.py') # sets config.version\n \n return config\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n\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 from numpy.version import version\n setup(\n name = 'numpy',\n version = version, # will be overwritten by configuration version\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"], \n configuration=configuration )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "source_code_before": "\"\"\"NumPy: array processing for numbers, strings, records, and objects.\n\nNumPy is a general-purpose array-processing package designed to\nefficiently manipulate large multi-dimensional arrays of arbitrary\nrecords without sacrificing too much speed for small multi-dimensional\narrays. NumPy is built on the Numeric code base and adds features\nintroduced by numarray as well as an extended C-API and the ability to\ncreate arrays of arbitrary type.\n\nThere are also basic facilities for discrete fourier transform,\nbasic linear algebra and random number generation.\n\"\"\"\n\nDOCLINES = __doc__.split(\"\\n\")\n\nimport os\nimport sys\n\nCLASSIFIERS = \"\"\"\\\nDevelopment Status :: 4 - Beta\nIntended Audience :: Science/Research\nIntended Audience :: Developers\nLicense :: OSI Approved\nProgramming Language :: C\nProgramming Language :: Python\nTopic :: Software Development\nTopic :: Scientific/Engineering\nOperating System :: Microsoft :: Windows\nOperating System :: POSIX\nOperating System :: Unix\nOperating System :: MacOS\n\"\"\"\n\ndef configuration(parent_package='',top_path=None):\n from numpy.distutils.misc_util import Configuration\n\n config = Configuration(None, parent_package, top_path,\n maintainer = \"NumPy Developers\",\n maintainer_email = \"numpy-discussion@lists.sourceforge.net\",\n description = DOCLINES[0],\n long_description = \"\\n\".join(DOCLINES[2:]),\n url = \"http://numeric.scipy.org\",\n download_url = \"http://sourceforge.net/projects/numpy\",\n license = 'BSD',\n classifiers=filter(None, CLASSIFIERS.split('\\n')),\n author = \"Travis E. Oliphant, et.al.\",\n author_email = \"oliphant@ee.byu.edu\",\n platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],\n )\n config.set_options(ignore_setup_xxx_py=True,\n assume_default_configuration=True,\n delegate_options_to_subpackages=True,\n quiet=True)\n \n config.add_subpackage('numpy')\n\n config.name = 'numpy' # used in generated file names\n \n from numpy.version import version\n config.dict_append(version=version)\n \n config.add_data_files(('numpy',['*.txt','COMPATIBILITY',\n 'scipy_compatibility']))\n \n return config\n\ndef setup_package():\n\n from numpy.distutils.core import setup\n\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 setup( configuration=configuration )\n finally:\n del sys.path[0]\n os.chdir(old_path)\n return\n\nif __name__ == '__main__':\n setup_package()\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 12, + "complexity": 1, + "token_count": 79, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 27, + "complexity": 2, + "token_count": 171, + "parameters": [], + "start_line": 52, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 26, + "complexity": 1, + "token_count": 169, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [], + "start_line": 67, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 12, + "complexity": 1, + "token_count": 79, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 34, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "setup_package", + "long_name": "setup_package( )", + "filename": "setup.py", + "nloc": 27, + "complexity": 2, + "token_count": 171, + "parameters": [], + "start_line": 52, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "nloc": 70, + "complexity": 3, + "token_count": 276, + "diff_parsed": { + "added": [ + " config = Configuration(None, parent_package, top_path)", + "", + "", + " config.get_version('numpy/version.py') # sets config.version", + " from numpy.version import version", + " setup(", + " name = 'numpy',", + " version = version, # will be overwritten by configuration version", + " maintainer = \"NumPy Developers\",", + " maintainer_email = \"numpy-discussion@lists.sourceforge.net\",", + " description = DOCLINES[0],", + " long_description = \"\\n\".join(DOCLINES[2:]),", + " url = \"http://numeric.scipy.org\",", + " download_url = \"http://sourceforge.net/projects/numpy\",", + " license = 'BSD',", + " classifiers=filter(None, CLASSIFIERS.split('\\n')),", + " author = \"Travis E. Oliphant, et.al.\",", + " author_email = \"oliphant@ee.byu.edu\",", + " platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],", + " configuration=configuration )" + ], + "deleted": [ + " config = Configuration(None, parent_package, top_path,", + " maintainer = \"NumPy Developers\",", + " maintainer_email = \"numpy-discussion@lists.sourceforge.net\",", + " description = DOCLINES[0],", + " long_description = \"\\n\".join(DOCLINES[2:]),", + " url = \"http://numeric.scipy.org\",", + " download_url = \"http://sourceforge.net/projects/numpy\",", + " license = 'BSD',", + " classifiers=filter(None, CLASSIFIERS.split('\\n')),", + " author = \"Travis E. Oliphant, et.al.\",", + " author_email = \"oliphant@ee.byu.edu\",", + " platforms = [\"Windows\", \"Linux\", \"Solaris\", \"Mac OS-X\", \"Unix\"],", + " )", + "", + " config.name = 'numpy' # used in generated file names", + "", + " from numpy.version import version", + " config.dict_append(version=version)", + "", + " setup( configuration=configuration )" + ] + } + } + ] + }, + { + "hash": "035720e9fa8fe6ba910ec92b38aa7a28cc63e692", + "msg": "Fixed bug in sorting on byteswapped arrays.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-04-06T09:44:35+00:00", + "author_timezone": 0, + "committer_date": "2006-04-06T09:44:35+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "17d7cfe350073ca04a17f76323fe813e361d74de" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 2, + "insertions": 10, + "lines": 12, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "numpy/core/src/multiarraymodule.c", + "new_path": "numpy/core/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -1839,7 +1839,7 @@ static int\n _new_sort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n {\n \tPyArrayIterObject *it;\n-\tint needcopy=0;\n+\tint needcopy=0, swap;\n \tintp N, size;\n \tint elsize;\n \tintp astride;\n@@ -1847,6 +1847,7 @@ _new_sort(PyArrayObject *op, int axis, PyArray_SORTKIND which)\n \tBEGIN_THREADS_DEF \n \n \tit = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, axis);\n+\tswap = !PyArray_ISNOTSWAPPED(op);\n \tif (it == NULL) return -1;\n \n \tBEGIN_THREADS\n@@ -1856,7 +1857,8 @@ _new_sort(PyArrayObject *op, int axis, PyArray_SORTKIND which)\n \telsize = op->descr->elsize;\n \tastride = op->strides[axis];\n \n-\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize);\n+\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) \\\n+\t\t|| swap;\n \n \tif (needcopy) {\n \t\tchar *buffer;\n@@ -1864,9 +1866,15 @@ _new_sort(PyArrayObject *op, int axis, PyArray_SORTKIND which)\n \t\twhile (size--) {\n \t\t\t_strided_copy(buffer, (intp) elsize, it->dataptr, \n \t\t\t\t astride, N, elsize);\n+\t\t\tif (swap) {\n+\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);\n+\t\t\t}\n \t\t\tif (sort(buffer, N, op) < 0) {\n \t\t\t\tPyDataMem_FREE(buffer); goto fail;\n \t\t\t}\n+\t\t\tif (swap) {\n+\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);\n+\t\t\t}\t\t\t\n \t\t\t_strided_copy(it->dataptr, astride, buffer, \n \t\t\t\t (intp) elsize, N, elsize);\n \t\t\tPyArray_ITER_NEXT(it);\n", + "added_lines": 10, + "deleted_lines": 2, + "source_code": "/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified extensively for numpy in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"numpy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\nstatic PyObject *_numpy_internal=NULL; /* A Python module for callbacks */\nstatic int _multiarray_module_loaded=0;\n\n\nstatic PyArray_Descr *\n_arraydescr_fromobj(PyObject *obj)\n{\n\tPyObject *dtypedescr;\n\tPyArray_Descr *new;\n\tint ret;\n\t\n\tdtypedescr = PyObject_GetAttrString(obj, \"dtype\");\n\tPyErr_Clear();\n\tif (dtypedescr) {\n\t\tret = PyArray_DescrConverter(dtypedescr, &new);\n\t\tPy_DECREF(dtypedescr);\n\t\tif (ret) return new;\n\t\tPyErr_Clear();\n\t}\n\treturn NULL;\n}\n\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\n/*MULTIARRAY_API\n Multiply a List of ints\n*/\nstatic int\nPyArray_MultiplyIntList(register int *l1, register int n) \n{\n\tregister int s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Multiply a List\n*/\nstatic intp \nPyArray_MultiplyList(register intp *l1, register int n) \n{\n\tregister intp s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Produce a pointer into array\n*/\nstatic void *\nPyArray_GetPtr(PyArrayObject *obj, register intp* ind)\n{\n\tregister int n = obj->nd;\n\tregister intp *strides = obj->strides;\n\tregister char *dptr = obj->data;\n\t\n\twhile (n--) dptr += (*strides++) * (*ind++);\n\treturn (void *)dptr;\n}\n\n/*MULTIARRAY_API\n Get axis from an object (possibly None) -- a converter function,\n*/\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Compare Lists\n*/\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;iob_type;\n\t\n\tPy_INCREF(self->descr);\n\tnew = PyArray_NewFromDescr(subtype,\n\t\t\t\t self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides,\n\t\t\t\t self->data,\n\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (new==NULL) return NULL;\n\tPy_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n\t\n\tif (type != NULL) {\n\t\tif (PyObject_SetAttrString(new, \"dtype\",\n\t\t\t\t\t (PyObject *)type) < 0) {\n\t\t\tPy_DECREF(new);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tPy_DECREF(type);\n\t}\n\treturn new;\t\n}\n\n/*MULTIARRAY_API\n Ravel\n*/\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, PyArray_ORDER fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n if (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(a); \n \n\tnewdim.ptr = val; \n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) { \n\t\treturn PyArray_Newshape(a, &newdim, PyArray_CORDER); \n\t} \n\telse if (fortran && PyArray_ISFORTRAN(a)) { \n\t\treturn PyArray_Newshape(a, &newdim, PyArray_FORTRANORDER); \n\t} \n\telse \n\t\treturn PyArray_Flatten(a, fortran); \n}\n\nstatic double\npower_of_ten(int n)\n{\n\tstatic const double p10[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};\n\tdouble ret;\n\tif (n < 9)\n\t\tret = p10[n];\n\telse {\n\t\tret = 1e9;\n\t\twhile (n-- > 9)\n\t\t\tret *= 10.;\n\t}\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Round\n*/\nstatic PyObject *\nPyArray_Round(PyArrayObject *a, int decimals)\n{\n\tif (PyArray_ISCOMPLEX(a)) {\n\t\tPyObject *part;\n\t\tPyObject *round_part;\n\t\tPyObject *new;\n\t\tint res;\n\t\tnew = PyArray_Copy(a);\n\t\tif (new == NULL) return NULL;\n\n\t\t/* new.real = a.real.round(decimals) */\n\t\tpart = PyObject_GetAttrString(new, \"real\");\n\t\tif (part == NULL) {Py_DECREF(new); return NULL;}\n\t\tround_part = PyArray_Round\\\n\t\t\t((PyArrayObject *)PyArray_EnsureAnyArray(part), \n\t\t\t decimals);\n\t\tPy_DECREF(part);\n\t\tif (round_part == NULL) {Py_DECREF(new); return NULL;}\n\t\tres = PyObject_SetAttrString(new, \"real\", round_part);\n\t\tPy_DECREF(round_part);\n\t\tif (res < 0) {Py_DECREF(new); return NULL;}\n\n\t\t/* new.imag = a.imag.round(decimals) */\n\t\tpart = PyObject_GetAttrString(new, \"imag\");\n\t\tif (part == NULL) {Py_DECREF(new); return NULL;}\n\t\tround_part = PyArray_Round\\\n\t\t\t((PyArrayObject *)PyArray_EnsureAnyArray(part), \n\t\t\t decimals);\n\t\tPy_DECREF(part);\n\t\tif (round_part == NULL) {Py_DECREF(new); return NULL;}\n\t\tres = PyObject_SetAttrString(new, \"imag\", round_part);\n\t\tPy_DECREF(round_part);\n\t\tif (res < 0) {Py_DECREF(new); return NULL;}\n\t\treturn new;\n\t}\n\t/* do the most common case first */\n\tif (decimals == 0) {\n\t\tif (PyArray_ISINTEGER(a)) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_GenericUnaryFunction((PyAO *)a, n_ops.rint);\n\t}\n\tif (decimals > 0) {\n\t\tPyObject *f, *ret;\n\t\tif (PyArray_ISINTEGER(a)) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\tf = PyFloat_FromDouble(power_of_ten(decimals));\n\t\tif (f==NULL) return NULL;\n\t\tret = PyNumber_Multiply((PyObject *)a, f);\n\t\tif (ret==NULL) {Py_DECREF(f); return NULL;}\n\t\tif (PyArray_IsScalar(ret, Generic)) {\n\t\t\t/* array scalars cannot be modified inplace */\n\t\t\tPyObject *tmp;\n\t\t\ttmp = PyObject_CallFunction(n_ops.rint, \"O\", ret);\n\t\t\tPy_DECREF(ret);\n\t\t\tret = PyObject_CallFunction(n_ops.divide, \"OO\", \n\t\t\t\t\t\t tmp, f);\n\t\t\tPy_DECREF(tmp);\n\t\t} else {\n\t\t\tPyObject_CallFunction(n_ops.rint, \"OO\", ret, ret);\n\t\t\tPyObject_CallFunction(n_ops.divide, \"OOO\", ret, \n\t\t\t\t\t f, ret);\n\t\t}\n\t\tPy_DECREF(f);\n\t\treturn ret;\n\t} \n\telse {\n\t\t/* remaining case: decimals < 0 */\n\t\tPyObject *f, *ret;\n\t\tf = PyFloat_FromDouble(power_of_ten(-decimals));\n\t\tif (f==NULL) return NULL;\n\t\tret = PyNumber_Divide((PyObject *)a, f);\n\t\tif (ret==NULL) {Py_DECREF(f); return NULL;}\n\t\tif (PyArray_IsScalar(ret, Generic)) {\n\t\t\t/* array scalars cannot be modified inplace */\n\t\t\tPyObject *tmp;\n\t\t\ttmp = PyObject_CallFunction(n_ops.rint, \"O\", ret);\n\t\t\tPy_DECREF(ret);\n\t\t\tret = PyObject_CallFunction(n_ops.multiply, \"OO\", \n\t\t\t\t\t\t tmp, f);\n\t\t\tPy_DECREF(tmp);\n\t\t} else {\n\t\t\tPyObject_CallFunction(n_ops.rint, \"OO\", ret, ret);\n\t\t\tPyObject_CallFunction(n_ops.multiply, \"OOO\", ret, \n\t\t\t\t\t f, ret);\n\t\t}\n\t\tPy_DECREF(f);\n\t\treturn ret;\n\t}\n}\n\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, PyArray_ORDER fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(a);\n\n\tsize = PyArray_SIZE(a);\n\tPy_INCREF(a->descr);\n\tret = PyArray_NewFromDescr(a->ob_type,\n\t\t\t\t a->descr,\n\t\t\t\t 1, &size,\n\t\t\t\t NULL,\n\t\t\t\t NULL,\n\t\t\t\t 0, (PyObject *)a);\n\t\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\n/*MULTIARRAY_API\n Reshape an array\n*/\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims, PyArray_CORDER);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\nstatic int\n_check_ones(PyArrayObject *self, int newnd, intp* newdims, intp *strides)\n{\n\tint nd;\n\tintp *dims;\n\tBool done=FALSE;\n\tint j, k;\n\n\tnd = self->nd;\n\tdims = self->dimensions;\n\n\tfor (k=0, j=0; !done && (jstrides[j];\n\t\t\tj++; k++;\n\t\t}\n\t\telse if ((kptr;\n\tn = newshape->len;\t\n\ts_known = 1;\n\ti_unknown = -1;\n\t\n\tfor(i=0; i= 0) {\n\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tdimensions[i_unknown] = s_original/s_known;\n\t} else {\n\t\tif (s_original != s_known) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\treturn -1;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/* Returns a new array \n with the new shape from the data\n in the old array --- order-perspective depends on fortran argument.\n copy-if-necessary\n*/\n\n/*MULTIARRAY_API\n New shape for an array\n*/\nstatic PyObject * \nPyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims, \n\t\t PyArray_ORDER fortran)\n{\n intp i;\n\tintp *dimensions = newdims->ptr;\n PyArrayObject *ret;\n\tint n = newdims->len;\n Bool same, incref;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n\tif (fortran == PyArray_ANYORDER)\n\t\tfortran = PyArray_ISFORTRAN(self);\n\t\n /* Quick check to make sure anything actually needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && idescr->elsize;\n\t\t\tfor (i=1; idescr->elsize;\n\t\t\tfor (i=n-2; i>-1; i--) {\n\t\t\t\tif (strides[i] == 0)\n\t\t\t\t\tstrides[i] = strides[i+1] *\t\\\n\t\t\t\t\t\tdimensions[i+1];\n\t\t\t}\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = (PyAO *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t self->descr,\n\t\t\t\t\t n, dimensions,\n\t\t\t\t\t strides,\n\t\t\t\t\t self->data,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (ret== NULL) goto fail;\n\t\n if (incref) Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n\t\n fail:\n\tif (!incref) {Py_DECREF(self);}\n\treturn NULL;\n}\n\n\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\n/*MULTIARRAY_API*/\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t self->descr,\n\t\t\t\t newnd, dimensions, \n\t\t\t\t strides, self->data, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPyArray_FLAGS(ret) &= ~OWN_DATA;\n\tPyArray_BASE(ret) = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\n/*MULTIARRAY_API\n Mean\n*/\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\n/* Set variance to 1 to by-pass square-root calculation and return variance */\n/*MULTIARRAY_API\n Std\n*/\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype, int variance)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"condition must be 1-d array\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Nonzero\n*/\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t (PyObject *)self);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\tPy_DECREF(it);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\n/*MULTIARRAY_API\n Clip\n*/\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) {\n\t\tPy_DECREF(two);\n\t\tPy_XDECREF(res1);\n\t\tPy_XDECREF(res2);\n\t}\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two); \n\tPy_DECREF(res1); \n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) {Py_DECREF(selector); return NULL;}\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Conjugate\n*/\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_NewCopy(self, -1);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\n/*MULTIARRAY_API\n Trace\n*/\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Diagonal\n*/\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyArray_Dims newaxes;\n\tintp dims[MAX_DIMS];\n\tint i, pos;\t\n\n\tnewaxes.ptr = dims;\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes.len = n;\n\t/* insert at the end */\n\tnewaxes.ptr[n-2] = axis1;\n\tnewaxes.ptr[n-1] = axis2;\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr;\n\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"C arrays of only 1-3 dimensions available\");\n\t\tPy_XDECREF(typedescr);\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, typedescr, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS, NULL)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)_pya_malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"no memory\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\n/*MULTIARRAY_API\n Convert to a 1D C-array\n*/\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n/*MULTIARRAY_API\n Convert to a 2D C-array\n*/\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\n/*MULTIARRAY_API\n Free pointers created if As2D is called\n*/\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\t_pya_free(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tif (mps[i]->ob_type != subtype) {\n\t\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\t\tif (prior2 > prior1) {\n\t\t\t\tprior1 = prior2;\n\t\t\t\tsubtype = mps[i]->ob_type;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0-d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t mps[0]->descr, nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis1 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis2 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tnew_axes.ptr = dims;\n\tnew_axes.len = n;\n\n\tfor (i=0; ind;\n\t\tfor(i=0; ilen;\n\t\taxes = permute->ptr;\n\t\tif (n > ap->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many axes for this array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tPy_INCREF(ap->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t ap->descr, \n\t\t\t\t n, permutation, \n\t\t\t\t NULL, ap->data, ap->flags,\n\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) return NULL;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\t\n\n\treturn (PyObject *)ret;\t\n}\n\n/*MULTIARRAY_API\n Repeat the array.\n*/\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)\n{\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromAny(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tPy_INCREF(aop->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(aop->ob_type, \n\t\t\t\t\t\t aop->descr,\n\t\t\t\t\t\t aop->nd,\n\t\t\t\t\t\t aop->dimensions,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->descr->elsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; idescr->elsize;\n\tbyteorder = arr->descr->byteorder;\n\tptr = arr->data;\n\tif (elsize > 1 && \\\n\t (byteorder == PyArray_LITTLE ||\t\\\n\t (byteorder == PyArray_NATIVE &&\n\t PyArray_ISNBO(PyArray_LITTLE))))\n\t\tptr += elsize-1;\n\t\n\treturn ((*ptr & bitmask) != 0);\t\n}\n\n\n/*OBJECT_API*/\nstatic PyArray_SCALARKIND\nPyArray_ScalarKind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) {\n\t\tif (arr && _signbit_set(*arr)) return PyArray_INTNEG_SCALAR;\n\t\telse return PyArray_INTPOS_SCALAR;\n\t}\n\tif (PyTypeNum_ISFLOAT(typenum)) return PyArray_FLOAT_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return PyArray_INTPOS_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return PyArray_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return PyArray_BOOL_SCALAR;\n\n\treturn PyArray_OBJECT_SCALAR;\n}\n\n/*OBJECT_API*/\nstatic int \nPyArray_CanCoerceScalar(char thistype, char neededtype, \n\t\t\tPyArray_SCALARKIND scalar) \n{\n\n\tswitch(scalar) {\n\tcase PyArray_NOSCALAR:\n\tcase PyArray_BOOL_SCALAR:\n\tcase PyArray_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase PyArray_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase PyArray_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase PyArray_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase PyArray_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\n/* This needs to change to allow scalars of a different \"kind\" to alter the input type\n */\n\n/*OBJECT_API*/\nstatic PyArrayObject **\nPyArray_ConvertToCommonType(PyObject *op, int *retn)\n{\n\tint i, n, allscalars=0; \n\tPyArrayObject **mps=NULL;\n\tPyObject *otmp;\n\tPyArray_Descr *intype=NULL, *stype=NULL;\n\tPyArray_Descr *newtype=NULL;\n\tchar scalarkind;\n\n\t\n\t*retn = n = PySequence_Length(op);\n\tif (PyErr_Occurred()) {*retn = 0; return NULL;}\n\t\n\tmps = (PyArrayObject **)PyDataMem_NEW(n*sizeof(PyArrayObject *));\n\tif (mps == NULL) {\n\t\t*retn = 0;\n\t\treturn (void*)PyErr_NoMemory();\n\t}\n\t\n\tfor(i=0; itype_num, NULL);\n\t\t\tif (intype && !PyArray_CanCoerceScalar(newtype->type_num,\n\t\t\t\t\t\t\t intype->type_num, \n\t\t\t\t\t\t\t scalarkind)) {\n\t\t\t\tPy_XDECREF(intype);\n\t\t\t\tintype = stype;\n\t\t\t}\n\t\t\tmps[i] = (PyArrayObject *)Py_None;\n\t\t\tPy_INCREF(Py_None);\n\t\t}\n\t\tPy_XDECREF(otmp);\n\t}\n\tif (intype==NULL) { /* all scalars */\n\t\tallscalars = 1;\n\t\tintype = stype;\n\t\tPy_INCREF(intype);\n\t\tfor (i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t\t\t mps[0]->descr,\n\t\t\t\t\t\t ap->nd,\n\t\t\t\t\t\t ap->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->descr->elsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->f->sort[which];\n\tsize = it->size;\n\tN = op->dimensions[axis];\n\telsize = op->descr->elsize;\n\tastride = op->strides[axis];\n\n\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) \\\n\t\t|| swap;\n\n\tif (needcopy) {\n\t\tchar *buffer;\n\t\tbuffer = PyDataMem_NEW(N*elsize);\n\t\twhile (size--) {\n\t\t\t_strided_copy(buffer, (intp) elsize, it->dataptr, \n\t\t\t\t astride, N, elsize);\n\t\t\tif (swap) {\n\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);\n\t\t\t}\n\t\t\tif (sort(buffer, N, op) < 0) {\n\t\t\t\tPyDataMem_FREE(buffer); goto fail;\n\t\t\t}\n\t\t\tif (swap) {\n\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);\n\t\t\t}\t\t\t\n\t\t\t_strided_copy(it->dataptr, astride, buffer, \n\t\t\t\t (intp) elsize, N, elsize);\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tPyDataMem_FREE(buffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tif (sort(it->dataptr, N, op) < 0) goto fail;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\t\n\t\n\tEND_THREADS\n\t\n\tPy_DECREF(it);\n\treturn 0;\n\n fail:\n\tEND_THREADS\n\n\tPy_DECREF(it);\n\treturn 0;\n}\n\nstatic PyObject*\n_new_argsort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\n\tPyArrayIterObject *it=NULL;\n\tPyArrayIterObject *rit=NULL;\n\tPyObject *ret;\n\tint needcopy=0, i;\n\tintp N, size;\n\tint elsize;\n\tintp astride, rstride, *iptr;\n\tPyArray_ArgSortFunc *argsort;\n\tBEGIN_THREADS_DEF \n\n\tret = PyArray_New(op->ob_type, op->nd,\n\t\t\t op->dimensions, PyArray_INTP,\n\t\t\t NULL, NULL, 0, 0, (PyObject *)op);\n\tif (ret == NULL) return NULL;\n\n\tit = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, axis);\n\trit = (PyArrayIterObject *)PyArray_IterAllButAxis(ret, axis);\n\tif (rit == NULL || it == NULL) goto fail;\n\n\tBEGIN_THREADS\n\n\targsort = op->descr->f->argsort[which];\n\tsize = it->size;\n\tN = op->dimensions[axis];\n\telsize = op->descr->elsize;\n\tastride = op->strides[axis];\n\trstride = PyArray_STRIDE(ret,axis);\n\n\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) || \\\n\t\t(rstride != sizeof(intp));\n\t\n\tif (needcopy) {\n\t\tchar *valbuffer, *indbuffer;\n\t\tvalbuffer = PyDataMem_NEW(N*(elsize+sizeof(intp)));\n\t\tindbuffer = valbuffer + (N*elsize);\n\t\twhile (size--) {\n\t\t\t_strided_copy(valbuffer, (intp) elsize, it->dataptr,\n\t\t\t\t astride, N, elsize);\n\t\t\tiptr = (intp *)indbuffer;\n\t\t\tfor (i=0; idataptr, rstride, indbuffer, \n\t\t\t\t sizeof(intp), N, sizeof(intp));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t\tPyDataMem_FREE(valbuffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)rit->dataptr;\n\t\t\tfor (i=0; idataptr, (intp *)rit->dataptr, \n\t\t\t\t N, op) < 0) goto fail;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t}\n\t\n\tEND_THREADS\n\n\tPy_DECREF(it);\n\tPy_DECREF(rit);\n\treturn ret;\n\n fail:\n\n\tEND_THREADS\n\n\tPy_DECREF(ret);\n\tPy_XDECREF(it);\n\tPy_XDECREF(rit);\n\treturn NULL;\n}\n\n\n/* Be sure to save this global_compare when necessary */\n\nstatic PyArrayObject *global_obj;\n\nstatic int \nqsortCompare (const void *a, const void *b) \n{\n\treturn global_obj->descr->f->compare(a,b,global_obj);\n}\n\n/* Consumes reference to ap (op gets it)\n op contains a version of the array with axes swapped if\n local variable axis is not the last dimension.\n orign must be defined locally. \n*/\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/* Consumes reference to ap (op gets it)\n origin must be previously defined locally. \n SWAPAXES must have been called previously. \n op contains the swapped version of the array. \n*/\n#define SWAPBACK(op, ap) {\t \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/* These swap axes in-place if necessary */\n#define SWAPINTP(a,b) {intp c; c=(a); (a) = (b); (b) = c;}\n#define SWAPAXES2(ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\tSWAPINTP(ap->dimensions[axis], ap->dimensions[orign]); \\\n\t\t\tSWAPINTP(ap->strides[axis], ap->strides[orign]); \\\n\t\t\tPyArray_UpdateFlags(ap, CONTIGUOUS | FORTRAN); \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\n#define SWAPBACK2(ap) {\t\t \\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\tSWAPINTP(ap->dimensions[axis], ap->dimensions[orign]); \\\n\t\t\tSWAPINTP(ap->strides[axis], ap->strides[orign]); \\\n\t\t\tPyArray_UpdateFlags(ap, CONTIGUOUS | FORTRAN);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\n/*MULTIARRAY_API\n Sort an array in-place\n*/\nstatic int\nPyArray_Sort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tn = op->nd;\n\tif ((n==0) || (PyArray_SIZE(op)==1)) return 0;\n\n\tif (axis < 0) axis += n;\n\tif ((axis < 0) || (axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\treturn -1;\n\t}\n\tif (!PyArray_ISWRITEABLE(op)) {\n\t\tPyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"attempted sort on unwriteable array.\");\n\t\treturn -1;\n\t}\n\n\t/* Determine if we should use type-specific algorithm or not */\n\tif (op->descr->f->sort[which] != NULL) {\n\t\treturn _new_sort(op, axis, which);\n\t}\n\n\tif ((which != PyArray_QUICKSORT) || \\\n\t op->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"desired sort not supported for this type\");\n\t\treturn -1;\n\t}\n\n\tSWAPAXES2(op);\n\n ap = (PyArrayObject *)PyArray_FromAny((PyObject *)op, \n\t\t\t\t\t NULL, 1, 0, \n\t\t\t\t\t DEFAULT_FLAGS | UPDATEIFCOPY, NULL);\t\n\tif (ap == NULL) goto fail;\n\t\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; idescr->elsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->f->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\n/*MULTIARRAY_API\n ArgSort an array\n*/\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\tPyArrayObject *ap=NULL, *ret=NULL, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tn = op->nd;\n\tif ((n==0) || (PyArray_SIZE(op)==1)) {\n\t\tret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,\n\t\t\t\t\t\t op->dimensions, \n\t\t\t\t\t\t PyArray_INTP,\n\t\t\t\t\t\t NULL, NULL, 0, 0, \n\t\t\t\t\t\t (PyObject *)op);\n\t\tif (ret == NULL) return NULL;\n\t\t*((intp *)ret->data) = 0;\n\t\treturn (PyObject *)ret;\n\t}\n\tif (axis < 0) axis += n;\n\tif ((axis < 0) || (axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\treturn NULL;\n\t}\n\n\t/* Determine if we should use new algorithm or not */\n\tif (op->descr->f->argsort[which] != NULL) {\n\t\treturn _new_argsort(op, axis, which);\n\t}\n\n\tif ((which != PyArray_QUICKSORT) || op->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"requested sort not available for type\");\n\t\tgoto fail;\n\t}\n\n\tSWAPAXES(ap, op);\n\n\top = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)ap, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\n\tif (op == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,\n\t\t\t\t\t op->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)op);\n\tif (ret == NULL) goto fail;\n\t\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = op->descr->elsize;\n\tm = op->dimensions[op->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(op)/m;\n\tstore_ptr = global_data;\n\tglobal_data = op->data;\n\tstore = global_obj;\n\tglobal_obj = op;\n\tfor (i=0; i 0 in lexsort\");\n\t\treturn NULL;\n\t}\n\tmps = (PyArrayObject **) _pya_malloc(n*sizeof(PyArrayObject));\n\tif (mps==NULL) return PyErr_NoMemory();\n\tits = (PyArrayIterObject **) _pya_malloc(n*sizeof(PyArrayIterObject));\n\tif (its == NULL) {_pya_free(mps); return PyErr_NoMemory();}\n\tfor (i=0; i0) {\n\t\t\tif ((mps[i]->nd != mps[0]->nd) ||\t\\\n\t\t\t (!PyArray_CompareLists(mps[i]->dimensions,\n\t\t\t\t\t\t mps[0]->dimensions,\n\t\t\t\t\t\t mps[0]->nd))) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"all keys need to be the same shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (!mps[i]->descr->f->argsort[PyArray_MERGESORT]) {\n\t\t\tPyErr_Format(PyExc_TypeError, \n\t\t\t\t \"merge sort not available for item %d\", i);\n\t\t\tgoto fail;\n\t\t}\n\t\tits[i] = (PyArrayIterObject *)PyArray_IterAllButAxis\t\\\n\t\t\t((PyObject *)mps[i], axis);\n\t\tif (its[i]==NULL) goto fail;\n\t}\n\n\t/* Now we can check the axis */\n\tnd = mps[0]->nd;\n\tif ((nd==0) || (PyArray_SIZE(mps[0])==1)) {\n\t\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t PyArray_INTP,\n\t\t\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t\tif (ret == NULL) return NULL;\n\t\t*((intp *)(ret->data)) = 0;\n\t\treturn (PyObject *)ret;\n\t}\n\tif (axis < 0) axis += nd;\n\tif ((axis < 0) || (axis >= nd)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\tgoto fail;\n\t}\n\n\t/* Now do the sorting */\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,\n\t\t\t\t\t mps[0]->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (ret == NULL) goto fail;\n\n\trit = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ret, axis);\n\tif (rit == NULL) goto fail;\n\n\tsize = rit->size;\n\tN = mps[0]->dimensions[axis];\n\trstride = PyArray_STRIDE(ret,axis);\n\n maxelsize = mps[0]->descr->elsize;\n\tneedcopy = (rstride != sizeof(intp));\n\tfor (j=0; jflags & ALIGNED) || \\\n\t\t\t(mps[j]->strides[axis] != (intp)mps[j]->descr->elsize);\n if (mps[j]->descr->elsize > maxelsize) \n maxelsize = mps[j]->descr->elsize;\n\t}\n\n\tif (needcopy) {\n\t\tchar *valbuffer, *indbuffer;\n\t\tvalbuffer = PyDataMem_NEW(N*(maxelsize+sizeof(intp)));\n\t\tindbuffer = valbuffer + (N*maxelsize);\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)indbuffer;\n\t\t\tfor (i=0; idescr->elsize;\n\t\t\t\tastride = mps[j]->strides[axis];\t\n\t\t\t\targsort = mps[j]->descr->f->argsort[PyArray_MERGESORT];\n\t\t\t\t_strided_copy(valbuffer, (intp) elsize, its[j]->dataptr,\n\t\t\t\t\t astride, N, elsize);\n\t\t\t\tif (argsort(valbuffer, (intp *)indbuffer, N, mps[j]) < 0) {\n\t\t\t\t\tPyDataMem_FREE(valbuffer); goto fail;\n\t\t\t\t}\n\t\t\t\tPyArray_ITER_NEXT(its[j]);\n\t\t\t}\n\t\t\t_strided_copy(rit->dataptr, rstride, indbuffer,\n\t\t\t\t sizeof(intp), N, sizeof(intp));\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t\tPyDataMem_FREE(valbuffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)rit->dataptr;\n\t\t\tfor (i=0; idescr->f->argsort[PyArray_MERGESORT];\n\t\t\t\tif (argsort(its[j]->dataptr, (intp *)rit->dataptr,\n\t\t\t\t\t N, mps[j]) < 0) goto fail;\n\t\t\t\tPyArray_ITER_NEXT(its[j]);\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t}\n\n\tfor (i=0; idescr->f->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->descr->elsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_SIZE(ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\n/*MULTIARRAY_API\n Numeric.searchsorted(a,v)\n*/\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n/*\n Make a new empty array, of the passed size, of a type that takes the\n priority of ap1 and ap2 into account.\n */\nstatic PyArrayObject *\nnew_array_for_sum(PyArrayObject *ap1, PyArrayObject *ap2,\n\t\t int nd, intp dimensions[], int typenum)\n{\n\tPyArrayObject *ret;\n\tPyTypeObject *subtype;\n\tdouble prior1, prior2;\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tif (ap2->ob_type != ap1->ob_type) {\n\t\tprior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n\t\tprior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n\n\t\tsubtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\t} else {\n\t\tprior1 = prior2 = 0.0;\n\t\tsubtype = ap1->ob_type;\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\treturn ret;\n}\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\n/*MULTIARRAY_API\n Numeric.innerproduct(a,v)\n*/\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tPyArrayIterObject *it1, *it2;\n\tintp i, j, l;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\tPyArray_Descr *typec;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\n\ttypec = PyArray_DescrFromType(typenum);\n\tPy_INCREF(typec);\n\tap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, \n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap1 == NULL) {Py_DECREF(typec); return NULL;}\n\tap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,\n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->f->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tit1 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap1, ap1->nd-1);\n\tit2 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap2, ap2->nd-1);\n\n\twhile(1) {\n\t\twhile(it2->index < it2->size) {\n\t\t\tdot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);\n\t\t\top += os;\n\t\t\tPyArray_ITER_NEXT(it2);\n\t\t}\n\t\tPyArray_ITER_NEXT(it1);\n\t\tif (it1->index >= it1->size) break;\n\t\tPyArray_ITER_RESET(it2);\n\t}\n\tPy_DECREF(it1);\n\tPy_DECREF(it2);\n\n\tif (PyErr_Occurred()) goto fail;\n\t\t\n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n/* just like inner product but does the swapaxes stuff on the fly */\n/*MULTIARRAY_API\n Numeric.matrixproduct(a,v)\n*/\nstatic PyObject *\nPyArray_MatrixProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tPyArrayIterObject *it1, *it2;\n\tintp i, j, l;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\tintp matchDim;\n\tPyArray_Descr *typec;\n\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\t\n\t\n\ttypec = PyArray_DescrFromType(typenum);\n\tPy_INCREF(typec);\n\tap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, \n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap1 == NULL) {Py_DECREF(typec); return NULL;}\n\tap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,\n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; istrides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\n /* Choose which subtype to return */\n\tret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);\n\tif (ret == NULL) goto fail;\n\n\t/* Ensure that multiarray.dot([],[]) -> 0 */\n\tmemset(PyArray_DATA(ret), 0, PyArray_ITEMSIZE(ret));\n\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\top = ret->data; os = ret->descr->elsize;\n\n\tit1 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap1, ap1->nd-1);\n\tit2 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap2, matchDim);\n\n\twhile(1) {\n\t\twhile(it2->index < it2->size) {\n\t\t\tdot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);\n\t\t\top += os;\n\t\t\tPyArray_ITER_NEXT(it2);\n\t\t}\n\t\tPyArray_ITER_NEXT(it1);\n\t\tif (it1->index >= it1->size) break;\n\t\tPyArray_ITER_RESET(it2);\n\t}\n\tPy_DECREF(it1);\n\tPy_DECREF(it2);\n\tif (PyErr_Occurred()) goto fail; /* only for OBJECT arrays */\n\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n/*MULTIARRAY_API\n Fast Copy and Transpose\n*/\nstatic PyObject *\nPyArray_CopyAndTranspose(PyObject *op) \n{\n\tPyObject *ret, *arr;\n\tint nd;\n\tintp dims[2];\n\tintp i,j;\n\tint elsize, str2;\n\tchar *iptr;\n\tchar *optr;\n\n\t/* make sure it is well-behaved */\n\tarr = PyArray_FromAny(op, NULL, 0, 0, CARRAY_FLAGS, NULL);\n\tnd = PyArray_NDIM(arr);\n\tif (nd == 1) { /* we will give in to old behavior */\n\t\tret = PyArray_Copy((PyArrayObject *)arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\t\t\n\t}\n\telse if (nd != 2) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"only 2-d arrays are allowed\");\n\t\treturn NULL;\n\t}\n\n\t/* Now construct output array */\n\tdims[0] = PyArray_DIM(arr,1);\n\tdims[1] = PyArray_DIM(arr,0);\n\telsize = PyArray_ITEMSIZE(arr);\n\t\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(arr->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t 2, dims, \n\t\t\t\t NULL, NULL, 0, arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[0];\n\tn2 = ap2->dimensions[0];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (intp)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0, 1, or 2\");\n\t\tgoto fail;\n\t}\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tret = new_array_for_sum(ap1, ap2, 1, &length, typenum);\n\tif (ret == NULL) goto fail;\n\t\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this data type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[0]; is2 = ap2->strides[0];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Min\n*/\nstatic PyObject *\nPyArray_Min(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tret = PyArray_GenericReduceFunction(arr, n_ops.minimum, axis,\n\t\t\t\t\t arr->descr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Ptp\n*/\nstatic PyObject *\nPyArray_Ptp(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\tPyObject *obj1=NULL, *obj2=NULL;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tobj1 = PyArray_Max(arr, axis);\n\tif (obj1 == NULL) goto fail;\n\tobj2 = PyArray_Min(arr, axis);\n\tif (obj2 == NULL) goto fail;\n\tPy_DECREF(arr);\n\tret = PyNumber_Subtract(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(obj1);\n\tPy_XDECREF(obj2);\n\treturn NULL;\n}\n\n\n/*MULTIARRAY_API\n ArgMax\n*/\nstatic PyObject *\nPyArray_ArgMax(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *rp=NULL;\n\tPyArray_ArgFunc* arg_func;\n\tchar *ip;\n\tintp *rptr;\n\tintp i, n, orign, m;\n\tint elsize;\n\t\n\tif ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t PyArray_NOTYPE, 1, 0);\n\n\tPy_DECREF(op);\n\tif (ap == NULL) return NULL;\n\t\n\targ_func = ap->descr->f->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, \n (PyObject *)ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n\tPy_INCREF(self->descr);\n ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t nd, shape, \n\t\t\t\t\t\t NULL, NULL, 0, \n\t\t\t\t\t\t (PyObject *)self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->descr->elsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array\n*/\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject* values0, PyObject *indices0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromAny(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n\tthistype = self->descr->type_num;\n Py_INCREF(self->descr); \n\tvalues = (PyArrayObject *)PyArray_FromAny(values0, self->descr, 0, 0, \n\t\t\t\t\t\t DEFAULT_FLAGS | FORCECAST, NULL); \n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n if (thistype == PyArray_OBJECT) { \n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n Py_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+tmp*chunk)));\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array according to a mask.\n*/\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_FROM_OTF(mask0, PyArray_BOOL, CARRAY_FLAGS | FORCECAST);\n\tif (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n if (thistype == PyArray_OBJECT) {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+i*chunk)));\n memmove(dest + i * chunk, src, chunk);\n }\n\t\t\t}\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) memmove(dest + i * chunk, src, chunk);\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \n/*MULTIARRAY_API\n Useful to pass as converter function for O& processing in\n PyArgs_ParseTuple.\n*/\nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS, NULL);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\n/*MULTIARRAY_API\n Convert an object to true / false\n*/\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{ \n\tif (PyObject_IsTrue(object))\n\t\t*val=TRUE;\n\telse *val=FALSE;\n\tif (PyErr_Occurred())\n\t\treturn PY_FAIL;\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Convert an object to FORTRAN / C / ANY\n*/\nstatic int\nPyArray_OrderConverter(PyObject *object, PyArray_ORDER *val)\n{\n char *str;\n if (object == Py_None) {\n *val = PyArray_ANYORDER;\n }\n else if (!PyString_Check(object) || PyString_GET_SIZE(object) < 1) {\n if (PyObject_IsTrue(object))\n *val = PyArray_FORTRANORDER;\n else\n *val = PyArray_CORDER;\n if (PyErr_Occurred())\n return PY_FAIL;\n return PY_SUCCEED;\n }\n else {\n str = PyString_AS_STRING(object);\n if (str[0] == 'C' || str[0] == 'c') {\n *val = PyArray_CORDER; \n }\n if (str[0] == 'F' || str[0] == 'f') {\n *val = PyArray_FORTRANORDER;\n }\n if (str[0] == 'A' || str[0] == 'a') {\n *val = PyArray_ANYORDER;\n }\n }\n return PY_SUCCEED;\n}\n\n\n/*MULTIARRAY_API\n Typestr converter\n*/\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_GENBOOLLTR) {\n\t\tif (itemsize == 1)\n\t\t\tnewtype = PyArray_BOOL;\n\t\telse \n\t\t\tnewtype = PyArray_NOTYPE;\n\t}\n\telse if (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\n/*MULTIARRAY_API\n Get buffer chunk from object\n*/\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = BEHAVED_FLAGS;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\n/*MULTIARRAY_API\n Get intp chunk from sequence\n*/\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"sequence too large; \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) {\n\t\tPyDimMem_FREE(seq->ptr);\n\t\tseq->ptr=NULL;\n\t\treturn PY_FAIL;\n\t}\n return PY_SUCCEED;\n}\n\n\n/* A tuple type would be either (generic typeobject, typesize) \n or (fixed-length data-type, shape) \n\n or (inheriting data-type, new-data-type)\n The new data-type must have the same itemsize as the inheriting data-type\n unless the latter is 0 \n \n Thus (int32, {'real':(int16,0),'imag',(int16,2)})\n\n is one way to specify a descriptor that will give \n a['real'] and a['imag'] to an int32 array.\n*/\n\n/* leave type reference alone */\nstatic PyArray_Descr *\n_use_inherit(PyArray_Descr *type, PyObject *newobj, int *errflag) \n{\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\t*errflag = 0;\n\tif (!PyArray_DescrConverter(newobj, &conv)) {\n\t\treturn NULL;\n\t}\n\t*errflag = 1;\n\tif (type == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"cannot base a new descriptor on an\"\\\n\t\t\t\t\" OBJECT descriptor.\");\n\t\tgoto fail;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) goto fail;\n\n\tif (new->elsize && new->elsize != conv->elsize) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mismatch in size of old\"\\\n\t\t\t\t\"and new data-descriptor\");\n\t\tgoto fail;\n\t}\n\tnew->elsize = conv->elsize;\n\tif (conv->fields != Py_None) {\n\t\tnew->fields = conv->fields;\n\t\tPy_XINCREF(new->fields);\n\t}\n\tPy_DECREF(conv);\n\t*errflag = 0;\n\treturn new;\n\n fail:\n\tPy_DECREF(conv);\n\treturn NULL;\n\n}\n\nstatic PyArray_Descr *\n_convert_from_tuple(PyObject *obj) \n{\n\tPyArray_Descr *type, *res;\n\tPyObject *val;\n\tint errflag;\n\t\n\tif (PyTuple_GET_SIZE(obj) != 2) return NULL;\n\n\tif (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj,0), &type)) \n\t\treturn NULL;\n\tval = PyTuple_GET_ITEM(obj,1);\n\t/* try to interpret next item as a type */\n\tres = _use_inherit(type, val, &errflag);\n\tif (res || errflag) {\n\t\tPy_DECREF(type);\n\t\tif (res) return res;\n\t\telse return NULL;\n\t}\n\tPyErr_Clear();\n\t/* We get here if res was NULL but errflag wasn't set\n\t --- i.e. the conversion to a data-descr failed in _use_inherit\n\t*/\n\n\tif (type->elsize == 0) { /* interpret next item as a typesize */\n\t\tint itemsize;\n\t\titemsize = PyArray_PyIntAsInt(PyTuple_GET_ITEM(obj,1));\n\t\tif (error_converting(itemsize)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid itemsize in generic type \"\\\n\t\t\t\t\t\"tuple\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(type);\n\t\tif (type->type_num == PyArray_UNICODE)\n\t\t\ttype->elsize = itemsize << 2; \n\t\telse\n\t\t\ttype->elsize = itemsize;\n\t}\n\telse {\n\t\t/* interpret next item as shape (if it's a tuple)\n\t\t and reset the type to PyArray_VOID with \n\t\t a new fields attribute. \n\t */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyArray_Descr *newdescr;\n\t\tif (!(PyArray_IntpConverter(val, &shape)) || \n\t\t (shape.len > MAX_DIMS)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid shape in fixed-type tuple.\");\n\t\t\tgoto fail;\n\t\t}\n\t\t/* If (type, 1) was given, it is equivalent to type... */\n\t\tif (shape.len == 1 && shape.ptr[0] == 1 && \\\n\t\t PyNumber_Check(val)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\treturn type;\n\t\t}\n\t\tnewdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tif (newdescr == NULL) {PyDimMem_FREE(shape.ptr); goto fail;}\n\t\tnewdescr->elsize = type->elsize;\n\t\tnewdescr->elsize *= PyArray_MultiplyList(shape.ptr, \n\t\t\t\t\t\t\t shape.len);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tnewdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tnewdescr->subarray->base = type;\n\t\tif (type->hasobject) newdescr->hasobject = 1;\n\t\tPy_INCREF(val);\n\t\tnewdescr->subarray->shape = val;\n\t\tPy_XDECREF(newdescr->fields);\n\t\tnewdescr->fields = NULL;\n\t\ttype = newdescr;\n\t}\n\treturn type;\n\n fail:\n\tPy_XDECREF(type);\n\treturn NULL;\n}\n\n/* obj is a list. Each item is a tuple with\n\n(field-name, data-type (either a list or a string), and an optional \n shape parameter).\n*/\nstatic PyArray_Descr *\n_convert_from_array_descr(PyObject *obj)\n{\n\tint n, i, totalsize;\n\tint ret;\n\tPyObject *fields, *item, *newobj;\n\tPyObject *name, *key, *tup, *title;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n int hasobject=0;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyTuple_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ihasobject)\n hasobject = 1;\n\t\ttup = PyTuple_New((title == NULL ? 2 : 3));\n\t\tPyTuple_SET_ITEM(tup, 0, (PyObject *)conv);\n\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));\n\t\tif (title != NULL) {\t\t\t\n\t\t\tPy_INCREF(title);\n\t\t\tPyTuple_SET_ITEM(tup, 2, title);\n\t\t\tPyDict_SetItem(fields, title, tup);\n\t\t}\n\t\tPyDict_SetItem(fields, name, tup);\n\t\ttotalsize += conv->elsize;\n\t\tPy_DECREF(tup);\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tnew->elsize = totalsize;\n new->hasobject=hasobject;\n\treturn new;\n \n fail:\n\tPy_DECREF(fields);\n\tPy_DECREF(nameslist);\n\treturn NULL;\n\n}\n\n/* a list specifying a data-type can just be\n a list of formats. The names for the fields\n will default to f1, f2, f3, and so forth.\n\n or it can be an array_descr format string -- in which case\n align must be 0. \n*/\n\nstatic PyArray_Descr *\n_convert_from_list(PyObject *obj, int align, int try_descr)\n{\n\tint n, i;\n\tint totalsize;\n\tPyObject *fields;\n\tPyArray_Descr *conv=NULL;\n\tPyArray_Descr *new;\n\tPyObject *key, *tup;\n\tPyObject *nameslist=NULL;\n \tint ret;\n\tint maxalign=0;\n int hasobject=0;\n\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyTuple_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ihasobject)\n\t\t\thasobject=1;\t\t\t\n\t\tPyTuple_SET_ITEM(tup, 0, (PyObject *)conv);\n\t\tif (align) {\n\t\t\tint _align;\n\t\t\t_align = conv->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign, _align);\n\t\t}\n\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));\n\t\tPyDict_SetItem(fields, key, tup);\n\t\tPy_DECREF(tup);\n\t\tPyTuple_SET_ITEM(nameslist, i, key);\n\t\ttotalsize += conv->elsize;\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n new->hasobject=hasobject;\n\tif (maxalign > 1) {\n\t\ttotalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;\n\t}\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\treturn new;\n\n fail:\n\tPy_DECREF(nameslist);\n\tPy_DECREF(fields);\n\tif (!try_descr) return NULL;\n\tif (align) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"failed to convert from list of formats \"\\\n\t\t\t\t\"and align cannot be 1 for conversion from \"\\\n\t\t\t\t\"array_descr structure\");\n\t\treturn NULL;\n\t}\n\tPyErr_Clear();\n\treturn _convert_from_array_descr(obj);\n}\n\n\n/* comma-separated string */\n/* this is the format developed by the numarray records module */\n/* and implemented by the format parser in that module */\n/* this is an alternative implementation found in the _internal.py \n file patterned after that one -- the approach is to try to convert \n to a list (with tuples if any repeat information is present) \n and then call the _convert_from_list)\n*/\n\nstatic PyArray_Descr *\n_convert_from_commastring(PyObject *obj, int align)\n{\n\tPyObject *listobj;\n\tPyArray_Descr *res;\n\n\tif (!PyString_Check(obj)) return NULL;\n listobj = PyObject_CallMethod(_numpy_internal, \"_commastring\",\n\t\t\t\t \"O\", obj);\n\tif (!listobj) return NULL;\n\tres = _convert_from_list(listobj, align, 0);\n\tPy_DECREF(listobj);\n\tif (!res && !PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ValueError, \"invalid data-type\");\n\t\treturn NULL;\n\t}\n\treturn res;\n}\n\n\n\n/* a dictionary specifying a data-type\n must have at least two and up to four\n keys These must all be sequences of the same length.\n\n \"names\" --- field names \n \"formats\" --- the data-type descriptors for the field.\n \n Optional:\n\n \"offsets\" --- integers indicating the offset into the \n record of the start of the field.\n\t\t if not given, then \"consecutive offsets\" \n\t\t will be assumed and placed in the dictionary.\n \n \"titles\" --- Allows the use of an additional key\n for the fields dictionary.\n \nAttribute-lookup-based field names merely has to query the fields \ndictionary of the data-descriptor. Any result present can be used\nto return the correct field.\n\nSo, the notion of what is a name and what is a title is really quite\narbitrary. \n\nWhat does distinguish a title, however, is that if it is not None, \nit will be placed at the end of the tuple inserted into the \nfields dictionary.\n\nIf the dictionary does not have \"names\" and \"formats\" entries,\nthen it will be checked for conformity and used directly. \n*/\n\nstatic PyArray_Descr *\n_use_fields_dict(PyObject *obj, int align)\n{\n return (PyArray_Descr *)PyObject_CallMethod(_numpy_internal, \n\t\t\t\t\t\t \"_usefields\", \n\t\t\t\t\t\t \"Oi\", obj, align);\n}\n\nstatic PyArray_Descr *\n_convert_from_dict(PyObject *obj, int align)\n{\n\tPyArray_Descr *new;\n\tPyObject *fields=NULL;\n\tPyObject *names, *offsets, *descrs, *titles, *key;\n\tint n, i;\n\tint totalsize;\n\tint maxalign=0;\n int hasobject=0;\n\t\n\tfields = PyDict_New();\n\tif (fields == NULL) return (PyArray_Descr *)PyErr_NoMemory();\n\t\n\tnames = PyDict_GetItemString(obj, \"names\");\n\tdescrs = PyDict_GetItemString(obj, \"formats\");\n\n\tif (!names || !descrs) {\n\t\tPy_DECREF(fields);\n\t\treturn _use_fields_dict(obj, align);\n\t}\n\tn = PyObject_Length(names);\n\toffsets = PyDict_GetItemString(obj, \"offsets\");\n\ttitles = PyDict_GetItemString(obj, \"titles\");\n\tif ((n > PyObject_Length(descrs)) ||\t\t\t\\\n\t (offsets && (n > PyObject_Length(offsets))) ||\t\\\n\t (titles && (n > PyObject_Length(titles)))) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"all items in the dictionary must have\" \\\n\t\t\t\t\" the same length.\");\n\t\tgoto fail;\n\t}\n\n\ttotalsize = 0;\n\tfor(i=0; i totalsize) totalsize = offset;\n\t\t}\n\t\telse {\n\t\t\tif (align) {\n\t\t\t\tint _align = newdescr->alignment;\n\t\t\t\tif (_align > 1) totalsize =\t\t\\\n\t\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\t\tmaxalign = MAX(maxalign,_align);\n\t\t\t}\n\t\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong(totalsize));\n\t\t}\n\t\tif (len == 3) PyTuple_SET_ITEM(tup, 2, item);\n\t\tname = PyObject_GetItem(names, index);\n\t\tPy_DECREF(index);\n\n\t\t/* Insert into dictionary */\n\t\tif (PyDict_GetItem(fields, name) != NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"name already used as a name or title\");\n\t\t\tret = PY_FAIL;\n\t\t}\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) {\n\t\t\tif (PyDict_GetItem(fields, item) != NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"title already used as a name or \" \\\n\t\t\t\t\t\t\" title.\");\n\t\t\t\tret=PY_FAIL;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPyDict_SetItem(fields, item, tup);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\n if (!hasobject && newdescr->hasobject)\n hasobject = 1;\n\t\ttotalsize += newdescr->elsize;\n\t}\n\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tif (new == NULL) goto fail;\n\tif (maxalign > 1)\n\t\ttotalsize = ((totalsize + maxalign - 1)/maxalign)*maxalign;\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\tkey = PyInt_FromLong(-1);\n if (!PyTuple_Check(names)) {\n names = PySequence_Tuple(names);\n PyDict_SetItem(fields, key, names);\n Py_DECREF(names);\n }\n else PyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\n new->hasobject=hasobject;\n\treturn new;\n\n fail:\n\tPy_XDECREF(fields);\n\treturn NULL;\n}\n\n/* \n any object with \n the .fields attribute and/or .itemsize attribute \n (if the .fields attribute does not give\n the total size -- i.e. a partial record naming).\n If itemsize is given it must be >= size computed from fields\n \n The .fields attribute must return a convertible dictionary if \n present. Result inherits from PyArray_VOID.\n*/\n\n\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to NULL\n*/\nstatic int\nPyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)\n{\n\tif (obj == Py_None) {\n\t\t*at = NULL;\n\t\treturn PY_SUCCEED;\n\t}\n\telse return PyArray_DescrConverter(obj, at);\n}\n\n/* This function takes a Python object representing a type and converts it \n to a the correct PyArray_Descr * structure to describe the type.\n \n Many objects can be used to represent a data-type which in NumPy is\n quite a flexible concept. \n\n This is the central code that converts Python objects to \n Type-descriptor objects that are used throughout numpy.\n */\n\n/* new reference in *at */\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to &LONG_descr\n*/\nstatic int\nPyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)\n{\n char *type;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item;\n\tint elsize = 0;\n\tchar endian = '=';\n\n\t*at=NULL;\n\t\n\t/* default */\n if (obj == Py_None) {\n\t\t*at = PyArray_DescrFromType(PyArray_LONG);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n\tif (PyArray_DescrCheck(obj)) {\n\t\t*at = (PyArray_Descr *)obj;\n\t\tPy_INCREF(*at);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n if (PyType_Check(obj)) {\n\t\tif (PyType_IsSubtype((PyTypeObject *)obj, \n\t\t\t\t &PyGenericArrType_Type)) {\n\t\t\t*at = PyArray_DescrFromTypeObject(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t\telse return PY_FAIL;\n\t\t}\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type))\n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyLong_Type))\n\t\t\tcheck_num = PyArray_LONGLONG;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t\telse if (obj == (PyObject *)(&PyBuffer_Type))\n\t\t\tcheck_num = PyArray_VOID;\n\t\telse {\n\t\t\t*at = _arraydescr_fromobj(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\n\t\tif (len <= 0) goto fail;\n\t\tcheck_num = (int) type[0];\n\t\tif ((char) check_num == '>' || (char) check_num == '<' || \\\n\t\t (char) check_num == '|' || (char) check_num == '=') {\n\t\t\tif (len <= 1) goto fail;\n\t\t\tendian = (char) check_num;\n\t\t\ttype++; len--;\n\t\t\tcheck_num = (int) type[0];\n\t\t\tif (endian == '|') endian = '=';\n\t\t}\n\t\tif (len > 1) {\n\t\t\tint i;\n\t\t\telsize = atoi(type+1);\n\t\t\t/* check for commas present */\n\t\t\tfor (i=1;ielsize == 0) && (elsize != 0)) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->elsize = elsize;\n\t}\n\tif (endian != '=' && PyArray_ISNBO(endian)) endian = '='; \n\t\n\tif (endian != '=' && (*at)->byteorder != '|' &&\t\\\n\t (*at)->byteorder != endian) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->byteorder = endian;\n\t}\n\t\n return PY_SUCCEED;\n\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\t*at=NULL;\n\treturn PY_FAIL;\n}\t\n\n/*MULTIARRAY_API\n Convert object to endian\n*/\nstatic int\nPyArray_ByteorderConverter(PyObject *obj, char *endian)\n{\n\tchar *str;\n\t*endian = PyArray_SWAP;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Byteorder string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\t*endian = str[0];\n\tif (str[0] != PyArray_BIG && str[0] != PyArray_LITTLE &&\t\\\n\t str[0] != PyArray_NATIVE) {\n\t\tif (str[0] == 'b' || str[0] == 'B')\n\t\t\t*endian = PyArray_BIG;\n\t\telse if (str[0] == 'l' || str[0] == 'L')\n\t\t\t*endian = PyArray_LITTLE;\n\t\telse if (str[0] == 'n' || str[0] == 'N')\n\t\t\t*endian = PyArray_NATIVE;\n\t\telse if (str[0] == 'i' || str[0] == 'I')\n\t\t\t*endian = PyArray_IGNORE;\n\t\telse if (str[0] == 's' || str[0] == 'S')\n\t\t\t*endian = PyArray_SWAP;\n\t\telse {\n\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t \"%s is an unrecognized byteorder\",\n\t\t\t\t str);\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Convert object to sort kind \n*/\nstatic int\nPyArray_SortkindConverter(PyObject *obj, PyArray_SORTKIND *sortkind)\n{\n\tchar *str;\n\t*sortkind = PyArray_QUICKSORT;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Sort kind string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\tif (str[0] == 'q' || str[0] == 'Q')\n\t\t*sortkind = PyArray_QUICKSORT;\n\telse if (str[0] == 'h' || str[0] == 'H')\n\t\t*sortkind = PyArray_HEAPSORT;\n\telse if (str[0] == 'm' || str[0] == 'M')\n\t\t*sortkind = PyArray_MERGESORT;\n\telse if (str[0] == 't' || str[0] == 'T')\n\t\t*sortkind = PyArray_TIMSORT;\n\telse {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s is an unrecognized kind of sort\",\n\t\t\t str);\n\t\treturn PY_FAIL;\n\t}\n\treturn PY_SUCCEED;\n}\n\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\n/*MULTIARRAY_API*/\nstatic Bool\nPyArray_EquivTypes(PyArray_Descr *typ1, PyArray_Descr *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->elsize;\n\tregister int size2=typ2->elsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typ1->fields != typ2->fields) return FALSE;\n\tif (PyArray_ISNBO(typ1->byteorder) != PyArray_ISNBO(typ2->byteorder))\n\t\treturn FALSE;\n\n\tif (typenum1 == PyArray_VOID || \\\n\t typenum2 == PyArray_VOID) {\n\t\treturn ((typenum1 == typenum2) && \n\t\t\t(typ1->typeobj == typ2->typeobj) &&\n\t\t\t(typ1->fields == typ2->fields));\n\t}\n\treturn (typ1->kind == typ2->kind);\n}\n\n/*** END C-API FUNCTIONS **/\n\nstatic PyObject *\n_prepend_ones(PyArrayObject *arr, int nd, int ndmin)\n{\n\tintp newdims[MAX_DIMS];\n\tintp newstrides[MAX_DIMS];\n\tint i,k,num;\n\tPyObject *ret;\n\n\tnum = ndmin-nd;\n\tfor (i=0; idescr->elsize;\n\t}\n\tfor (i=num;idimensions[k];\n\t\tnewstrides[i] = arr->strides[k];\n\t}\n\tPy_INCREF(arr->descr);\n\tret = PyArray_NewFromDescr(arr->ob_type, arr->descr, ndmin,\n\t\t\t\t newdims, newstrides, arr->data, arr->flags,\n\t\t\t\t (PyObject *)arr);\n\t/* steals a reference to arr --- so don't increment\n\t here */\n\tPyArray_BASE(ret) = (PyObject *)arr;\n\treturn ret;\n}\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, \"\n \"order=None, subok=0,ndmin=0)\\n\"\n\t\"will return an array from object with the specified date-type\\n\\n\"\n\t\"Inputs:\\n\\n\"\n\t\" object - an array, any object exposing the array interface, any \\n\"\n\t\" object whose __array__ method returns an array, or any \\n\"\n\t\" (nested) sequence.\\n\"\n\t\" dtype - The desired data-type for the array. If not given, then\\n\"\n\t\" the type will be determined as the minimum type required\\n\"\n\t\" to hold the objects in the sequence. This argument can only\\n\"\n\t\" be used to 'upcast' the array. For downcasting, use the \\n\"\n\t\" .astype(t) method.\\n\"\n \" copy - If true, then force a copy. Otherwise a copy will only occur\\n\"\n\t\" if __array__ returns a copy, obj is a nested sequence, or \\n\"\n\t\" a copy is needed to satisfy any of the other requirements\\n\"\n\t\" order - Specify the order of the array. If order is 'C', then the\\n\"\n\t\" array will be in C-contiguous order (last-index varies the\\n\"\n\t\" fastest). If order is 'FORTRAN', then the returned array\\n\"\n\t\" will be in Fortran-contiguous order (first-index varies the\\n\"\n\t\" fastest). If order is None, then the returned array may\\n\"\n\t\" be in either C-, or Fortran-contiguous order or even\\n\"\n\t\" discontiguous.\\n\"\n\t\" subok - If True, then sub-classes will be passed-through, otherwise\\n\"\n\t\" the returned array will be forced to be a base-class array\\n\"\n\t\" ndmin - Specifies the minimum number of dimensions that the resulting\\n\"\n\t\" array should have. 1's will be pre-pended to the shape as\\n\"\n\t\" needed to meet this requirement.\\n\";\n\n#define STRIDING_OK(op, order) ((order) == PyArray_ANYORDER || \\\n ((order) == PyArray_CORDER && \\\n PyArray_ISCONTIGUOUS(op)) || \\\n ((order) == PyArray_FORTRANORDER && \\\n PyArray_ISFORTRAN(op)))\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"order\", \"subok\", \n\t\t\t \"ndmin\", NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tint ndmin=0, nd;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tPyArray_ORDER order=PyArray_ANYORDER;\n\tint flags=0;\n\n if (PyTuple_GET_SIZE(args) > 2) {\n PyErr_SetString(PyExc_ValueError, \n \"only 2 non-keyword arguments accepted\");\n return NULL;\n }\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&i\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_OrderConverter, &order,\n PyArray_BoolConverter, &subok, \n\t\t\t\t\t&ndmin)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((subok && PyArray_Check(op)) || \n\t (!subok && PyArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && STRIDING_OK(op, order)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\tret = op;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t order);\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\t/* One more chance */\n\t\toldtype = PyArray_DESCR(op);\n\t\tif (PyArray_EquivTypes(oldtype, type)) {\n\t\t\tif (!copy && STRIDING_OK(op, order)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\tret = op;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t order);\n\t\t\t\tif (oldtype == type) return ret;\n\t\t\t\tPy_INCREF(oldtype);\n\t\t\t\tPy_DECREF(PyArray_DESCR(ret));\n\t\t\t\tPyArray_DESCR(ret) = oldtype;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n if (order == PyArray_CORDER) {\n flags |= CONTIGUOUS;\n }\n\telse if ((order == PyArray_FORTRANORDER) || \n /* order == PyArray_ANYORDER && */\n (PyArray_Check(op) && PyArray_ISFORTRAN(op))) {\n flags |= FORTRAN;\n }\n\tif (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n finish:\n\n\tif ((nd=PyArray_NDIM(ret)) >= ndmin) return ret;\n\t/* create a new array from the same data with ones in the shape */\n\t/* steals a reference to ret */\n\treturn _prepend_ones((PyArrayObject *)ret, nd, ndmin);\n}\n\n/* accepts NULL type */\n/* steals referenct to type */\n/*MULTIARRAY_API\n Empty\n*/\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n \n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type, nd, dims, \n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=int,order='C') will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"order\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tPyArray_ORDER order = PyArray_CORDER;\t\n Bool fortran;\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_OrderConverter, &order)) \n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = TRUE;\n else fortran = FALSE;\n\n\tret = PyArray_Empty(shape.len, shape.ptr, typecode, fortran); \n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtype,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtype must be a valid data-type descriptor. If dtype corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtype\",\"obj\", NULL};\n\tPyArray_Descr *typecode;\n\tPyObject *obj=NULL;\n\tint alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|O\",\n\t\t\t\t\t kwlist, &PyArrayDescr_Type, \n\t\t\t\t\t &typecode,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\t\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = _pya_malloc(typecode->elsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode->elsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode->elsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode, NULL);\n\t\n\t/* free dptr which contains zeros */\n\tif (alloc) _pya_free(dptr);\n\treturn ret;\n}\n\n\n/* steal a reference */\n/* accepts NULL type */\n/*MULTIARRAY_API\n Zeros\n*/\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type,\n\t\t\t\t\t\t nd, dims, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\n\t\tn = PyArray_NBYTES(ret);\n\t\tmemset(ret->data, 0, n);\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=int,order='C') will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL}; /* XXX ? */\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n PyArray_ORDER order = PyArray_CORDER;\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_OrderConverter,\n\t\t\t\t\t &order)) \n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = TRUE;\n else fortran = FALSE;\n\tret = PyArray_Zeros(shape.len, shape.ptr, typecode, (int) fortran);\n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic int\n_skip_sep(char **ptr, char *sep)\n{\n\tchar *a;\n\tint n;\n\tn = strlen(sep);\n\ta = *ptr;\n\twhile(*a != '\\0' && (strncmp(a, sep, n) != 0))\n\t\ta++;\n\tif (*a == '\\0') return -1;\n\t*ptr = a+strlen(sep);\n\treturn 0;\n}\n\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, \n\t\t intp n, char *sep)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\tBool binary;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\titemsize = dtype->elsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\t\n\n\tif (binary) {\n\t\tif (dtype == &OBJECT_Descr) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"Cannot create an object array from\"\\\n\t\t\t\t\t\" a binary string\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\t\t\n\t\tif (n < 0 ) {\n\t\t\tif (slen % itemsize != 0) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"string size must be a \"\\\n\t\t\t\t\t\t\"multiple of element size\");\n\t\t\t\tPy_DECREF(dtype);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tn = slen/itemsize;\n\t\t} else {\n\t\t\tif (slen < n*itemsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"string is smaller than \" \\\n\t\t\t\t\t\t\"requested size\");\n\t\t\t\tPy_DECREF(dtype);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\n\t\tif ((ret = (PyArrayObject *)\\\n\t\t PyArray_NewFromDescr(&PyArray_Type, dtype,\n\t\t\t\t\t 1, &n, NULL, NULL,\n\t\t\t\t\t 0, NULL)) == NULL)\n\t\t\treturn NULL;\t\t\n\t\tmemcpy(ret->data, data, n*dtype->elsize);\n\t\treturn (PyObject *)ret;\n\t}\n\telse { /* read from character-based string */\n\t\tchar *ptr;\t\t\n\t\tPyArray_FromStrFunc *fromstr;\n\t\tchar *dptr;\n\t\tintp nread=0;\n\t\tintp index;\n\n\t\tfromstr = dtype->f->fromstr;\n\t\tif (fromstr == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character strings for given \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (n!=-1) {\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t dtype, 1, &n, NULL,\n\t\t\t\t\t\t NULL, 0, NULL);\n\t\t\tif (ret == NULL) return NULL;\n\t\t\tptr = data;\n\t\t\tdptr = ret->data;\n\t\t\tfor (index=0; index < n; index++) {\n\t\t\t\tif (fromstr(ptr, dptr, &ptr, ret) < 0)\n\t\t\t\t\tbreak;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += dtype->elsize;\n\t\t\t\tif (_skip_sep(&ptr, sep) < 0) \n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (nread < n) {\n\t\t\t\tfprintf(stderr, \"%ld items requested but \"\\\n\t\t\t\t\t\"only %ld read\\n\", \n\t\t\t\t\t(long) n, (long) nread);\n\t\t\t\tret->data = \\\n\t\t\t\t\tPyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t\tnread *\t\t\\\n\t\t\t\t\t\t\tret->descr->elsize);\n\t\t\t\tPyArray_DIM(ret,0) = nread;\n\t\t\t}\n\t\t}\n\t\telse {\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\t\t\tchar *end;\n\t\t\tint val;\n\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t dtype,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (ret==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * dtype->elsize;\n\t\t\tdptr = ret->data;\n\t\t\tptr = data;\n\t\t\tend = data+slen;\n\t\t\twhile (ptr < end) {\n\t\t\t\tval = fromstr(ptr, dptr, &ptr, ret);\n\t\t\t\tif (val < 0) break;\n\t\t\t\tnread += 1;\n\t\t\t\tval = _skip_sep(&ptr, sep);\n\t\t\t\tif (val < 0) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tdptr += dtype->elsize;\n\t\t\t\tif (thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tret->data = PyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = ret->data + \\\n\t\t\t\t\t\t(totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tret->data = PyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t nread*ret->descr->elsize);\n\t\t\tPyArray_DIM(ret,0) = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1, sep='') returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string. If sep is not empty then the string is interpreted in ASCII mode and converted to the desired number type using sep as the separator between elements (extra whitespace is ignored).\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tchar *sep=NULL;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&Ls\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_DescrConverter, &descr,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin, sep);\n}\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\tBool binary;\n\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"0-sized elements.\");\n\t\tPy_DECREF(typecode);\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\n\tif (num == -1 && binary) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\trewind(fp);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\t\"could not seek in file\");\n\t\t\tPy_DECREF(typecode);\n\t\t\treturn NULL;\n\t\t}\n\t\tnum = numbytes / typecode->elsize;\n\t}\n\t\n\tif (binary) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->elsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\t\tint done=0;\n\n\t\tscan = typecode->f->scanfunc;\n\t\tif (scan == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character files with that \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\tPy_DECREF(typecode);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode, \n\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num; i++) {\n\t\t\t\tif (done) break;\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\t\t\t\tif (done < -2) break;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->elsize;\n\t\t\tdptr = r->data;\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value. done is 1 or 2\n\t\t\t\t if end of file reached trying to\n\t\t\t\t scan separator. Still good value.\n\t\t\t\t*/\n\t\t\t\tif (done < -2) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tfprintf(stderr, \"%ld items requested but only %ld read\\n\", \n\t\t\t(long) num, (long) nread);\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->descr->elsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic char doc_fromfile[] = \\\n\t\"fromfile(file=, dtype=int, count=-1, sep='')\\n\"\t\\\n\t\"\\n\"\\\n\t\" Return an array of the given data type from a \\n\"\\\n\t\" (text or binary) file. The file argument can be an open file\\n\"\\\n\t\" or a string with the name of a file to read from. If\\n\"\\\n\t\" count==-1, then the entire file is read, otherwise count is\\n\"\\\n\t\" the number of items of the given type read in. If sep is ''\\n\"\\\n\t\" then read a binary file, otherwise it gives the separator\\n\"\\\n\t\" between elements in a text file.\\n\"\\\n\t\"\\n\"\\\n\t\" WARNING: This function should be used sparingly, as it is not\\n\"\\\n\t\" a platform-independent method of persistence. But it can be \\n\"\\\n\t\" useful to read in simply-formatted or binary data quickly.\";\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *type=NULL;\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (type == NULL) type = PyArray_DescrFromType(PyArray_LONG);\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\"first argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, \n\t\t intp count, intp offset) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer\");\n\t\tPy_DECREF(type);\n\t\treturn NULL;\n\t}\n\tif (type->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"itemsize cannot be zero in type\");\n\t\tPy_DECREF(type);\n\t\treturn NULL; \t\t\n\t}\n\n\tif (buf->ob_type->tp_as_buffer == NULL || \\\n\t (buf->ob_type->tp_as_buffer->bf_getwritebuffer == NULL &&\t\\\n\t buf->ob_type->tp_as_buffer->bf_getreadbuffer == NULL)) {\n\t\tPyObject *newbuf;\n\t\tnewbuf = PyObject_GetAttrString(buf, \"__buffer__\");\n\t\tif (newbuf == NULL) {Py_DECREF(type); return NULL;}\n\t\tbuf = newbuf;\n\t}\n\telse {Py_INCREF(buf);}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((offset < 0) || (offset >= ts)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"offset must be positive and smaller than %\"\n\t\t\t INTP_FMT, (intp)ts);\n\t}\n\n\tdata += offset;\n\ts = (intp)ts - offset;\n\tn = (intp)count;\n\titemsize = type->elsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t type, \n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, data, \n\t\t\t\t\t\t\t DEFAULT_FLAGS,\n\t\t\t\t\t\t\t NULL)) == NULL) {\n\t\tPy_DECREF(buf);\n\t\treturn NULL;\n\t}\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_frombuffer[] = \\\n\t\"frombuffer(buffer=, dtype=int, count=-1, offset=0)\\n\"\\\n\t\"\\n\"\t\t\t\t\t\t\t\t\\\n\t\" Returns a 1-d array of data type dtype from buffer. The buffer\\n\"\\\n\t\" argument must be an object that exposes the buffer interface.\\n\"\\\n\t\" If count is -1 then the entire buffer is used, otherwise, count\\n\"\\\n\t\" is the size of the output. If offset is given then jump that\\n\"\\\n\t\" far into the buffer. If the buffer has data that is out\\n\" \\\n\t\" not in machine byte-order, than use a propert data type\\n\"\\\n\t\" descriptor. The data will not\\n\" \\\n\t\" be byteswapped, but the array will manage it in future\\n\"\\\n\t\" operations.\\n\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1, offset=0;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", \"offset\", NULL};\n\tPyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&LL\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &offset)) {\n\t\treturn NULL;\n\t}\n\tif (type==NULL)\n\t\ttype = PyArray_DescrFromType(PyArray_LONG);\n\t\n\treturn PyArray_FromBuffer(obj, type, (intp)nin, (intp)offset);\n}\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\n/*MULTIARRAY_API\n Arange, \n*/\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length;\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *obj;\n\tint ret;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\n\tfuncs = PyArray_DESCR(range)->f; \n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tobj = PyFloat_FromDouble(start);\n\tret = funcs->setitem(obj, PyArray_DATA(range), (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 1) return range;\n\n\tobj = PyFloat_FromDouble(start + step);\n\tret = funcs->setitem(obj, PyArray_BYTES(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 2) return range;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\treturn NULL;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\t\n\treturn range;\n\n fail:\n\tPy_DECREF(range);\n\treturn NULL;\n}\n\n/* the formula is \n len = (intp) ceil((start - stop) / step);\n*/\nstatic intp\n_calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, int cmplx)\n{\n\tintp len;\n\tPyObject *val;\n\tdouble value;\n\t\n\t*next = PyNumber_Subtract(stop, start);\n\tif (!(*next)) return -1;\n\tval = PyNumber_TrueDivide(*next, step);\n\tPy_DECREF(*next); *next=NULL;\n\tif (!val) return -1;\n\tif (cmplx && PyComplex_Check(val)) {\n\t\tvalue = PyComplex_RealAsDouble(val);\n\t\tif (error_converting(value)) {Py_DECREF(val); return -1;}\n\t\tlen = (intp) ceil(value);\n\t\tvalue = PyComplex_ImagAsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = MIN(len, (intp) ceil(value));\n\t}\n\telse {\n\t\tvalue = PyFloat_AsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = (intp) ceil(value);\n\t}\n\t\n\tif (len > 0) {\n\t\t*next = PyNumber_Add(start, step);\n\t\tif (!next) return -1;\n\t}\n\treturn len;\n}\n\n/* this doesn't change the references */\n/*MULTIARRAY_API\n ArangeObj,\n*/\nstatic PyObject *\nPyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject *step, PyArray_Descr *dtype) \n{\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *next;\n\tintp length;\n\n\tif (!dtype) {\n\t\tPyArray_Descr *deftype;\n\t\tPyArray_Descr *newtype;\n\t\tdeftype = PyArray_DescrFromType(PyArray_LONG);\n\t\tnewtype = PyArray_DescrFromObject(start, deftype);\n\t\tPy_DECREF(deftype);\n\t\tdeftype = newtype;\n\t\tif (stop && stop != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(stop, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tif (step && step != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(step, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tdtype = deftype;\n\t}\n\telse Py_INCREF(dtype);\n\n\tif (!step || step == Py_None) {\n\t\tstep = PyInt_FromLong(1);\n\t}\n\telse Py_XINCREF(step);\n\n\tif (!stop || stop == Py_None) {\n\t\tstop = start;\n\t\tstart = PyInt_FromLong(0);\n\t}\n\telse Py_INCREF(start);\n\n\t/* calculate the length and next = start + step*/\n\tlength = _calc_length(start, stop, step, &next, \n\t\t\t PyTypeNum_ISCOMPLEX(dtype->type_num));\n\n\tif (PyErr_Occurred()) {Py_DECREF(dtype); goto fail;}\n\tif (length <= 0) {\n\t\tlength = 0;\n\t\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\t\tPy_DECREF(step); Py_DECREF(start); return range;\n\t}\n\n\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\tif (range == NULL) goto fail;\n\n\tfuncs = PyArray_DESCR(range)->f;\n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tif (funcs->setitem(start, PyArray_DATA(range), (PyArrayObject *)range) < 0)\n\t\tgoto fail;\n\tif (length == 1) goto finish;\n\tif (funcs->setitem(next, PyArray_BYTES(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range) < 0) goto fail;\n\tif (length == 2) goto finish;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\tgoto fail;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\n finish:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_DECREF(next);\n\treturn range;\n\t\n fail:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_XDECREF(next);\n\treturn NULL;\n}\n\n\nstatic char doc_arange[] = \n\"arange([start,] stop[, step,], dtype=None)\\n\\n\"\n\"For integer arguments, just like range() except it returns an array whose type can\\n\"\n\"be specified by the keyword argument dtype.\\n\\n\"\n\"If dtype is not specified, the type of the result is deduced from the type of the\\n\"\n\"arguments.\\n\\n\"\n\"For floating point arguments, the length of the result is ceil((stop - start)/step).\\n\"\n\"This rule may result in the last element of the result be greater than stop.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=NULL, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tPyArray_Descr *typecode=NULL;\n\t\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_DescrConverter2,\n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\treturn PyArray_ArangeObj(o_start, o_stop, o_step, typecode);\n}\n\n/*\nIncluded at the very first so not auto-grabbed and thus not \nlabeled.\n*/\nstatic unsigned int\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (unsigned int)NDARRAY_VERSION;\n}\n\nstatic char \ndoc__get_ndarray_c_version[] = \"_get_ndarray_c_version() gets the compile time NDARRAY_VERSION number\";\n\nstatic PyObject *\narray__get_ndarray_c_version(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {NULL};\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"\", kwlist )) return NULL;\n\t\n\treturn PyInt_FromLong( (long) PyArray_GetNDArrayCVersion() );\n}\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tif (!PyCallable_Check(op)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Argument must be callable.\");\n\t\treturn NULL;\n\t}\n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (kwds && PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"one or more objects not callable\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\n/*MULTIARRAY_API\n Where\n*/\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0, NULL);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither \"\n\t\t\t\t\"of x and y should be given\");\n\t\treturn NULL;\n\t}\n\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, \n\t\t\t\t\t\t\t\tn_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_lexsort[] = \"lexsort(keys=, axis=-1) returns an array of indexes\"\\\n\t\" similar to argsort except the sorting is done using the provided sorting\"\\\n\t\" keys. First the sort is done using key[0], then the resulting list of\"\\\n\t\" indexes is further manipulated by sorting on key[0]. And so forth\"\\\n\t\" The result is a sort on multiple keys. If the keys represented columns\" \\\n\t\" of a spread-sheet, for example, this would sort using multiple columns.\"\\\n\t\" The keys argument must be a tuple of things that can be converted to \"\\\n\t\" arrays of the same shape.\";\n\nstatic PyObject *\narray_lexsort(PyObject *ignored, PyObject *args, PyObject *kwds)\n{\n\tint axis=-1;\n\tPyObject *obj;\n\tstatic char *kwlist[] = {\"keys\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|i\", kwlist, \n\t\t\t\t\t &PyTuple_Type, &obj, &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_LexSort(obj, axis));\n}\n\n#undef _ARET\n\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *d1=NULL;\n\tPyArray_Descr *d2=NULL;\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_DescrConverter, &d1,\n\t\t\t\t\tPyArray_DescrConverter, &d2))\n\t\treturn NULL;\n\tif (d1 == NULL || d2 == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types; \"\t\\\n\t\t\t\t\"'None' not accepted\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(d1, d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\nstatic char doc_new_buffer[] = \\\n\t\"newbuffer(size) return a new uninitialized buffer object of size \"\n\t\"bytes\";\n\nstatic PyObject *\nnew_buffer(PyObject *dummy, PyObject *args)\n{\n\tint size;\n\n\tif(!PyArg_ParseTuple(args, \"i\", &size))\n\t\treturn NULL;\n\t\n\treturn PyBuffer_New(size);\n}\n\nstatic char doc_buffer_buffer[] = \\\n\t\"getbuffer(obj [,offset[, size]]) create a buffer object from the \"\\\n\t\"given object\\n referencing a slice of length size starting at \"\\\n\t\"offset. Default\\n is the entire buffer. A read-write buffer is \"\\\n\t\"attempted followed by a read-only buffer.\";\n\nstatic PyObject *\nbuffer_buffer(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj;\n\tint offset=0, size=Py_END_OF_BUFFER, n;\n\tvoid *unused;\n\tstatic char *kwlist[] = {\"object\", \"offset\", \"size\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ii\", kwlist, \n\t\t\t\t\t &obj, &offset, &size))\n\t\treturn NULL;\n\n\n\tif (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {\n\t\tPyErr_Clear();\n\t\treturn PyBuffer_FromObject(obj, offset, size);\t\t\n\t}\n\telse\n\t\treturn PyBuffer_FromReadWriteObject(obj, offset, size);\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"_get_ndarray_c_version\", (PyCFunction)array__get_ndarray_c_version, \n\t METH_VARARGS|METH_KEYWORDS, doc__get_ndarray_c_version},\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"lexsort\", (PyCFunction)array_lexsort,\n\t METH_VARARGS | METH_KEYWORDS, doc_lexsort},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t{\"newbuffer\", (PyCFunction)new_buffer,\n\t METH_VARARGS, doc_new_buffer},\t\n\t{\"getbuffer\", (PyCFunction)buffer_buffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_buffer_buffer},\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Number, Generic);\n SINGLE_INHERIT(Integer, Number);\n SINGLE_INHERIT(Inexact, Number);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n\tPy##child##ArrType_Type.tp_richcompare =\t\t\t\\\n\t\tPy##parent1##_Type.tp_richcompare;\t\t\t\\\n\tPy##child##ArrType_Type.tp_compare =\t\t\t\t\\\n\t\tPy##parent1##_Type.tp_compare;\t\t\t\t\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n#if SIZEOF_LONGLONG == SIZEOF_LONG\n DUAL_INHERIT(LongLong, Int, SignedInteger);\n#else\n SINGLE_INHERIT(LongLong, SignedInteger);\n#endif\n\n /* fprintf(stderr, \"tp_free = %p, PyObject_Del = %p, int_tp_free = %p, base.tp_free = %p\\n\", PyIntArrType_Type.tp_free, PyObject_Del, PyInt_Type.tp_free, PySignedIntegerArrType_Type.tp_free);\n\t */\n\tSINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\n\tif (_multiarray_module_loaded) return;\n\t_multiarray_module_loaded = 1;\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMultiIter_Type.tp_iter = PyObject_SelfIter;\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tif (PyType_Ready(&PyArrayMultiIter_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayDescr_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayFlags_Type) < 0)\n\t\treturn;\n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMultiIter_Type);\n\tPyDict_SetItemString(d, \"broadcast\", \n\t\t\t (PyObject *)&PyArrayMultiIter_Type);\n\tPy_INCREF(&PyArrayDescr_Type);\n\tPyDict_SetItemString(d, \"dtype\", (PyObject *)&PyArrayDescr_Type);\n\n\tPy_INCREF(&PyArrayFlags_Type);\n\tPyDict_SetItemString(d, \"flagsobj\", (PyObject *)&PyArrayFlags_Type);\n\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) != 0) goto err;\n\n\t_numpy_internal =\t\t\t\t\t\t\\\n\t\tPyImport_ImportModule(\"numpy.core._internal\");\n\tif (_numpy_internal != NULL) return;\n\n err:\t\n\tif (!PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"cannot load multiarray module.\");\n\t}\n\treturn;\n}\n\n", + "source_code_before": "/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified extensively for numpy in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"numpy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\nstatic PyObject *_numpy_internal=NULL; /* A Python module for callbacks */\nstatic int _multiarray_module_loaded=0;\n\n\nstatic PyArray_Descr *\n_arraydescr_fromobj(PyObject *obj)\n{\n\tPyObject *dtypedescr;\n\tPyArray_Descr *new;\n\tint ret;\n\t\n\tdtypedescr = PyObject_GetAttrString(obj, \"dtype\");\n\tPyErr_Clear();\n\tif (dtypedescr) {\n\t\tret = PyArray_DescrConverter(dtypedescr, &new);\n\t\tPy_DECREF(dtypedescr);\n\t\tif (ret) return new;\n\t\tPyErr_Clear();\n\t}\n\treturn NULL;\n}\n\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\n/*MULTIARRAY_API\n Multiply a List of ints\n*/\nstatic int\nPyArray_MultiplyIntList(register int *l1, register int n) \n{\n\tregister int s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Multiply a List\n*/\nstatic intp \nPyArray_MultiplyList(register intp *l1, register int n) \n{\n\tregister intp s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Produce a pointer into array\n*/\nstatic void *\nPyArray_GetPtr(PyArrayObject *obj, register intp* ind)\n{\n\tregister int n = obj->nd;\n\tregister intp *strides = obj->strides;\n\tregister char *dptr = obj->data;\n\t\n\twhile (n--) dptr += (*strides++) * (*ind++);\n\treturn (void *)dptr;\n}\n\n/*MULTIARRAY_API\n Get axis from an object (possibly None) -- a converter function,\n*/\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Compare Lists\n*/\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;iob_type;\n\t\n\tPy_INCREF(self->descr);\n\tnew = PyArray_NewFromDescr(subtype,\n\t\t\t\t self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides,\n\t\t\t\t self->data,\n\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (new==NULL) return NULL;\n\tPy_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n\t\n\tif (type != NULL) {\n\t\tif (PyObject_SetAttrString(new, \"dtype\",\n\t\t\t\t\t (PyObject *)type) < 0) {\n\t\t\tPy_DECREF(new);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tPy_DECREF(type);\n\t}\n\treturn new;\t\n}\n\n/*MULTIARRAY_API\n Ravel\n*/\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, PyArray_ORDER fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n if (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(a); \n \n\tnewdim.ptr = val; \n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) { \n\t\treturn PyArray_Newshape(a, &newdim, PyArray_CORDER); \n\t} \n\telse if (fortran && PyArray_ISFORTRAN(a)) { \n\t\treturn PyArray_Newshape(a, &newdim, PyArray_FORTRANORDER); \n\t} \n\telse \n\t\treturn PyArray_Flatten(a, fortran); \n}\n\nstatic double\npower_of_ten(int n)\n{\n\tstatic const double p10[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};\n\tdouble ret;\n\tif (n < 9)\n\t\tret = p10[n];\n\telse {\n\t\tret = 1e9;\n\t\twhile (n-- > 9)\n\t\t\tret *= 10.;\n\t}\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Round\n*/\nstatic PyObject *\nPyArray_Round(PyArrayObject *a, int decimals)\n{\n\tif (PyArray_ISCOMPLEX(a)) {\n\t\tPyObject *part;\n\t\tPyObject *round_part;\n\t\tPyObject *new;\n\t\tint res;\n\t\tnew = PyArray_Copy(a);\n\t\tif (new == NULL) return NULL;\n\n\t\t/* new.real = a.real.round(decimals) */\n\t\tpart = PyObject_GetAttrString(new, \"real\");\n\t\tif (part == NULL) {Py_DECREF(new); return NULL;}\n\t\tround_part = PyArray_Round\\\n\t\t\t((PyArrayObject *)PyArray_EnsureAnyArray(part), \n\t\t\t decimals);\n\t\tPy_DECREF(part);\n\t\tif (round_part == NULL) {Py_DECREF(new); return NULL;}\n\t\tres = PyObject_SetAttrString(new, \"real\", round_part);\n\t\tPy_DECREF(round_part);\n\t\tif (res < 0) {Py_DECREF(new); return NULL;}\n\n\t\t/* new.imag = a.imag.round(decimals) */\n\t\tpart = PyObject_GetAttrString(new, \"imag\");\n\t\tif (part == NULL) {Py_DECREF(new); return NULL;}\n\t\tround_part = PyArray_Round\\\n\t\t\t((PyArrayObject *)PyArray_EnsureAnyArray(part), \n\t\t\t decimals);\n\t\tPy_DECREF(part);\n\t\tif (round_part == NULL) {Py_DECREF(new); return NULL;}\n\t\tres = PyObject_SetAttrString(new, \"imag\", round_part);\n\t\tPy_DECREF(round_part);\n\t\tif (res < 0) {Py_DECREF(new); return NULL;}\n\t\treturn new;\n\t}\n\t/* do the most common case first */\n\tif (decimals == 0) {\n\t\tif (PyArray_ISINTEGER(a)) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_GenericUnaryFunction((PyAO *)a, n_ops.rint);\n\t}\n\tif (decimals > 0) {\n\t\tPyObject *f, *ret;\n\t\tif (PyArray_ISINTEGER(a)) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\tf = PyFloat_FromDouble(power_of_ten(decimals));\n\t\tif (f==NULL) return NULL;\n\t\tret = PyNumber_Multiply((PyObject *)a, f);\n\t\tif (ret==NULL) {Py_DECREF(f); return NULL;}\n\t\tif (PyArray_IsScalar(ret, Generic)) {\n\t\t\t/* array scalars cannot be modified inplace */\n\t\t\tPyObject *tmp;\n\t\t\ttmp = PyObject_CallFunction(n_ops.rint, \"O\", ret);\n\t\t\tPy_DECREF(ret);\n\t\t\tret = PyObject_CallFunction(n_ops.divide, \"OO\", \n\t\t\t\t\t\t tmp, f);\n\t\t\tPy_DECREF(tmp);\n\t\t} else {\n\t\t\tPyObject_CallFunction(n_ops.rint, \"OO\", ret, ret);\n\t\t\tPyObject_CallFunction(n_ops.divide, \"OOO\", ret, \n\t\t\t\t\t f, ret);\n\t\t}\n\t\tPy_DECREF(f);\n\t\treturn ret;\n\t} \n\telse {\n\t\t/* remaining case: decimals < 0 */\n\t\tPyObject *f, *ret;\n\t\tf = PyFloat_FromDouble(power_of_ten(-decimals));\n\t\tif (f==NULL) return NULL;\n\t\tret = PyNumber_Divide((PyObject *)a, f);\n\t\tif (ret==NULL) {Py_DECREF(f); return NULL;}\n\t\tif (PyArray_IsScalar(ret, Generic)) {\n\t\t\t/* array scalars cannot be modified inplace */\n\t\t\tPyObject *tmp;\n\t\t\ttmp = PyObject_CallFunction(n_ops.rint, \"O\", ret);\n\t\t\tPy_DECREF(ret);\n\t\t\tret = PyObject_CallFunction(n_ops.multiply, \"OO\", \n\t\t\t\t\t\t tmp, f);\n\t\t\tPy_DECREF(tmp);\n\t\t} else {\n\t\t\tPyObject_CallFunction(n_ops.rint, \"OO\", ret, ret);\n\t\t\tPyObject_CallFunction(n_ops.multiply, \"OOO\", ret, \n\t\t\t\t\t f, ret);\n\t\t}\n\t\tPy_DECREF(f);\n\t\treturn ret;\n\t}\n}\n\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, PyArray_ORDER fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran == PyArray_ANYORDER) \n\t\tfortran = PyArray_ISFORTRAN(a);\n\n\tsize = PyArray_SIZE(a);\n\tPy_INCREF(a->descr);\n\tret = PyArray_NewFromDescr(a->ob_type,\n\t\t\t\t a->descr,\n\t\t\t\t 1, &size,\n\t\t\t\t NULL,\n\t\t\t\t NULL,\n\t\t\t\t 0, (PyObject *)a);\n\t\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\n/*MULTIARRAY_API\n Reshape an array\n*/\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims, PyArray_CORDER);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\nstatic int\n_check_ones(PyArrayObject *self, int newnd, intp* newdims, intp *strides)\n{\n\tint nd;\n\tintp *dims;\n\tBool done=FALSE;\n\tint j, k;\n\n\tnd = self->nd;\n\tdims = self->dimensions;\n\n\tfor (k=0, j=0; !done && (jstrides[j];\n\t\t\tj++; k++;\n\t\t}\n\t\telse if ((kptr;\n\tn = newshape->len;\t\n\ts_known = 1;\n\ti_unknown = -1;\n\t\n\tfor(i=0; i= 0) {\n\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\treturn -1;\n\t\t}\n\t\tdimensions[i_unknown] = s_original/s_known;\n\t} else {\n\t\tif (s_original != s_known) {\n\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\treturn -1;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/* Returns a new array \n with the new shape from the data\n in the old array --- order-perspective depends on fortran argument.\n copy-if-necessary\n*/\n\n/*MULTIARRAY_API\n New shape for an array\n*/\nstatic PyObject * \nPyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims, \n\t\t PyArray_ORDER fortran)\n{\n intp i;\n\tintp *dimensions = newdims->ptr;\n PyArrayObject *ret;\n\tint n = newdims->len;\n Bool same, incref;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n\tif (fortran == PyArray_ANYORDER)\n\t\tfortran = PyArray_ISFORTRAN(self);\n\t\n /* Quick check to make sure anything actually needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && idescr->elsize;\n\t\t\tfor (i=1; idescr->elsize;\n\t\t\tfor (i=n-2; i>-1; i--) {\n\t\t\t\tif (strides[i] == 0)\n\t\t\t\t\tstrides[i] = strides[i+1] *\t\\\n\t\t\t\t\t\tdimensions[i+1];\n\t\t\t}\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = (PyAO *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t self->descr,\n\t\t\t\t\t n, dimensions,\n\t\t\t\t\t strides,\n\t\t\t\t\t self->data,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (ret== NULL) goto fail;\n\t\n if (incref) Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n\t\n fail:\n\tif (!incref) {Py_DECREF(self);}\n\treturn NULL;\n}\n\n\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\n/*MULTIARRAY_API*/\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t self->descr,\n\t\t\t\t newnd, dimensions, \n\t\t\t\t strides, self->data, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPyArray_FLAGS(ret) &= ~OWN_DATA;\n\tPyArray_BASE(ret) = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\n/*MULTIARRAY_API\n Mean\n*/\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\n/* Set variance to 1 to by-pass square-root calculation and return variance */\n/*MULTIARRAY_API\n Std\n*/\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype, int variance)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"condition must be 1-d array\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Nonzero\n*/\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t (PyObject *)self);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\tPy_DECREF(it);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\n/*MULTIARRAY_API\n Clip\n*/\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) {\n\t\tPy_DECREF(two);\n\t\tPy_XDECREF(res1);\n\t\tPy_XDECREF(res2);\n\t}\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two); \n\tPy_DECREF(res1); \n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) {Py_DECREF(selector); return NULL;}\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Conjugate\n*/\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_NewCopy(self, -1);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\n/*MULTIARRAY_API\n Trace\n*/\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Diagonal\n*/\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyArray_Dims newaxes;\n\tintp dims[MAX_DIMS];\n\tint i, pos;\t\n\n\tnewaxes.ptr = dims;\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes.len = n;\n\t/* insert at the end */\n\tnewaxes.ptr[n-2] = axis1;\n\tnewaxes.ptr[n-1] = axis2;\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr;\n\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"C arrays of only 1-3 dimensions available\");\n\t\tPy_XDECREF(typedescr);\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, typedescr, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS, NULL)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)_pya_malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"no memory\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\n/*MULTIARRAY_API\n Convert to a 1D C-array\n*/\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n/*MULTIARRAY_API\n Convert to a 2D C-array\n*/\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\n/*MULTIARRAY_API\n Free pointers created if As2D is called\n*/\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\t_pya_free(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tif (mps[i]->ob_type != subtype) {\n\t\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\t\tif (prior2 > prior1) {\n\t\t\t\tprior1 = prior2;\n\t\t\t\tsubtype = mps[i]->ob_type;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0-d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t mps[0]->descr, nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis1 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis2 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tnew_axes.ptr = dims;\n\tnew_axes.len = n;\n\n\tfor (i=0; ind;\n\t\tfor(i=0; ilen;\n\t\taxes = permute->ptr;\n\t\tif (n > ap->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many axes for this array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tPy_INCREF(ap->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t ap->descr, \n\t\t\t\t n, permutation, \n\t\t\t\t NULL, ap->data, ap->flags,\n\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) return NULL;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\t\n\n\treturn (PyObject *)ret;\t\n}\n\n/*MULTIARRAY_API\n Repeat the array.\n*/\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)\n{\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromAny(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tPy_INCREF(aop->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(aop->ob_type, \n\t\t\t\t\t\t aop->descr,\n\t\t\t\t\t\t aop->nd,\n\t\t\t\t\t\t aop->dimensions,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->descr->elsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; idescr->elsize;\n\tbyteorder = arr->descr->byteorder;\n\tptr = arr->data;\n\tif (elsize > 1 && \\\n\t (byteorder == PyArray_LITTLE ||\t\\\n\t (byteorder == PyArray_NATIVE &&\n\t PyArray_ISNBO(PyArray_LITTLE))))\n\t\tptr += elsize-1;\n\t\n\treturn ((*ptr & bitmask) != 0);\t\n}\n\n\n/*OBJECT_API*/\nstatic PyArray_SCALARKIND\nPyArray_ScalarKind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) {\n\t\tif (arr && _signbit_set(*arr)) return PyArray_INTNEG_SCALAR;\n\t\telse return PyArray_INTPOS_SCALAR;\n\t}\n\tif (PyTypeNum_ISFLOAT(typenum)) return PyArray_FLOAT_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return PyArray_INTPOS_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return PyArray_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return PyArray_BOOL_SCALAR;\n\n\treturn PyArray_OBJECT_SCALAR;\n}\n\n/*OBJECT_API*/\nstatic int \nPyArray_CanCoerceScalar(char thistype, char neededtype, \n\t\t\tPyArray_SCALARKIND scalar) \n{\n\n\tswitch(scalar) {\n\tcase PyArray_NOSCALAR:\n\tcase PyArray_BOOL_SCALAR:\n\tcase PyArray_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase PyArray_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase PyArray_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase PyArray_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase PyArray_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\n/* This needs to change to allow scalars of a different \"kind\" to alter the input type\n */\n\n/*OBJECT_API*/\nstatic PyArrayObject **\nPyArray_ConvertToCommonType(PyObject *op, int *retn)\n{\n\tint i, n, allscalars=0; \n\tPyArrayObject **mps=NULL;\n\tPyObject *otmp;\n\tPyArray_Descr *intype=NULL, *stype=NULL;\n\tPyArray_Descr *newtype=NULL;\n\tchar scalarkind;\n\n\t\n\t*retn = n = PySequence_Length(op);\n\tif (PyErr_Occurred()) {*retn = 0; return NULL;}\n\t\n\tmps = (PyArrayObject **)PyDataMem_NEW(n*sizeof(PyArrayObject *));\n\tif (mps == NULL) {\n\t\t*retn = 0;\n\t\treturn (void*)PyErr_NoMemory();\n\t}\n\t\n\tfor(i=0; itype_num, NULL);\n\t\t\tif (intype && !PyArray_CanCoerceScalar(newtype->type_num,\n\t\t\t\t\t\t\t intype->type_num, \n\t\t\t\t\t\t\t scalarkind)) {\n\t\t\t\tPy_XDECREF(intype);\n\t\t\t\tintype = stype;\n\t\t\t}\n\t\t\tmps[i] = (PyArrayObject *)Py_None;\n\t\t\tPy_INCREF(Py_None);\n\t\t}\n\t\tPy_XDECREF(otmp);\n\t}\n\tif (intype==NULL) { /* all scalars */\n\t\tallscalars = 1;\n\t\tintype = stype;\n\t\tPy_INCREF(intype);\n\t\tfor (i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t\t\t mps[0]->descr,\n\t\t\t\t\t\t ap->nd,\n\t\t\t\t\t\t ap->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->descr->elsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->f->sort[which];\n\tsize = it->size;\n\tN = op->dimensions[axis];\n\telsize = op->descr->elsize;\n\tastride = op->strides[axis];\n\n\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize);\n\n\tif (needcopy) {\n\t\tchar *buffer;\n\t\tbuffer = PyDataMem_NEW(N*elsize);\n\t\twhile (size--) {\n\t\t\t_strided_copy(buffer, (intp) elsize, it->dataptr, \n\t\t\t\t astride, N, elsize);\n\t\t\tif (sort(buffer, N, op) < 0) {\n\t\t\t\tPyDataMem_FREE(buffer); goto fail;\n\t\t\t}\n\t\t\t_strided_copy(it->dataptr, astride, buffer, \n\t\t\t\t (intp) elsize, N, elsize);\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tPyDataMem_FREE(buffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tif (sort(it->dataptr, N, op) < 0) goto fail;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\t\n\t\n\tEND_THREADS\n\t\n\tPy_DECREF(it);\n\treturn 0;\n\n fail:\n\tEND_THREADS\n\n\tPy_DECREF(it);\n\treturn 0;\n}\n\nstatic PyObject*\n_new_argsort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\n\tPyArrayIterObject *it=NULL;\n\tPyArrayIterObject *rit=NULL;\n\tPyObject *ret;\n\tint needcopy=0, i;\n\tintp N, size;\n\tint elsize;\n\tintp astride, rstride, *iptr;\n\tPyArray_ArgSortFunc *argsort;\n\tBEGIN_THREADS_DEF \n\n\tret = PyArray_New(op->ob_type, op->nd,\n\t\t\t op->dimensions, PyArray_INTP,\n\t\t\t NULL, NULL, 0, 0, (PyObject *)op);\n\tif (ret == NULL) return NULL;\n\n\tit = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, axis);\n\trit = (PyArrayIterObject *)PyArray_IterAllButAxis(ret, axis);\n\tif (rit == NULL || it == NULL) goto fail;\n\n\tBEGIN_THREADS\n\n\targsort = op->descr->f->argsort[which];\n\tsize = it->size;\n\tN = op->dimensions[axis];\n\telsize = op->descr->elsize;\n\tastride = op->strides[axis];\n\trstride = PyArray_STRIDE(ret,axis);\n\n\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) || \\\n\t\t(rstride != sizeof(intp));\n\t\n\tif (needcopy) {\n\t\tchar *valbuffer, *indbuffer;\n\t\tvalbuffer = PyDataMem_NEW(N*(elsize+sizeof(intp)));\n\t\tindbuffer = valbuffer + (N*elsize);\n\t\twhile (size--) {\n\t\t\t_strided_copy(valbuffer, (intp) elsize, it->dataptr,\n\t\t\t\t astride, N, elsize);\n\t\t\tiptr = (intp *)indbuffer;\n\t\t\tfor (i=0; idataptr, rstride, indbuffer, \n\t\t\t\t sizeof(intp), N, sizeof(intp));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t\tPyDataMem_FREE(valbuffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)rit->dataptr;\n\t\t\tfor (i=0; idataptr, (intp *)rit->dataptr, \n\t\t\t\t N, op) < 0) goto fail;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t}\n\t\n\tEND_THREADS\n\n\tPy_DECREF(it);\n\tPy_DECREF(rit);\n\treturn ret;\n\n fail:\n\n\tEND_THREADS\n\n\tPy_DECREF(ret);\n\tPy_XDECREF(it);\n\tPy_XDECREF(rit);\n\treturn NULL;\n}\n\n\n/* Be sure to save this global_compare when necessary */\n\nstatic PyArrayObject *global_obj;\n\nstatic int \nqsortCompare (const void *a, const void *b) \n{\n\treturn global_obj->descr->f->compare(a,b,global_obj);\n}\n\n/* Consumes reference to ap (op gets it)\n op contains a version of the array with axes swapped if\n local variable axis is not the last dimension.\n orign must be defined locally. \n*/\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/* Consumes reference to ap (op gets it)\n origin must be previously defined locally. \n SWAPAXES must have been called previously. \n op contains the swapped version of the array. \n*/\n#define SWAPBACK(op, ap) {\t \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/* These swap axes in-place if necessary */\n#define SWAPINTP(a,b) {intp c; c=(a); (a) = (b); (b) = c;}\n#define SWAPAXES2(ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\tSWAPINTP(ap->dimensions[axis], ap->dimensions[orign]); \\\n\t\t\tSWAPINTP(ap->strides[axis], ap->strides[orign]); \\\n\t\t\tPyArray_UpdateFlags(ap, CONTIGUOUS | FORTRAN); \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\n#define SWAPBACK2(ap) {\t\t \\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\tSWAPINTP(ap->dimensions[axis], ap->dimensions[orign]); \\\n\t\t\tSWAPINTP(ap->strides[axis], ap->strides[orign]); \\\n\t\t\tPyArray_UpdateFlags(ap, CONTIGUOUS | FORTRAN);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\n/*MULTIARRAY_API\n Sort an array in-place\n*/\nstatic int\nPyArray_Sort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tn = op->nd;\n\tif ((n==0) || (PyArray_SIZE(op)==1)) return 0;\n\n\tif (axis < 0) axis += n;\n\tif ((axis < 0) || (axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\treturn -1;\n\t}\n\tif (!PyArray_ISWRITEABLE(op)) {\n\t\tPyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"attempted sort on unwriteable array.\");\n\t\treturn -1;\n\t}\n\n\t/* Determine if we should use type-specific algorithm or not */\n\tif (op->descr->f->sort[which] != NULL) {\n\t\treturn _new_sort(op, axis, which);\n\t}\n\n\tif ((which != PyArray_QUICKSORT) || \\\n\t op->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"desired sort not supported for this type\");\n\t\treturn -1;\n\t}\n\n\tSWAPAXES2(op);\n\n ap = (PyArrayObject *)PyArray_FromAny((PyObject *)op, \n\t\t\t\t\t NULL, 1, 0, \n\t\t\t\t\t DEFAULT_FLAGS | UPDATEIFCOPY, NULL);\t\n\tif (ap == NULL) goto fail;\n\t\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; idescr->elsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->f->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\n/*MULTIARRAY_API\n ArgSort an array\n*/\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis, PyArray_SORTKIND which) \n{\n\tPyArrayObject *ap=NULL, *ret=NULL, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tn = op->nd;\n\tif ((n==0) || (PyArray_SIZE(op)==1)) {\n\t\tret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,\n\t\t\t\t\t\t op->dimensions, \n\t\t\t\t\t\t PyArray_INTP,\n\t\t\t\t\t\t NULL, NULL, 0, 0, \n\t\t\t\t\t\t (PyObject *)op);\n\t\tif (ret == NULL) return NULL;\n\t\t*((intp *)ret->data) = 0;\n\t\treturn (PyObject *)ret;\n\t}\n\tif (axis < 0) axis += n;\n\tif ((axis < 0) || (axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\treturn NULL;\n\t}\n\n\t/* Determine if we should use new algorithm or not */\n\tif (op->descr->f->argsort[which] != NULL) {\n\t\treturn _new_argsort(op, axis, which);\n\t}\n\n\tif ((which != PyArray_QUICKSORT) || op->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"requested sort not available for type\");\n\t\tgoto fail;\n\t}\n\n\tSWAPAXES(ap, op);\n\n\top = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)ap, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\n\tif (op == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(op->ob_type, op->nd,\n\t\t\t\t\t op->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)op);\n\tif (ret == NULL) goto fail;\n\t\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = op->descr->elsize;\n\tm = op->dimensions[op->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(op)/m;\n\tstore_ptr = global_data;\n\tglobal_data = op->data;\n\tstore = global_obj;\n\tglobal_obj = op;\n\tfor (i=0; i 0 in lexsort\");\n\t\treturn NULL;\n\t}\n\tmps = (PyArrayObject **) _pya_malloc(n*sizeof(PyArrayObject));\n\tif (mps==NULL) return PyErr_NoMemory();\n\tits = (PyArrayIterObject **) _pya_malloc(n*sizeof(PyArrayIterObject));\n\tif (its == NULL) {_pya_free(mps); return PyErr_NoMemory();}\n\tfor (i=0; i0) {\n\t\t\tif ((mps[i]->nd != mps[0]->nd) ||\t\\\n\t\t\t (!PyArray_CompareLists(mps[i]->dimensions,\n\t\t\t\t\t\t mps[0]->dimensions,\n\t\t\t\t\t\t mps[0]->nd))) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"all keys need to be the same shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (!mps[i]->descr->f->argsort[PyArray_MERGESORT]) {\n\t\t\tPyErr_Format(PyExc_TypeError, \n\t\t\t\t \"merge sort not available for item %d\", i);\n\t\t\tgoto fail;\n\t\t}\n\t\tits[i] = (PyArrayIterObject *)PyArray_IterAllButAxis\t\\\n\t\t\t((PyObject *)mps[i], axis);\n\t\tif (its[i]==NULL) goto fail;\n\t}\n\n\t/* Now we can check the axis */\n\tnd = mps[0]->nd;\n\tif ((nd==0) || (PyArray_SIZE(mps[0])==1)) {\n\t\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t PyArray_INTP,\n\t\t\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t\tif (ret == NULL) return NULL;\n\t\t*((intp *)(ret->data)) = 0;\n\t\treturn (PyObject *)ret;\n\t}\n\tif (axis < 0) axis += nd;\n\tif ((axis < 0) || (axis >= nd)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", axis);\n\t\tgoto fail;\n\t}\n\n\t/* Now do the sorting */\n\n\tret = (PyArrayObject *)PyArray_New(&PyArray_Type, mps[0]->nd,\n\t\t\t\t\t mps[0]->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (ret == NULL) goto fail;\n\n\trit = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ret, axis);\n\tif (rit == NULL) goto fail;\n\n\tsize = rit->size;\n\tN = mps[0]->dimensions[axis];\n\trstride = PyArray_STRIDE(ret,axis);\n\n maxelsize = mps[0]->descr->elsize;\n\tneedcopy = (rstride != sizeof(intp));\n\tfor (j=0; jflags & ALIGNED) || \\\n\t\t\t(mps[j]->strides[axis] != (intp)mps[j]->descr->elsize);\n if (mps[j]->descr->elsize > maxelsize) \n maxelsize = mps[j]->descr->elsize;\n\t}\n\n\tif (needcopy) {\n\t\tchar *valbuffer, *indbuffer;\n\t\tvalbuffer = PyDataMem_NEW(N*(maxelsize+sizeof(intp)));\n\t\tindbuffer = valbuffer + (N*maxelsize);\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)indbuffer;\n\t\t\tfor (i=0; idescr->elsize;\n\t\t\t\tastride = mps[j]->strides[axis];\t\n\t\t\t\targsort = mps[j]->descr->f->argsort[PyArray_MERGESORT];\n\t\t\t\t_strided_copy(valbuffer, (intp) elsize, its[j]->dataptr,\n\t\t\t\t\t astride, N, elsize);\n\t\t\t\tif (argsort(valbuffer, (intp *)indbuffer, N, mps[j]) < 0) {\n\t\t\t\t\tPyDataMem_FREE(valbuffer); goto fail;\n\t\t\t\t}\n\t\t\t\tPyArray_ITER_NEXT(its[j]);\n\t\t\t}\n\t\t\t_strided_copy(rit->dataptr, rstride, indbuffer,\n\t\t\t\t sizeof(intp), N, sizeof(intp));\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t\tPyDataMem_FREE(valbuffer);\n\t}\n\telse {\n\t\twhile (size--) {\n\t\t\tiptr = (intp *)rit->dataptr;\n\t\t\tfor (i=0; idescr->f->argsort[PyArray_MERGESORT];\n\t\t\t\tif (argsort(its[j]->dataptr, (intp *)rit->dataptr,\n\t\t\t\t\t N, mps[j]) < 0) goto fail;\n\t\t\t\tPyArray_ITER_NEXT(its[j]);\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(rit);\n\t\t}\n\t}\n\n\tfor (i=0; idescr->f->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->descr->elsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_SIZE(ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\n/*MULTIARRAY_API\n Numeric.searchsorted(a,v)\n*/\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n/*\n Make a new empty array, of the passed size, of a type that takes the\n priority of ap1 and ap2 into account.\n */\nstatic PyArrayObject *\nnew_array_for_sum(PyArrayObject *ap1, PyArrayObject *ap2,\n\t\t int nd, intp dimensions[], int typenum)\n{\n\tPyArrayObject *ret;\n\tPyTypeObject *subtype;\n\tdouble prior1, prior2;\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tif (ap2->ob_type != ap1->ob_type) {\n\t\tprior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n\t\tprior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n\n\t\tsubtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\t} else {\n\t\tprior1 = prior2 = 0.0;\n\t\tsubtype = ap1->ob_type;\n\t}\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\treturn ret;\n}\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\n/*MULTIARRAY_API\n Numeric.innerproduct(a,v)\n*/\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tPyArrayIterObject *it1, *it2;\n\tintp i, j, l;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\tPyArray_Descr *typec;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\n\ttypec = PyArray_DescrFromType(typenum);\n\tPy_INCREF(typec);\n\tap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, \n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap1 == NULL) {Py_DECREF(typec); return NULL;}\n\tap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,\n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->f->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tit1 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap1, ap1->nd-1);\n\tit2 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap2, ap2->nd-1);\n\n\twhile(1) {\n\t\twhile(it2->index < it2->size) {\n\t\t\tdot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);\n\t\t\top += os;\n\t\t\tPyArray_ITER_NEXT(it2);\n\t\t}\n\t\tPyArray_ITER_NEXT(it1);\n\t\tif (it1->index >= it1->size) break;\n\t\tPyArray_ITER_RESET(it2);\n\t}\n\tPy_DECREF(it1);\n\tPy_DECREF(it2);\n\n\tif (PyErr_Occurred()) goto fail;\n\t\t\n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n/* just like inner product but does the swapaxes stuff on the fly */\n/*MULTIARRAY_API\n Numeric.matrixproduct(a,v)\n*/\nstatic PyObject *\nPyArray_MatrixProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tPyArrayIterObject *it1, *it2;\n\tintp i, j, l;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\tintp matchDim;\n\tPyArray_Descr *typec;\n\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\t\n\t\n\ttypec = PyArray_DescrFromType(typenum);\n\tPy_INCREF(typec);\n\tap1 = (PyArrayObject *)PyArray_FromAny(op1, typec, 0, 0, \n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap1 == NULL) {Py_DECREF(typec); return NULL;}\n\tap2 = (PyArrayObject *)PyArray_FromAny(op2, typec, 0, 0,\n\t\t\t\t\t BEHAVED_FLAGS, NULL);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; istrides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\n /* Choose which subtype to return */\n\tret = new_array_for_sum(ap1, ap2, nd, dimensions, typenum);\n\tif (ret == NULL) goto fail;\n\n\t/* Ensure that multiarray.dot([],[]) -> 0 */\n\tmemset(PyArray_DATA(ret), 0, PyArray_ITEMSIZE(ret));\n\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\top = ret->data; os = ret->descr->elsize;\n\n\tit1 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap1, ap1->nd-1);\n\tit2 = (PyArrayIterObject *)\\\n\t\tPyArray_IterAllButAxis((PyObject *)ap2, matchDim);\n\n\twhile(1) {\n\t\twhile(it2->index < it2->size) {\n\t\t\tdot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);\n\t\t\top += os;\n\t\t\tPyArray_ITER_NEXT(it2);\n\t\t}\n\t\tPyArray_ITER_NEXT(it1);\n\t\tif (it1->index >= it1->size) break;\n\t\tPyArray_ITER_RESET(it2);\n\t}\n\tPy_DECREF(it1);\n\tPy_DECREF(it2);\n\tif (PyErr_Occurred()) goto fail; /* only for OBJECT arrays */\n\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n/*MULTIARRAY_API\n Fast Copy and Transpose\n*/\nstatic PyObject *\nPyArray_CopyAndTranspose(PyObject *op) \n{\n\tPyObject *ret, *arr;\n\tint nd;\n\tintp dims[2];\n\tintp i,j;\n\tint elsize, str2;\n\tchar *iptr;\n\tchar *optr;\n\n\t/* make sure it is well-behaved */\n\tarr = PyArray_FromAny(op, NULL, 0, 0, CARRAY_FLAGS, NULL);\n\tnd = PyArray_NDIM(arr);\n\tif (nd == 1) { /* we will give in to old behavior */\n\t\tret = PyArray_Copy((PyArrayObject *)arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\t\t\n\t}\n\telse if (nd != 2) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"only 2-d arrays are allowed\");\n\t\treturn NULL;\n\t}\n\n\t/* Now construct output array */\n\tdims[0] = PyArray_DIM(arr,1);\n\tdims[1] = PyArray_DIM(arr,0);\n\telsize = PyArray_ITEMSIZE(arr);\n\t\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(arr->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t 2, dims, \n\t\t\t\t NULL, NULL, 0, arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[0];\n\tn2 = ap2->dimensions[0];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (intp)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0, 1, or 2\");\n\t\tgoto fail;\n\t}\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n\tret = new_array_for_sum(ap1, ap2, 1, &length, typenum);\n\tif (ret == NULL) goto fail;\n\t\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this data type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[0]; is2 = ap2->strides[0];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Min\n*/\nstatic PyObject *\nPyArray_Min(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tret = PyArray_GenericReduceFunction(arr, n_ops.minimum, axis,\n\t\t\t\t\t arr->descr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Ptp\n*/\nstatic PyObject *\nPyArray_Ptp(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\tPyObject *obj1=NULL, *obj2=NULL;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tobj1 = PyArray_Max(arr, axis);\n\tif (obj1 == NULL) goto fail;\n\tobj2 = PyArray_Min(arr, axis);\n\tif (obj2 == NULL) goto fail;\n\tPy_DECREF(arr);\n\tret = PyNumber_Subtract(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(obj1);\n\tPy_XDECREF(obj2);\n\treturn NULL;\n}\n\n\n/*MULTIARRAY_API\n ArgMax\n*/\nstatic PyObject *\nPyArray_ArgMax(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *rp=NULL;\n\tPyArray_ArgFunc* arg_func;\n\tchar *ip;\n\tintp *rptr;\n\tintp i, n, orign, m;\n\tint elsize;\n\t\n\tif ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t PyArray_NOTYPE, 1, 0);\n\n\tPy_DECREF(op);\n\tif (ap == NULL) return NULL;\n\t\n\targ_func = ap->descr->f->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, \n (PyObject *)ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n\tPy_INCREF(self->descr);\n ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t nd, shape, \n\t\t\t\t\t\t NULL, NULL, 0, \n\t\t\t\t\t\t (PyObject *)self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->descr->elsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array\n*/\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject* values0, PyObject *indices0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromAny(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n\tthistype = self->descr->type_num;\n Py_INCREF(self->descr); \n\tvalues = (PyArrayObject *)PyArray_FromAny(values0, self->descr, 0, 0, \n\t\t\t\t\t\t DEFAULT_FLAGS | FORCECAST, NULL); \n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n if (thistype == PyArray_OBJECT) { \n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n Py_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+tmp*chunk)));\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array according to a mask.\n*/\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_FROM_OTF(mask0, PyArray_BOOL, CARRAY_FLAGS | FORCECAST);\n\tif (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n if (thistype == PyArray_OBJECT) {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+i*chunk)));\n memmove(dest + i * chunk, src, chunk);\n }\n\t\t\t}\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) memmove(dest + i * chunk, src, chunk);\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \n/*MULTIARRAY_API\n Useful to pass as converter function for O& processing in\n PyArgs_ParseTuple.\n*/\nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS, NULL);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\n/*MULTIARRAY_API\n Convert an object to true / false\n*/\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{ \n\tif (PyObject_IsTrue(object))\n\t\t*val=TRUE;\n\telse *val=FALSE;\n\tif (PyErr_Occurred())\n\t\treturn PY_FAIL;\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Convert an object to FORTRAN / C / ANY\n*/\nstatic int\nPyArray_OrderConverter(PyObject *object, PyArray_ORDER *val)\n{\n char *str;\n if (object == Py_None) {\n *val = PyArray_ANYORDER;\n }\n else if (!PyString_Check(object) || PyString_GET_SIZE(object) < 1) {\n if (PyObject_IsTrue(object))\n *val = PyArray_FORTRANORDER;\n else\n *val = PyArray_CORDER;\n if (PyErr_Occurred())\n return PY_FAIL;\n return PY_SUCCEED;\n }\n else {\n str = PyString_AS_STRING(object);\n if (str[0] == 'C' || str[0] == 'c') {\n *val = PyArray_CORDER; \n }\n if (str[0] == 'F' || str[0] == 'f') {\n *val = PyArray_FORTRANORDER;\n }\n if (str[0] == 'A' || str[0] == 'a') {\n *val = PyArray_ANYORDER;\n }\n }\n return PY_SUCCEED;\n}\n\n\n/*MULTIARRAY_API\n Typestr converter\n*/\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_GENBOOLLTR) {\n\t\tif (itemsize == 1)\n\t\t\tnewtype = PyArray_BOOL;\n\t\telse \n\t\t\tnewtype = PyArray_NOTYPE;\n\t}\n\telse if (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\n/*MULTIARRAY_API\n Get buffer chunk from object\n*/\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = BEHAVED_FLAGS;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\n/*MULTIARRAY_API\n Get intp chunk from sequence\n*/\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"sequence too large; \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) {\n\t\tPyDimMem_FREE(seq->ptr);\n\t\tseq->ptr=NULL;\n\t\treturn PY_FAIL;\n\t}\n return PY_SUCCEED;\n}\n\n\n/* A tuple type would be either (generic typeobject, typesize) \n or (fixed-length data-type, shape) \n\n or (inheriting data-type, new-data-type)\n The new data-type must have the same itemsize as the inheriting data-type\n unless the latter is 0 \n \n Thus (int32, {'real':(int16,0),'imag',(int16,2)})\n\n is one way to specify a descriptor that will give \n a['real'] and a['imag'] to an int32 array.\n*/\n\n/* leave type reference alone */\nstatic PyArray_Descr *\n_use_inherit(PyArray_Descr *type, PyObject *newobj, int *errflag) \n{\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\t*errflag = 0;\n\tif (!PyArray_DescrConverter(newobj, &conv)) {\n\t\treturn NULL;\n\t}\n\t*errflag = 1;\n\tif (type == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"cannot base a new descriptor on an\"\\\n\t\t\t\t\" OBJECT descriptor.\");\n\t\tgoto fail;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) goto fail;\n\n\tif (new->elsize && new->elsize != conv->elsize) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mismatch in size of old\"\\\n\t\t\t\t\"and new data-descriptor\");\n\t\tgoto fail;\n\t}\n\tnew->elsize = conv->elsize;\n\tif (conv->fields != Py_None) {\n\t\tnew->fields = conv->fields;\n\t\tPy_XINCREF(new->fields);\n\t}\n\tPy_DECREF(conv);\n\t*errflag = 0;\n\treturn new;\n\n fail:\n\tPy_DECREF(conv);\n\treturn NULL;\n\n}\n\nstatic PyArray_Descr *\n_convert_from_tuple(PyObject *obj) \n{\n\tPyArray_Descr *type, *res;\n\tPyObject *val;\n\tint errflag;\n\t\n\tif (PyTuple_GET_SIZE(obj) != 2) return NULL;\n\n\tif (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj,0), &type)) \n\t\treturn NULL;\n\tval = PyTuple_GET_ITEM(obj,1);\n\t/* try to interpret next item as a type */\n\tres = _use_inherit(type, val, &errflag);\n\tif (res || errflag) {\n\t\tPy_DECREF(type);\n\t\tif (res) return res;\n\t\telse return NULL;\n\t}\n\tPyErr_Clear();\n\t/* We get here if res was NULL but errflag wasn't set\n\t --- i.e. the conversion to a data-descr failed in _use_inherit\n\t*/\n\n\tif (type->elsize == 0) { /* interpret next item as a typesize */\n\t\tint itemsize;\n\t\titemsize = PyArray_PyIntAsInt(PyTuple_GET_ITEM(obj,1));\n\t\tif (error_converting(itemsize)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid itemsize in generic type \"\\\n\t\t\t\t\t\"tuple\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(type);\n\t\tif (type->type_num == PyArray_UNICODE)\n\t\t\ttype->elsize = itemsize << 2; \n\t\telse\n\t\t\ttype->elsize = itemsize;\n\t}\n\telse {\n\t\t/* interpret next item as shape (if it's a tuple)\n\t\t and reset the type to PyArray_VOID with \n\t\t a new fields attribute. \n\t */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyArray_Descr *newdescr;\n\t\tif (!(PyArray_IntpConverter(val, &shape)) || \n\t\t (shape.len > MAX_DIMS)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid shape in fixed-type tuple.\");\n\t\t\tgoto fail;\n\t\t}\n\t\t/* If (type, 1) was given, it is equivalent to type... */\n\t\tif (shape.len == 1 && shape.ptr[0] == 1 && \\\n\t\t PyNumber_Check(val)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\treturn type;\n\t\t}\n\t\tnewdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tif (newdescr == NULL) {PyDimMem_FREE(shape.ptr); goto fail;}\n\t\tnewdescr->elsize = type->elsize;\n\t\tnewdescr->elsize *= PyArray_MultiplyList(shape.ptr, \n\t\t\t\t\t\t\t shape.len);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tnewdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tnewdescr->subarray->base = type;\n\t\tif (type->hasobject) newdescr->hasobject = 1;\n\t\tPy_INCREF(val);\n\t\tnewdescr->subarray->shape = val;\n\t\tPy_XDECREF(newdescr->fields);\n\t\tnewdescr->fields = NULL;\n\t\ttype = newdescr;\n\t}\n\treturn type;\n\n fail:\n\tPy_XDECREF(type);\n\treturn NULL;\n}\n\n/* obj is a list. Each item is a tuple with\n\n(field-name, data-type (either a list or a string), and an optional \n shape parameter).\n*/\nstatic PyArray_Descr *\n_convert_from_array_descr(PyObject *obj)\n{\n\tint n, i, totalsize;\n\tint ret;\n\tPyObject *fields, *item, *newobj;\n\tPyObject *name, *key, *tup, *title;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n int hasobject=0;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyTuple_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ihasobject)\n hasobject = 1;\n\t\ttup = PyTuple_New((title == NULL ? 2 : 3));\n\t\tPyTuple_SET_ITEM(tup, 0, (PyObject *)conv);\n\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));\n\t\tif (title != NULL) {\t\t\t\n\t\t\tPy_INCREF(title);\n\t\t\tPyTuple_SET_ITEM(tup, 2, title);\n\t\t\tPyDict_SetItem(fields, title, tup);\n\t\t}\n\t\tPyDict_SetItem(fields, name, tup);\n\t\ttotalsize += conv->elsize;\n\t\tPy_DECREF(tup);\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tnew->elsize = totalsize;\n new->hasobject=hasobject;\n\treturn new;\n \n fail:\n\tPy_DECREF(fields);\n\tPy_DECREF(nameslist);\n\treturn NULL;\n\n}\n\n/* a list specifying a data-type can just be\n a list of formats. The names for the fields\n will default to f1, f2, f3, and so forth.\n\n or it can be an array_descr format string -- in which case\n align must be 0. \n*/\n\nstatic PyArray_Descr *\n_convert_from_list(PyObject *obj, int align, int try_descr)\n{\n\tint n, i;\n\tint totalsize;\n\tPyObject *fields;\n\tPyArray_Descr *conv=NULL;\n\tPyArray_Descr *new;\n\tPyObject *key, *tup;\n\tPyObject *nameslist=NULL;\n \tint ret;\n\tint maxalign=0;\n int hasobject=0;\n\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyTuple_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ihasobject)\n\t\t\thasobject=1;\t\t\t\n\t\tPyTuple_SET_ITEM(tup, 0, (PyObject *)conv);\n\t\tif (align) {\n\t\t\tint _align;\n\t\t\t_align = conv->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign, _align);\n\t\t}\n\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));\n\t\tPyDict_SetItem(fields, key, tup);\n\t\tPy_DECREF(tup);\n\t\tPyTuple_SET_ITEM(nameslist, i, key);\n\t\ttotalsize += conv->elsize;\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n new->hasobject=hasobject;\n\tif (maxalign > 1) {\n\t\ttotalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;\n\t}\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\treturn new;\n\n fail:\n\tPy_DECREF(nameslist);\n\tPy_DECREF(fields);\n\tif (!try_descr) return NULL;\n\tif (align) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"failed to convert from list of formats \"\\\n\t\t\t\t\"and align cannot be 1 for conversion from \"\\\n\t\t\t\t\"array_descr structure\");\n\t\treturn NULL;\n\t}\n\tPyErr_Clear();\n\treturn _convert_from_array_descr(obj);\n}\n\n\n/* comma-separated string */\n/* this is the format developed by the numarray records module */\n/* and implemented by the format parser in that module */\n/* this is an alternative implementation found in the _internal.py \n file patterned after that one -- the approach is to try to convert \n to a list (with tuples if any repeat information is present) \n and then call the _convert_from_list)\n*/\n\nstatic PyArray_Descr *\n_convert_from_commastring(PyObject *obj, int align)\n{\n\tPyObject *listobj;\n\tPyArray_Descr *res;\n\n\tif (!PyString_Check(obj)) return NULL;\n listobj = PyObject_CallMethod(_numpy_internal, \"_commastring\",\n\t\t\t\t \"O\", obj);\n\tif (!listobj) return NULL;\n\tres = _convert_from_list(listobj, align, 0);\n\tPy_DECREF(listobj);\n\tif (!res && !PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ValueError, \"invalid data-type\");\n\t\treturn NULL;\n\t}\n\treturn res;\n}\n\n\n\n/* a dictionary specifying a data-type\n must have at least two and up to four\n keys These must all be sequences of the same length.\n\n \"names\" --- field names \n \"formats\" --- the data-type descriptors for the field.\n \n Optional:\n\n \"offsets\" --- integers indicating the offset into the \n record of the start of the field.\n\t\t if not given, then \"consecutive offsets\" \n\t\t will be assumed and placed in the dictionary.\n \n \"titles\" --- Allows the use of an additional key\n for the fields dictionary.\n \nAttribute-lookup-based field names merely has to query the fields \ndictionary of the data-descriptor. Any result present can be used\nto return the correct field.\n\nSo, the notion of what is a name and what is a title is really quite\narbitrary. \n\nWhat does distinguish a title, however, is that if it is not None, \nit will be placed at the end of the tuple inserted into the \nfields dictionary.\n\nIf the dictionary does not have \"names\" and \"formats\" entries,\nthen it will be checked for conformity and used directly. \n*/\n\nstatic PyArray_Descr *\n_use_fields_dict(PyObject *obj, int align)\n{\n return (PyArray_Descr *)PyObject_CallMethod(_numpy_internal, \n\t\t\t\t\t\t \"_usefields\", \n\t\t\t\t\t\t \"Oi\", obj, align);\n}\n\nstatic PyArray_Descr *\n_convert_from_dict(PyObject *obj, int align)\n{\n\tPyArray_Descr *new;\n\tPyObject *fields=NULL;\n\tPyObject *names, *offsets, *descrs, *titles, *key;\n\tint n, i;\n\tint totalsize;\n\tint maxalign=0;\n int hasobject=0;\n\t\n\tfields = PyDict_New();\n\tif (fields == NULL) return (PyArray_Descr *)PyErr_NoMemory();\n\t\n\tnames = PyDict_GetItemString(obj, \"names\");\n\tdescrs = PyDict_GetItemString(obj, \"formats\");\n\n\tif (!names || !descrs) {\n\t\tPy_DECREF(fields);\n\t\treturn _use_fields_dict(obj, align);\n\t}\n\tn = PyObject_Length(names);\n\toffsets = PyDict_GetItemString(obj, \"offsets\");\n\ttitles = PyDict_GetItemString(obj, \"titles\");\n\tif ((n > PyObject_Length(descrs)) ||\t\t\t\\\n\t (offsets && (n > PyObject_Length(offsets))) ||\t\\\n\t (titles && (n > PyObject_Length(titles)))) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"all items in the dictionary must have\" \\\n\t\t\t\t\" the same length.\");\n\t\tgoto fail;\n\t}\n\n\ttotalsize = 0;\n\tfor(i=0; i totalsize) totalsize = offset;\n\t\t}\n\t\telse {\n\t\t\tif (align) {\n\t\t\t\tint _align = newdescr->alignment;\n\t\t\t\tif (_align > 1) totalsize =\t\t\\\n\t\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\t\tmaxalign = MAX(maxalign,_align);\n\t\t\t}\n\t\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong(totalsize));\n\t\t}\n\t\tif (len == 3) PyTuple_SET_ITEM(tup, 2, item);\n\t\tname = PyObject_GetItem(names, index);\n\t\tPy_DECREF(index);\n\n\t\t/* Insert into dictionary */\n\t\tif (PyDict_GetItem(fields, name) != NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"name already used as a name or title\");\n\t\t\tret = PY_FAIL;\n\t\t}\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) {\n\t\t\tif (PyDict_GetItem(fields, item) != NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"title already used as a name or \" \\\n\t\t\t\t\t\t\" title.\");\n\t\t\t\tret=PY_FAIL;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPyDict_SetItem(fields, item, tup);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\n if (!hasobject && newdescr->hasobject)\n hasobject = 1;\n\t\ttotalsize += newdescr->elsize;\n\t}\n\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tif (new == NULL) goto fail;\n\tif (maxalign > 1)\n\t\ttotalsize = ((totalsize + maxalign - 1)/maxalign)*maxalign;\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\tkey = PyInt_FromLong(-1);\n if (!PyTuple_Check(names)) {\n names = PySequence_Tuple(names);\n PyDict_SetItem(fields, key, names);\n Py_DECREF(names);\n }\n else PyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\n new->hasobject=hasobject;\n\treturn new;\n\n fail:\n\tPy_XDECREF(fields);\n\treturn NULL;\n}\n\n/* \n any object with \n the .fields attribute and/or .itemsize attribute \n (if the .fields attribute does not give\n the total size -- i.e. a partial record naming).\n If itemsize is given it must be >= size computed from fields\n \n The .fields attribute must return a convertible dictionary if \n present. Result inherits from PyArray_VOID.\n*/\n\n\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to NULL\n*/\nstatic int\nPyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)\n{\n\tif (obj == Py_None) {\n\t\t*at = NULL;\n\t\treturn PY_SUCCEED;\n\t}\n\telse return PyArray_DescrConverter(obj, at);\n}\n\n/* This function takes a Python object representing a type and converts it \n to a the correct PyArray_Descr * structure to describe the type.\n \n Many objects can be used to represent a data-type which in NumPy is\n quite a flexible concept. \n\n This is the central code that converts Python objects to \n Type-descriptor objects that are used throughout numpy.\n */\n\n/* new reference in *at */\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to &LONG_descr\n*/\nstatic int\nPyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)\n{\n char *type;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item;\n\tint elsize = 0;\n\tchar endian = '=';\n\n\t*at=NULL;\n\t\n\t/* default */\n if (obj == Py_None) {\n\t\t*at = PyArray_DescrFromType(PyArray_LONG);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n\tif (PyArray_DescrCheck(obj)) {\n\t\t*at = (PyArray_Descr *)obj;\n\t\tPy_INCREF(*at);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n if (PyType_Check(obj)) {\n\t\tif (PyType_IsSubtype((PyTypeObject *)obj, \n\t\t\t\t &PyGenericArrType_Type)) {\n\t\t\t*at = PyArray_DescrFromTypeObject(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t\telse return PY_FAIL;\n\t\t}\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type))\n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyLong_Type))\n\t\t\tcheck_num = PyArray_LONGLONG;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t\telse if (obj == (PyObject *)(&PyBuffer_Type))\n\t\t\tcheck_num = PyArray_VOID;\n\t\telse {\n\t\t\t*at = _arraydescr_fromobj(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\n\t\tif (len <= 0) goto fail;\n\t\tcheck_num = (int) type[0];\n\t\tif ((char) check_num == '>' || (char) check_num == '<' || \\\n\t\t (char) check_num == '|' || (char) check_num == '=') {\n\t\t\tif (len <= 1) goto fail;\n\t\t\tendian = (char) check_num;\n\t\t\ttype++; len--;\n\t\t\tcheck_num = (int) type[0];\n\t\t\tif (endian == '|') endian = '=';\n\t\t}\n\t\tif (len > 1) {\n\t\t\tint i;\n\t\t\telsize = atoi(type+1);\n\t\t\t/* check for commas present */\n\t\t\tfor (i=1;ielsize == 0) && (elsize != 0)) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->elsize = elsize;\n\t}\n\tif (endian != '=' && PyArray_ISNBO(endian)) endian = '='; \n\t\n\tif (endian != '=' && (*at)->byteorder != '|' &&\t\\\n\t (*at)->byteorder != endian) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->byteorder = endian;\n\t}\n\t\n return PY_SUCCEED;\n\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\t*at=NULL;\n\treturn PY_FAIL;\n}\t\n\n/*MULTIARRAY_API\n Convert object to endian\n*/\nstatic int\nPyArray_ByteorderConverter(PyObject *obj, char *endian)\n{\n\tchar *str;\n\t*endian = PyArray_SWAP;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Byteorder string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\t*endian = str[0];\n\tif (str[0] != PyArray_BIG && str[0] != PyArray_LITTLE &&\t\\\n\t str[0] != PyArray_NATIVE) {\n\t\tif (str[0] == 'b' || str[0] == 'B')\n\t\t\t*endian = PyArray_BIG;\n\t\telse if (str[0] == 'l' || str[0] == 'L')\n\t\t\t*endian = PyArray_LITTLE;\n\t\telse if (str[0] == 'n' || str[0] == 'N')\n\t\t\t*endian = PyArray_NATIVE;\n\t\telse if (str[0] == 'i' || str[0] == 'I')\n\t\t\t*endian = PyArray_IGNORE;\n\t\telse if (str[0] == 's' || str[0] == 'S')\n\t\t\t*endian = PyArray_SWAP;\n\t\telse {\n\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t \"%s is an unrecognized byteorder\",\n\t\t\t\t str);\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Convert object to sort kind \n*/\nstatic int\nPyArray_SortkindConverter(PyObject *obj, PyArray_SORTKIND *sortkind)\n{\n\tchar *str;\n\t*sortkind = PyArray_QUICKSORT;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Sort kind string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\tif (str[0] == 'q' || str[0] == 'Q')\n\t\t*sortkind = PyArray_QUICKSORT;\n\telse if (str[0] == 'h' || str[0] == 'H')\n\t\t*sortkind = PyArray_HEAPSORT;\n\telse if (str[0] == 'm' || str[0] == 'M')\n\t\t*sortkind = PyArray_MERGESORT;\n\telse if (str[0] == 't' || str[0] == 'T')\n\t\t*sortkind = PyArray_TIMSORT;\n\telse {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"%s is an unrecognized kind of sort\",\n\t\t\t str);\n\t\treturn PY_FAIL;\n\t}\n\treturn PY_SUCCEED;\n}\n\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\n/*MULTIARRAY_API*/\nstatic Bool\nPyArray_EquivTypes(PyArray_Descr *typ1, PyArray_Descr *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->elsize;\n\tregister int size2=typ2->elsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typ1->fields != typ2->fields) return FALSE;\n\tif (PyArray_ISNBO(typ1->byteorder) != PyArray_ISNBO(typ2->byteorder))\n\t\treturn FALSE;\n\n\tif (typenum1 == PyArray_VOID || \\\n\t typenum2 == PyArray_VOID) {\n\t\treturn ((typenum1 == typenum2) && \n\t\t\t(typ1->typeobj == typ2->typeobj) &&\n\t\t\t(typ1->fields == typ2->fields));\n\t}\n\treturn (typ1->kind == typ2->kind);\n}\n\n/*** END C-API FUNCTIONS **/\n\nstatic PyObject *\n_prepend_ones(PyArrayObject *arr, int nd, int ndmin)\n{\n\tintp newdims[MAX_DIMS];\n\tintp newstrides[MAX_DIMS];\n\tint i,k,num;\n\tPyObject *ret;\n\n\tnum = ndmin-nd;\n\tfor (i=0; idescr->elsize;\n\t}\n\tfor (i=num;idimensions[k];\n\t\tnewstrides[i] = arr->strides[k];\n\t}\n\tPy_INCREF(arr->descr);\n\tret = PyArray_NewFromDescr(arr->ob_type, arr->descr, ndmin,\n\t\t\t\t newdims, newstrides, arr->data, arr->flags,\n\t\t\t\t (PyObject *)arr);\n\t/* steals a reference to arr --- so don't increment\n\t here */\n\tPyArray_BASE(ret) = (PyObject *)arr;\n\treturn ret;\n}\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, \"\n \"order=None, subok=0,ndmin=0)\\n\"\n\t\"will return an array from object with the specified date-type\\n\\n\"\n\t\"Inputs:\\n\\n\"\n\t\" object - an array, any object exposing the array interface, any \\n\"\n\t\" object whose __array__ method returns an array, or any \\n\"\n\t\" (nested) sequence.\\n\"\n\t\" dtype - The desired data-type for the array. If not given, then\\n\"\n\t\" the type will be determined as the minimum type required\\n\"\n\t\" to hold the objects in the sequence. This argument can only\\n\"\n\t\" be used to 'upcast' the array. For downcasting, use the \\n\"\n\t\" .astype(t) method.\\n\"\n \" copy - If true, then force a copy. Otherwise a copy will only occur\\n\"\n\t\" if __array__ returns a copy, obj is a nested sequence, or \\n\"\n\t\" a copy is needed to satisfy any of the other requirements\\n\"\n\t\" order - Specify the order of the array. If order is 'C', then the\\n\"\n\t\" array will be in C-contiguous order (last-index varies the\\n\"\n\t\" fastest). If order is 'FORTRAN', then the returned array\\n\"\n\t\" will be in Fortran-contiguous order (first-index varies the\\n\"\n\t\" fastest). If order is None, then the returned array may\\n\"\n\t\" be in either C-, or Fortran-contiguous order or even\\n\"\n\t\" discontiguous.\\n\"\n\t\" subok - If True, then sub-classes will be passed-through, otherwise\\n\"\n\t\" the returned array will be forced to be a base-class array\\n\"\n\t\" ndmin - Specifies the minimum number of dimensions that the resulting\\n\"\n\t\" array should have. 1's will be pre-pended to the shape as\\n\"\n\t\" needed to meet this requirement.\\n\";\n\n#define STRIDING_OK(op, order) ((order) == PyArray_ANYORDER || \\\n ((order) == PyArray_CORDER && \\\n PyArray_ISCONTIGUOUS(op)) || \\\n ((order) == PyArray_FORTRANORDER && \\\n PyArray_ISFORTRAN(op)))\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"order\", \"subok\", \n\t\t\t \"ndmin\", NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tint ndmin=0, nd;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tPyArray_ORDER order=PyArray_ANYORDER;\n\tint flags=0;\n\n if (PyTuple_GET_SIZE(args) > 2) {\n PyErr_SetString(PyExc_ValueError, \n \"only 2 non-keyword arguments accepted\");\n return NULL;\n }\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&i\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_OrderConverter, &order,\n PyArray_BoolConverter, &subok, \n\t\t\t\t\t&ndmin)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((subok && PyArray_Check(op)) || \n\t (!subok && PyArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && STRIDING_OK(op, order)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\tret = op;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t order);\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t\t/* One more chance */\n\t\toldtype = PyArray_DESCR(op);\n\t\tif (PyArray_EquivTypes(oldtype, type)) {\n\t\t\tif (!copy && STRIDING_OK(op, order)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\tret = op;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t order);\n\t\t\t\tif (oldtype == type) return ret;\n\t\t\t\tPy_INCREF(oldtype);\n\t\t\t\tPy_DECREF(PyArray_DESCR(ret));\n\t\t\t\tPyArray_DESCR(ret) = oldtype;\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n if (order == PyArray_CORDER) {\n flags |= CONTIGUOUS;\n }\n\telse if ((order == PyArray_FORTRANORDER) || \n /* order == PyArray_ANYORDER && */\n (PyArray_Check(op) && PyArray_ISFORTRAN(op))) {\n flags |= FORTRAN;\n }\n\tif (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n finish:\n\n\tif ((nd=PyArray_NDIM(ret)) >= ndmin) return ret;\n\t/* create a new array from the same data with ones in the shape */\n\t/* steals a reference to ret */\n\treturn _prepend_ones((PyArrayObject *)ret, nd, ndmin);\n}\n\n/* accepts NULL type */\n/* steals referenct to type */\n/*MULTIARRAY_API\n Empty\n*/\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n \n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type, nd, dims, \n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=int,order='C') will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"order\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tPyArray_ORDER order = PyArray_CORDER;\t\n Bool fortran;\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_OrderConverter, &order)) \n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = TRUE;\n else fortran = FALSE;\n\n\tret = PyArray_Empty(shape.len, shape.ptr, typecode, fortran); \n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtype,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtype must be a valid data-type descriptor. If dtype corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtype\",\"obj\", NULL};\n\tPyArray_Descr *typecode;\n\tPyObject *obj=NULL;\n\tint alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|O\",\n\t\t\t\t\t kwlist, &PyArrayDescr_Type, \n\t\t\t\t\t &typecode,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\t\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = _pya_malloc(typecode->elsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode->elsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode->elsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode, NULL);\n\t\n\t/* free dptr which contains zeros */\n\tif (alloc) _pya_free(dptr);\n\treturn ret;\n}\n\n\n/* steal a reference */\n/* accepts NULL type */\n/*MULTIARRAY_API\n Zeros\n*/\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type,\n\t\t\t\t\t\t nd, dims, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\n\t\tn = PyArray_NBYTES(ret);\n\t\tmemset(ret->data, 0, n);\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=int,order='C') will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL}; /* XXX ? */\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n PyArray_ORDER order = PyArray_CORDER;\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_OrderConverter,\n\t\t\t\t\t &order)) \n\t\tgoto fail;\n\n if (order == PyArray_FORTRANORDER) fortran = TRUE;\n else fortran = FALSE;\n\tret = PyArray_Zeros(shape.len, shape.ptr, typecode, (int) fortran);\n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic int\n_skip_sep(char **ptr, char *sep)\n{\n\tchar *a;\n\tint n;\n\tn = strlen(sep);\n\ta = *ptr;\n\twhile(*a != '\\0' && (strncmp(a, sep, n) != 0))\n\t\ta++;\n\tif (*a == '\\0') return -1;\n\t*ptr = a+strlen(sep);\n\treturn 0;\n}\n\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, \n\t\t intp n, char *sep)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\tBool binary;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\titemsize = dtype->elsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\t\n\n\tif (binary) {\n\t\tif (dtype == &OBJECT_Descr) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"Cannot create an object array from\"\\\n\t\t\t\t\t\" a binary string\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\t\t\n\t\tif (n < 0 ) {\n\t\t\tif (slen % itemsize != 0) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"string size must be a \"\\\n\t\t\t\t\t\t\"multiple of element size\");\n\t\t\t\tPy_DECREF(dtype);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tn = slen/itemsize;\n\t\t} else {\n\t\t\tif (slen < n*itemsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"string is smaller than \" \\\n\t\t\t\t\t\t\"requested size\");\n\t\t\t\tPy_DECREF(dtype);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\n\t\tif ((ret = (PyArrayObject *)\\\n\t\t PyArray_NewFromDescr(&PyArray_Type, dtype,\n\t\t\t\t\t 1, &n, NULL, NULL,\n\t\t\t\t\t 0, NULL)) == NULL)\n\t\t\treturn NULL;\t\t\n\t\tmemcpy(ret->data, data, n*dtype->elsize);\n\t\treturn (PyObject *)ret;\n\t}\n\telse { /* read from character-based string */\n\t\tchar *ptr;\t\t\n\t\tPyArray_FromStrFunc *fromstr;\n\t\tchar *dptr;\n\t\tintp nread=0;\n\t\tintp index;\n\n\t\tfromstr = dtype->f->fromstr;\n\t\tif (fromstr == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character strings for given \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (n!=-1) {\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t dtype, 1, &n, NULL,\n\t\t\t\t\t\t NULL, 0, NULL);\n\t\t\tif (ret == NULL) return NULL;\n\t\t\tptr = data;\n\t\t\tdptr = ret->data;\n\t\t\tfor (index=0; index < n; index++) {\n\t\t\t\tif (fromstr(ptr, dptr, &ptr, ret) < 0)\n\t\t\t\t\tbreak;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += dtype->elsize;\n\t\t\t\tif (_skip_sep(&ptr, sep) < 0) \n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (nread < n) {\n\t\t\t\tfprintf(stderr, \"%ld items requested but \"\\\n\t\t\t\t\t\"only %ld read\\n\", \n\t\t\t\t\t(long) n, (long) nread);\n\t\t\t\tret->data = \\\n\t\t\t\t\tPyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t\tnread *\t\t\\\n\t\t\t\t\t\t\tret->descr->elsize);\n\t\t\t\tPyArray_DIM(ret,0) = nread;\n\t\t\t}\n\t\t}\n\t\telse {\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\t\t\tchar *end;\n\t\t\tint val;\n\n\t\t\tret = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t dtype,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (ret==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * dtype->elsize;\n\t\t\tdptr = ret->data;\n\t\t\tptr = data;\n\t\t\tend = data+slen;\n\t\t\twhile (ptr < end) {\n\t\t\t\tval = fromstr(ptr, dptr, &ptr, ret);\n\t\t\t\tif (val < 0) break;\n\t\t\t\tnread += 1;\n\t\t\t\tval = _skip_sep(&ptr, sep);\n\t\t\t\tif (val < 0) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tdptr += dtype->elsize;\n\t\t\t\tif (thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tret->data = PyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = ret->data + \\\n\t\t\t\t\t\t(totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tret->data = PyDataMem_RENEW(ret->data, \n\t\t\t\t\t\t nread*ret->descr->elsize);\n\t\t\tPyArray_DIM(ret,0) = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1, sep='') returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string. If sep is not empty then the string is interpreted in ASCII mode and converted to the desired number type using sep as the separator between elements (extra whitespace is ignored).\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tchar *sep=NULL;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&Ls\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_DescrConverter, &descr,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin, sep);\n}\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\tBool binary;\n\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"0-sized elements.\");\n\t\tPy_DECREF(typecode);\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\n\tif (num == -1 && binary) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\trewind(fp);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\t\"could not seek in file\");\n\t\t\tPy_DECREF(typecode);\n\t\t\treturn NULL;\n\t\t}\n\t\tnum = numbytes / typecode->elsize;\n\t}\n\t\n\tif (binary) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->elsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\t\tint done=0;\n\n\t\tscan = typecode->f->scanfunc;\n\t\tif (scan == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character files with that \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\tPy_DECREF(typecode);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode, \n\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num; i++) {\n\t\t\t\tif (done) break;\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\t\t\t\tif (done < -2) break;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->elsize;\n\t\t\tdptr = r->data;\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value. done is 1 or 2\n\t\t\t\t if end of file reached trying to\n\t\t\t\t scan separator. Still good value.\n\t\t\t\t*/\n\t\t\t\tif (done < -2) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tfprintf(stderr, \"%ld items requested but only %ld read\\n\", \n\t\t\t(long) num, (long) nread);\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->descr->elsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic char doc_fromfile[] = \\\n\t\"fromfile(file=, dtype=int, count=-1, sep='')\\n\"\t\\\n\t\"\\n\"\\\n\t\" Return an array of the given data type from a \\n\"\\\n\t\" (text or binary) file. The file argument can be an open file\\n\"\\\n\t\" or a string with the name of a file to read from. If\\n\"\\\n\t\" count==-1, then the entire file is read, otherwise count is\\n\"\\\n\t\" the number of items of the given type read in. If sep is ''\\n\"\\\n\t\" then read a binary file, otherwise it gives the separator\\n\"\\\n\t\" between elements in a text file.\\n\"\\\n\t\"\\n\"\\\n\t\" WARNING: This function should be used sparingly, as it is not\\n\"\\\n\t\" a platform-independent method of persistence. But it can be \\n\"\\\n\t\" useful to read in simply-formatted or binary data quickly.\";\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *type=NULL;\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (type == NULL) type = PyArray_DescrFromType(PyArray_LONG);\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\"first argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, \n\t\t intp count, intp offset) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer\");\n\t\tPy_DECREF(type);\n\t\treturn NULL;\n\t}\n\tif (type->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"itemsize cannot be zero in type\");\n\t\tPy_DECREF(type);\n\t\treturn NULL; \t\t\n\t}\n\n\tif (buf->ob_type->tp_as_buffer == NULL || \\\n\t (buf->ob_type->tp_as_buffer->bf_getwritebuffer == NULL &&\t\\\n\t buf->ob_type->tp_as_buffer->bf_getreadbuffer == NULL)) {\n\t\tPyObject *newbuf;\n\t\tnewbuf = PyObject_GetAttrString(buf, \"__buffer__\");\n\t\tif (newbuf == NULL) {Py_DECREF(type); return NULL;}\n\t\tbuf = newbuf;\n\t}\n\telse {Py_INCREF(buf);}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((offset < 0) || (offset >= ts)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"offset must be positive and smaller than %\"\n\t\t\t INTP_FMT, (intp)ts);\n\t}\n\n\tdata += offset;\n\ts = (intp)ts - offset;\n\tn = (intp)count;\n\titemsize = type->elsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t type, \n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, data, \n\t\t\t\t\t\t\t DEFAULT_FLAGS,\n\t\t\t\t\t\t\t NULL)) == NULL) {\n\t\tPy_DECREF(buf);\n\t\treturn NULL;\n\t}\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_frombuffer[] = \\\n\t\"frombuffer(buffer=, dtype=int, count=-1, offset=0)\\n\"\\\n\t\"\\n\"\t\t\t\t\t\t\t\t\\\n\t\" Returns a 1-d array of data type dtype from buffer. The buffer\\n\"\\\n\t\" argument must be an object that exposes the buffer interface.\\n\"\\\n\t\" If count is -1 then the entire buffer is used, otherwise, count\\n\"\\\n\t\" is the size of the output. If offset is given then jump that\\n\"\\\n\t\" far into the buffer. If the buffer has data that is out\\n\" \\\n\t\" not in machine byte-order, than use a propert data type\\n\"\\\n\t\" descriptor. The data will not\\n\" \\\n\t\" be byteswapped, but the array will manage it in future\\n\"\\\n\t\" operations.\\n\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1, offset=0;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", \"offset\", NULL};\n\tPyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&LL\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &offset)) {\n\t\treturn NULL;\n\t}\n\tif (type==NULL)\n\t\ttype = PyArray_DescrFromType(PyArray_LONG);\n\t\n\treturn PyArray_FromBuffer(obj, type, (intp)nin, (intp)offset);\n}\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\n/*MULTIARRAY_API\n Arange, \n*/\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length;\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *obj;\n\tint ret;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\n\tfuncs = PyArray_DESCR(range)->f; \n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tobj = PyFloat_FromDouble(start);\n\tret = funcs->setitem(obj, PyArray_DATA(range), (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 1) return range;\n\n\tobj = PyFloat_FromDouble(start + step);\n\tret = funcs->setitem(obj, PyArray_BYTES(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 2) return range;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\treturn NULL;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\t\n\treturn range;\n\n fail:\n\tPy_DECREF(range);\n\treturn NULL;\n}\n\n/* the formula is \n len = (intp) ceil((start - stop) / step);\n*/\nstatic intp\n_calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, int cmplx)\n{\n\tintp len;\n\tPyObject *val;\n\tdouble value;\n\t\n\t*next = PyNumber_Subtract(stop, start);\n\tif (!(*next)) return -1;\n\tval = PyNumber_TrueDivide(*next, step);\n\tPy_DECREF(*next); *next=NULL;\n\tif (!val) return -1;\n\tif (cmplx && PyComplex_Check(val)) {\n\t\tvalue = PyComplex_RealAsDouble(val);\n\t\tif (error_converting(value)) {Py_DECREF(val); return -1;}\n\t\tlen = (intp) ceil(value);\n\t\tvalue = PyComplex_ImagAsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = MIN(len, (intp) ceil(value));\n\t}\n\telse {\n\t\tvalue = PyFloat_AsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = (intp) ceil(value);\n\t}\n\t\n\tif (len > 0) {\n\t\t*next = PyNumber_Add(start, step);\n\t\tif (!next) return -1;\n\t}\n\treturn len;\n}\n\n/* this doesn't change the references */\n/*MULTIARRAY_API\n ArangeObj,\n*/\nstatic PyObject *\nPyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject *step, PyArray_Descr *dtype) \n{\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *next;\n\tintp length;\n\n\tif (!dtype) {\n\t\tPyArray_Descr *deftype;\n\t\tPyArray_Descr *newtype;\n\t\tdeftype = PyArray_DescrFromType(PyArray_LONG);\n\t\tnewtype = PyArray_DescrFromObject(start, deftype);\n\t\tPy_DECREF(deftype);\n\t\tdeftype = newtype;\n\t\tif (stop && stop != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(stop, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tif (step && step != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(step, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tdtype = deftype;\n\t}\n\telse Py_INCREF(dtype);\n\n\tif (!step || step == Py_None) {\n\t\tstep = PyInt_FromLong(1);\n\t}\n\telse Py_XINCREF(step);\n\n\tif (!stop || stop == Py_None) {\n\t\tstop = start;\n\t\tstart = PyInt_FromLong(0);\n\t}\n\telse Py_INCREF(start);\n\n\t/* calculate the length and next = start + step*/\n\tlength = _calc_length(start, stop, step, &next, \n\t\t\t PyTypeNum_ISCOMPLEX(dtype->type_num));\n\n\tif (PyErr_Occurred()) {Py_DECREF(dtype); goto fail;}\n\tif (length <= 0) {\n\t\tlength = 0;\n\t\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\t\tPy_DECREF(step); Py_DECREF(start); return range;\n\t}\n\n\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\tif (range == NULL) goto fail;\n\n\tfuncs = PyArray_DESCR(range)->f;\n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tif (funcs->setitem(start, PyArray_DATA(range), (PyArrayObject *)range) < 0)\n\t\tgoto fail;\n\tif (length == 1) goto finish;\n\tif (funcs->setitem(next, PyArray_BYTES(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range) < 0) goto fail;\n\tif (length == 2) goto finish;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\tgoto fail;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\n finish:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_DECREF(next);\n\treturn range;\n\t\n fail:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_XDECREF(next);\n\treturn NULL;\n}\n\n\nstatic char doc_arange[] = \n\"arange([start,] stop[, step,], dtype=None)\\n\\n\"\n\"For integer arguments, just like range() except it returns an array whose type can\\n\"\n\"be specified by the keyword argument dtype.\\n\\n\"\n\"If dtype is not specified, the type of the result is deduced from the type of the\\n\"\n\"arguments.\\n\\n\"\n\"For floating point arguments, the length of the result is ceil((stop - start)/step).\\n\"\n\"This rule may result in the last element of the result be greater than stop.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=NULL, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tPyArray_Descr *typecode=NULL;\n\t\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_DescrConverter2,\n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\treturn PyArray_ArangeObj(o_start, o_stop, o_step, typecode);\n}\n\n/*\nIncluded at the very first so not auto-grabbed and thus not \nlabeled.\n*/\nstatic unsigned int\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (unsigned int)NDARRAY_VERSION;\n}\n\nstatic char \ndoc__get_ndarray_c_version[] = \"_get_ndarray_c_version() gets the compile time NDARRAY_VERSION number\";\n\nstatic PyObject *\narray__get_ndarray_c_version(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {NULL};\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"\", kwlist )) return NULL;\n\t\n\treturn PyInt_FromLong( (long) PyArray_GetNDArrayCVersion() );\n}\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tif (!PyCallable_Check(op)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Argument must be callable.\");\n\t\treturn NULL;\n\t}\n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (kwds && PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"one or more objects not callable\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\n/*MULTIARRAY_API\n Where\n*/\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0, NULL);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither \"\n\t\t\t\t\"of x and y should be given\");\n\t\treturn NULL;\n\t}\n\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, \n\t\t\t\t\t\t\t\tn_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_lexsort[] = \"lexsort(keys=, axis=-1) returns an array of indexes\"\\\n\t\" similar to argsort except the sorting is done using the provided sorting\"\\\n\t\" keys. First the sort is done using key[0], then the resulting list of\"\\\n\t\" indexes is further manipulated by sorting on key[0]. And so forth\"\\\n\t\" The result is a sort on multiple keys. If the keys represented columns\" \\\n\t\" of a spread-sheet, for example, this would sort using multiple columns.\"\\\n\t\" The keys argument must be a tuple of things that can be converted to \"\\\n\t\" arrays of the same shape.\";\n\nstatic PyObject *\narray_lexsort(PyObject *ignored, PyObject *args, PyObject *kwds)\n{\n\tint axis=-1;\n\tPyObject *obj;\n\tstatic char *kwlist[] = {\"keys\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|i\", kwlist, \n\t\t\t\t\t &PyTuple_Type, &obj, &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_LexSort(obj, axis));\n}\n\n#undef _ARET\n\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *d1=NULL;\n\tPyArray_Descr *d2=NULL;\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_DescrConverter, &d1,\n\t\t\t\t\tPyArray_DescrConverter, &d2))\n\t\treturn NULL;\n\tif (d1 == NULL || d2 == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types; \"\t\\\n\t\t\t\t\"'None' not accepted\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(d1, d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\nstatic char doc_new_buffer[] = \\\n\t\"newbuffer(size) return a new uninitialized buffer object of size \"\n\t\"bytes\";\n\nstatic PyObject *\nnew_buffer(PyObject *dummy, PyObject *args)\n{\n\tint size;\n\n\tif(!PyArg_ParseTuple(args, \"i\", &size))\n\t\treturn NULL;\n\t\n\treturn PyBuffer_New(size);\n}\n\nstatic char doc_buffer_buffer[] = \\\n\t\"getbuffer(obj [,offset[, size]]) create a buffer object from the \"\\\n\t\"given object\\n referencing a slice of length size starting at \"\\\n\t\"offset. Default\\n is the entire buffer. A read-write buffer is \"\\\n\t\"attempted followed by a read-only buffer.\";\n\nstatic PyObject *\nbuffer_buffer(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj;\n\tint offset=0, size=Py_END_OF_BUFFER, n;\n\tvoid *unused;\n\tstatic char *kwlist[] = {\"object\", \"offset\", \"size\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ii\", kwlist, \n\t\t\t\t\t &obj, &offset, &size))\n\t\treturn NULL;\n\n\n\tif (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {\n\t\tPyErr_Clear();\n\t\treturn PyBuffer_FromObject(obj, offset, size);\t\t\n\t}\n\telse\n\t\treturn PyBuffer_FromReadWriteObject(obj, offset, size);\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"_get_ndarray_c_version\", (PyCFunction)array__get_ndarray_c_version, \n\t METH_VARARGS|METH_KEYWORDS, doc__get_ndarray_c_version},\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"lexsort\", (PyCFunction)array_lexsort,\n\t METH_VARARGS | METH_KEYWORDS, doc_lexsort},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t{\"newbuffer\", (PyCFunction)new_buffer,\n\t METH_VARARGS, doc_new_buffer},\t\n\t{\"getbuffer\", (PyCFunction)buffer_buffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_buffer_buffer},\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Number, Generic);\n SINGLE_INHERIT(Integer, Number);\n SINGLE_INHERIT(Inexact, Number);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n\tPy##child##ArrType_Type.tp_richcompare =\t\t\t\\\n\t\tPy##parent1##_Type.tp_richcompare;\t\t\t\\\n\tPy##child##ArrType_Type.tp_compare =\t\t\t\t\\\n\t\tPy##parent1##_Type.tp_compare;\t\t\t\t\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n#if SIZEOF_LONGLONG == SIZEOF_LONG\n DUAL_INHERIT(LongLong, Int, SignedInteger);\n#else\n SINGLE_INHERIT(LongLong, SignedInteger);\n#endif\n\n /* fprintf(stderr, \"tp_free = %p, PyObject_Del = %p, int_tp_free = %p, base.tp_free = %p\\n\", PyIntArrType_Type.tp_free, PyObject_Del, PyInt_Type.tp_free, PySignedIntegerArrType_Type.tp_free);\n\t */\n\tSINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\n\tif (_multiarray_module_loaded) return;\n\t_multiarray_module_loaded = 1;\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMultiIter_Type.tp_iter = PyObject_SelfIter;\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tif (PyType_Ready(&PyArrayMultiIter_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayDescr_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayFlags_Type) < 0)\n\t\treturn;\n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMultiIter_Type);\n\tPyDict_SetItemString(d, \"broadcast\", \n\t\t\t (PyObject *)&PyArrayMultiIter_Type);\n\tPy_INCREF(&PyArrayDescr_Type);\n\tPyDict_SetItemString(d, \"dtype\", (PyObject *)&PyArrayDescr_Type);\n\n\tPy_INCREF(&PyArrayFlags_Type);\n\tPyDict_SetItemString(d, \"flagsobj\", (PyObject *)&PyArrayFlags_Type);\n\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) != 0) goto err;\n\n\t_numpy_internal =\t\t\t\t\t\t\\\n\t\tPyImport_ImportModule(\"numpy.core._internal\");\n\tif (_numpy_internal != NULL) return;\n\n err:\t\n\tif (!PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"cannot load multiarray module.\");\n\t}\n\treturn;\n}\n\n", + "methods": [ + { + "name": "_arraydescr_fromobj", + "long_name": "_arraydescr_fromobj( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 3, + "token_count": 67, + "parameters": [ + "obj" + ], + "start_line": 35, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyIntList", + "long_name": "PyArray_MultiplyIntList( register int * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 75, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyList", + "long_name": "PyArray_MultiplyList( register intp * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 86, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPtr", + "long_name": "PyArray_GetPtr( PyArrayObject * obj , register intp * ind)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "obj", + "ind" + ], + "start_line": 97, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AxisConverter", + "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 53, + "parameters": [ + "obj", + "axis" + ], + "start_line": 111, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CompareLists", + "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "l1", + "l2", + "n" + ], + "start_line": 129, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_View", + "long_name": "PyArray_View( PyArrayObject * self , PyArray_Descr * type , PyTypeObject * pytype)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self", + "type", + "pytype" + ], + "start_line": 143, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ravel", + "long_name": "PyArray_Ravel( PyArrayObject * a , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 6, + "token_count": 105, + "parameters": [ + "a", + "fortran" + ], + "start_line": 179, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "power_of_ten", + "long_name": "power_of_ten( int n)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [ + "n" + ], + "start_line": 199, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Round", + "long_name": "PyArray_Round( PyArrayObject * a , int decimals)", + "filename": "multiarraymodule.c", + "nloc": 85, + "complexity": 19, + "token_count": 614, + "parameters": [ + "a", + "decimals" + ], + "start_line": 217, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 93, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 316, + "end_line": 352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 55, + "parameters": [ + "self", + "shape" + ], + "start_line": 363, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_check_ones", + "long_name": "_check_ones( PyArrayObject * self , int newnd , intp * newdims , intp * strides)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 12, + "token_count": 189, + "parameters": [ + "self", + "newnd", + "newdims", + "strides" + ], + "start_line": 375, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_fix_unknown_dimension", + "long_name": "_fix_unknown_dimension( PyArray_Dims * newshape , intp s_original)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 8, + "token_count": 191, + "parameters": [ + "newshape", + "s_original" + ], + "start_line": 404, + "end_line": 444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 77, + "complexity": 26, + "token_count": 513, + "parameters": [ + "self", + "newdims", + "fortran" + ], + "start_line": 456, + "end_line": 550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Squeeze", + "long_name": "PyArray_Squeeze( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 5, + "token_count": 204, + "parameters": [ + "self" + ], + "start_line": 561, + "end_line": 596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Mean", + "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 19, + "complexity": 4, + "token_count": 139, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 603, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Std", + "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype , int variance)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 13, + "token_count": 450, + "parameters": [ + "self", + "axis", + "rtype", + "variance" + ], + "start_line": 631, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sum", + "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 697, + "end_line": 707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Prod", + "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 713, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumSum", + "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 729, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumProd", + "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 745, + "end_line": 756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Any", + "long_name": "PyArray_Any( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 762, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_All", + "long_name": "PyArray_All( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 779, + "end_line": 790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Compress", + "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 3, + "token_count": 102, + "parameters": [ + "self", + "condition", + "axis" + ], + "start_line": 797, + "end_line": 817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Nonzero", + "long_name": "PyArray_Nonzero( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 13, + "token_count": 414, + "parameters": [ + "self" + ], + "start_line": 823, + "end_line": 882, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Clip", + "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", + "filename": "multiarraymodule.c", + "nloc": 28, + "complexity": 6, + "token_count": 237, + "parameters": [ + "self", + "min", + "max" + ], + "start_line": 888, + "end_line": 918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Conjugate", + "long_name": "PyArray_Conjugate( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 9, + "token_count": 228, + "parameters": [ + "self" + ], + "start_line": 924, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Trace", + "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 966, + "end_line": 976, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Diagonal", + "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", + "filename": "multiarraymodule.c", + "nloc": 104, + "complexity": 23, + "token_count": 776, + "parameters": [ + "self", + "offset", + "axis1", + "axis2" + ], + "start_line": 982, + "end_line": 1101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AsCArray", + "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , PyArray_Descr * typedescr)", + "filename": "multiarraymodule.c", + "nloc": 50, + "complexity": 12, + "token_count": 402, + "parameters": [ + "op", + "ptr", + "dims", + "nd", + "typedescr" + ], + "start_line": 1117, + "end_line": 1168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As1D", + "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 71, + "parameters": [ + "op", + "ptr", + "d1", + "typecode" + ], + "start_line": 1176, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As2D", + "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 92, + "parameters": [ + "op", + "ptr", + "d1", + "d2", + "typecode" + ], + "start_line": 1192, + "end_line": 1204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Free", + "long_name": "PyArray_Free( PyObject * op , * ptr)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 4, + "token_count": 67, + "parameters": [ + "op", + "ptr" + ], + "start_line": 1212, + "end_line": 1223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_swap_and_concat", + "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 6, + "token_count": 185, + "parameters": [ + "op", + "axis", + "n" + ], + "start_line": 1227, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Concatenate", + "long_name": "PyArray_Concatenate( PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 93, + "complexity": 21, + "token_count": 623, + "parameters": [ + "op", + "axis" + ], + "start_line": 1267, + "end_line": 1372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SwapAxes", + "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 12, + "token_count": 227, + "parameters": [ + "ap", + "a1", + "a2" + ], + "start_line": 1378, + "end_line": 1419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Transpose", + "long_name": "PyArray_Transpose( PyArrayObject * ap , PyArray_Dims * permute)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 10, + "token_count": 309, + "parameters": [ + "ap", + "permute" + ], + "start_line": 1425, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Repeat", + "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 78, + "complexity": 15, + "token_count": 523, + "parameters": [ + "aop", + "op", + "axis" + ], + "start_line": 1484, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "_signbit_set", + "long_name": "_signbit_set( PyArrayObject * arr)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 89, + "parameters": [ + "arr" + ], + "start_line": 1583, + "end_line": 1600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ScalarKind", + "long_name": "PyArray_ScalarKind( int typenum , PyArrayObject ** arr)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 8, + "token_count": 80, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 1605, + "end_line": 1617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCoerceScalar", + "long_name": "PyArray_CanCoerceScalar( char thistype , char neededtype , PyArray_SCALARKIND scalar)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 1621, + "end_line": 1643, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 73, + "complexity": 15, + "token_count": 482, + "parameters": [ + "op", + "retn" + ], + "start_line": 1651, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 80, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Choose", + "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 15, + "token_count": 518, + "parameters": [ + "ip", + "op" + ], + "start_line": 1737, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 0 + }, + { + "name": "_strided_copy", + "long_name": "_strided_copy( char * dst , intp dststride , char * src , intp srcstride , intp num , int elsize)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 48, + "parameters": [ + "dst", + "dststride", + "src", + "srcstride", + "num", + "elsize" + ], + "start_line": 1821, + "end_line": 1828, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_new_sort", + "long_name": "_new_sort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 55, + "complexity": 11, + "token_count": 347, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 1839, + "end_line": 1901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_new_argsort", + "long_name": "_new_argsort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 67, + "complexity": 13, + "token_count": 498, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 1904, + "end_line": 1982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "qsortCompare", + "long_name": "qsortCompare( const * a , const * b)", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "a", + "b" + ], + "start_line": 1990, + "end_line": 1993, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sort", + "long_name": "PyArray_Sort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 52, + "complexity": 14, + "token_count": 355, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 2048, + "end_line": 2114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "argsort_static_compare", + "long_name": "argsort_static_compare( const * ip1 , const * ip2)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 1, + "token_count": 67, + "parameters": [ + "ip1", + "ip2" + ], + "start_line": 2120, + "end_line": 2128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgSort", + "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 66, + "complexity": 15, + "token_count": 493, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 2134, + "end_line": 2214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_LexSort", + "long_name": "PyArray_LexSort( PyObject * sort_keys , int axis)", + "filename": "multiarraymodule.c", + "nloc": 132, + "complexity": 36, + "token_count": 1162, + "parameters": [ + "sort_keys", + "axis" + ], + "start_line": 2226, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 145, + "top_nesting_level": 0 + }, + { + "name": "local_where", + "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 243, + "parameters": [ + "ap1", + "ap2", + "ret" + ], + "start_line": 2374, + "end_line": 2409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SearchSorted", + "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 5, + "token_count": 231, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2415, + "end_line": 2460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "new_array_for_sum", + "long_name": "new_array_for_sum( PyArrayObject * ap1 , PyArrayObject * ap2 , int nd , intp dimensions [ ] , int typenum)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 4, + "token_count": 147, + "parameters": [ + "ap1", + "ap2", + "nd", + "typenum" + ], + "start_line": 2467, + "end_line": 2491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_InnerProduct", + "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 79, + "complexity": 15, + "token_count": 624, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2500, + "end_line": 2598, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 89, + "complexity": 17, + "token_count": 680, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2606, + "end_line": 2717, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 112, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyAndTranspose", + "long_name": "PyArray_CopyAndTranspose( PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 6, + "token_count": 286, + "parameters": [ + "op" + ], + "start_line": 2723, + "end_line": 2777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Correlate", + "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", + "filename": "multiarraymodule.c", + "nloc": 86, + "complexity": 13, + "token_count": 601, + "parameters": [ + "op1", + "op2", + "mode" + ], + "start_line": 2783, + "end_line": 2880, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 98, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMin", + "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 5, + "token_count": 141, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2887, + "end_line": 2911, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Max", + "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2917, + "end_line": 2928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Min", + "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2934, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ptp", + "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 138, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2951, + "end_line": 2974, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMax", + "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 7, + "token_count": 326, + "parameters": [ + "op", + "axis" + ], + "start_line": 2981, + "end_line": 3038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Take", + "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 473, + "parameters": [ + "self0", + "indices0", + "axis" + ], + "start_line": 3045, + "end_line": 3120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Put", + "long_name": "PyArray_Put( PyArrayObject * self , PyObject * values0 , PyObject * indices0)", + "filename": "multiarraymodule.c", + "nloc": 64, + "complexity": 15, + "token_count": 479, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 3126, + "end_line": 3196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 71, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PutMask", + "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * values0 , PyObject * mask0)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 422, + "parameters": [ + "self", + "values0", + "mask0" + ], + "start_line": 3202, + "end_line": 3273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Converter", + "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 68, + "parameters": [ + "object", + "address" + ], + "start_line": 3289, + "end_line": 3301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BoolConverter", + "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "object", + "val" + ], + "start_line": 3307, + "end_line": 3315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_OrderConverter", + "long_name": "PyArray_OrderConverter( PyObject * object , PyArray_ORDER * val)", + "filename": "multiarraymodule.c", + "nloc": 29, + "complexity": 12, + "token_count": 159, + "parameters": [ + "object", + "val" + ], + "start_line": 3321, + "end_line": 3349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_TypestrConvert", + "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", + "filename": "multiarraymodule.c", + "nloc": 96, + "complexity": 35, + "token_count": 308, + "parameters": [ + "itemsize", + "gentype" + ], + "start_line": 3356, + "end_line": 3471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 116, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BufferConverter", + "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 6, + "token_count": 147, + "parameters": [ + "obj", + "buf" + ], + "start_line": 3489, + "end_line": 3514, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpConverter", + "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 10, + "token_count": 189, + "parameters": [ + "obj", + "seq" + ], + "start_line": 3529, + "end_line": 3565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "_use_inherit", + "long_name": "_use_inherit( PyArray_Descr * type , PyObject * newobj , int * errflag)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 171, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3583, + "end_line": 3621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 66, + "complexity": 16, + "token_count": 400, + "parameters": [ + "obj" + ], + "start_line": 3624, + "end_line": 3702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 93, + "complexity": 24, + "token_count": 596, + "parameters": [ + "obj" + ], + "start_line": 3710, + "end_line": 3805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 13, + "token_count": 428, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3816, + "end_line": 3887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_commastring", + "long_name": "_convert_from_commastring( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 92, + "parameters": [ + "obj", + "align" + ], + "start_line": 3900, + "end_line": 3916, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_use_fields_dict", + "long_name": "_use_fields_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "obj", + "align" + ], + "start_line": 3953, + "end_line": 3958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_dict", + "long_name": "_convert_from_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 117, + "complexity": 30, + "token_count": 752, + "parameters": [ + "obj", + "align" + ], + "start_line": 3961, + "end_line": 4087, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter2", + "long_name": "PyArray_DescrConverter2( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 37, + "parameters": [ + "obj", + "at" + ], + "start_line": 4105, + "end_line": 4112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter", + "long_name": "PyArray_DescrConverter( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 141, + "complexity": 55, + "token_count": 886, + "parameters": [ + "obj", + "at" + ], + "start_line": 4129, + "end_line": 4309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 181, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ByteorderConverter", + "long_name": "PyArray_ByteorderConverter( PyObject * obj , char * endian)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 16, + "token_count": 218, + "parameters": [ + "obj", + "endian" + ], + "start_line": 4315, + "end_line": 4347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SortkindConverter", + "long_name": "PyArray_SortkindConverter( PyObject * obj , PyArray_SORTKIND * sortkind)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 11, + "token_count": 162, + "parameters": [ + "obj", + "sortkind" + ], + "start_line": 4353, + "end_line": 4379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EquivTypes", + "long_name": "PyArray_EquivTypes( PyArray_Descr * typ1 , PyArray_Descr * typ2)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 8, + "token_count": 138, + "parameters": [ + "typ1", + "typ2" + ], + "start_line": 4388, + "end_line": 4407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_prepend_ones", + "long_name": "_prepend_ones( PyArrayObject * arr , int nd , int ndmin)", + "filename": "multiarraymodule.c", + "nloc": 23, + "complexity": 3, + "token_count": 175, + "parameters": [ + "arr", + "nd", + "ndmin" + ], + "start_line": 4412, + "end_line": 4437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 76, + "complexity": 22, + "token_count": 437, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4477, + "end_line": 4564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Empty", + "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 14, + "complexity": 4, + "token_count": 96, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 4572, + "end_line": 4587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_empty", + "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 24, + "complexity": 3, + "token_count": 148, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4593, + "end_line": 4621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_scalar", + "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 10, + "token_count": 254, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4626, + "end_line": 4684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zeros", + "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 134, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 4693, + "end_line": 4717, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_zeros", + "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 3, + "token_count": 153, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4723, + "end_line": 4750, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "array_set_typeDict", + "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "ignored", + "args" + ], + "start_line": 4757, + "end_line": 4766, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_skip_sep", + "long_name": "_skip_sep( char ** ptr , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 78, + "parameters": [ + "ptr", + "sep" + ], + "start_line": 4769, + "end_line": 4780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 133, + "complexity": 22, + "token_count": 711, + "parameters": [ + "data", + "slen", + "dtype", + "n", + "sep" + ], + "start_line": 4785, + "end_line": 4927, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 143, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 2, + "token_count": 116, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4932, + "end_line": 4949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 114, + "complexity": 22, + "token_count": 664, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4963, + "end_line": 5091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "array_fromfile", + "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 225, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 5109, + "end_line": 5147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromBuffer", + "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Descr * type , intp count , intp offset)", + "filename": "multiarraymodule.c", + "nloc": 83, + "complexity": 16, + "token_count": 446, + "parameters": [ + "buf", + "type", + "count", + "offset" + ], + "start_line": 5151, + "end_line": 5244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_frombuffer", + "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 121, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 5260, + "end_line": 5277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_concatenate", + "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 73, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5283, + "end_line": 5294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_innerproduct", + "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5301, + "end_line": 5307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_matrixproduct", + "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5314, + "end_line": 5320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_fastCopyAndTranspose", + "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 41, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5324, + "end_line": 5330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_correlate", + "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5334, + "end_line": 5343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Arange", + "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", + "filename": "multiarraymodule.c", + "nloc": 40, + "complexity": 9, + "token_count": 300, + "parameters": [ + "start", + "stop", + "step", + "type_num" + ], + "start_line": 5350, + "end_line": 5401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_calc_length", + "long_name": "_calc_length( PyObject * start , PyObject * stop , PyObject * step , PyObject ** next , int cmplx)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 10, + "token_count": 235, + "parameters": [ + "start", + "stop", + "step", + "next", + "cmplx" + ], + "start_line": 5407, + "end_line": 5439, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArangeObj", + "long_name": "PyArray_ArangeObj( PyObject * start , PyObject * stop , PyObject * step , PyArray_Descr * dtype)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 19, + "token_count": 461, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 5446, + "end_line": 5530, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "array_arange", + "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 100, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 5543, + "end_line": 5555, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNDArrayCVersion", + "long_name": "PyArray_GetNDArrayCVersion()", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 5562, + "end_line": 5565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array__get_ndarray_c_version", + "long_name": "array__get_ndarray_c_version( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 55, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5571, + "end_line": 5577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_set_string_function", + "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 98, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5583, + "end_line": 5599, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "array_set_ops_function", + "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 5605, + "end_line": 5622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Where", + "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 8, + "token_count": 233, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 5629, + "end_line": 5669, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_where", + "long_name": "array_where( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 60, + "parameters": [ + "ignored", + "args" + ], + "start_line": 5677, + "end_line": 5685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_lexsort", + "long_name": "array_lexsort( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 5697, + "end_line": 5707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_register_dtype", + "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 3, + "token_count": 64, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5716, + "end_line": 5727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_can_cast_safely", + "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 5, + "token_count": 128, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5734, + "end_line": 5757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "new_buffer", + "long_name": "new_buffer( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5764, + "end_line": 5772, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "buffer_buffer", + "long_name": "buffer_buffer( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 120, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5781, + "end_line": 5799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setup_scalartypes", + "long_name": "setup_scalartypes( PyObject * dict)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 10, + "token_count": 351, + "parameters": [ + "dict" + ], + "start_line": 5865, + "end_line": 5978, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "set_flaginfo", + "long_name": "set_flaginfo( PyObject * d)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 1, + "token_count": 152, + "parameters": [ + "d" + ], + "start_line": 5983, + "end_line": 6007, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "initmultiarray", + "long_name": "initmultiarray()", + "filename": "multiarraymodule.c", + "nloc": 57, + "complexity": 16, + "token_count": 392, + "parameters": [], + "start_line": 6012, + "end_line": 6087, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_arraydescr_fromobj", + "long_name": "_arraydescr_fromobj( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 3, + "token_count": 67, + "parameters": [ + "obj" + ], + "start_line": 35, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyIntList", + "long_name": "PyArray_MultiplyIntList( register int * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 75, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyList", + "long_name": "PyArray_MultiplyList( register intp * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 86, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPtr", + "long_name": "PyArray_GetPtr( PyArrayObject * obj , register intp * ind)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "obj", + "ind" + ], + "start_line": 97, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AxisConverter", + "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 53, + "parameters": [ + "obj", + "axis" + ], + "start_line": 111, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CompareLists", + "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "l1", + "l2", + "n" + ], + "start_line": 129, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_View", + "long_name": "PyArray_View( PyArrayObject * self , PyArray_Descr * type , PyTypeObject * pytype)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self", + "type", + "pytype" + ], + "start_line": 143, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ravel", + "long_name": "PyArray_Ravel( PyArrayObject * a , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 6, + "token_count": 105, + "parameters": [ + "a", + "fortran" + ], + "start_line": 179, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "power_of_ten", + "long_name": "power_of_ten( int n)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [ + "n" + ], + "start_line": 199, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Round", + "long_name": "PyArray_Round( PyArrayObject * a , int decimals)", + "filename": "multiarraymodule.c", + "nloc": 85, + "complexity": 19, + "token_count": 614, + "parameters": [ + "a", + "decimals" + ], + "start_line": 217, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 93, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 316, + "end_line": 352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 55, + "parameters": [ + "self", + "shape" + ], + "start_line": 363, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_check_ones", + "long_name": "_check_ones( PyArrayObject * self , int newnd , intp * newdims , intp * strides)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 12, + "token_count": 189, + "parameters": [ + "self", + "newnd", + "newdims", + "strides" + ], + "start_line": 375, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_fix_unknown_dimension", + "long_name": "_fix_unknown_dimension( PyArray_Dims * newshape , intp s_original)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 8, + "token_count": 191, + "parameters": [ + "newshape", + "s_original" + ], + "start_line": 404, + "end_line": 444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims , PyArray_ORDER fortran)", + "filename": "multiarraymodule.c", + "nloc": 77, + "complexity": 26, + "token_count": 513, + "parameters": [ + "self", + "newdims", + "fortran" + ], + "start_line": 456, + "end_line": 550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Squeeze", + "long_name": "PyArray_Squeeze( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 5, + "token_count": 204, + "parameters": [ + "self" + ], + "start_line": 561, + "end_line": 596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Mean", + "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 19, + "complexity": 4, + "token_count": 139, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 603, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Std", + "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype , int variance)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 13, + "token_count": 450, + "parameters": [ + "self", + "axis", + "rtype", + "variance" + ], + "start_line": 631, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sum", + "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 697, + "end_line": 707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Prod", + "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 713, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumSum", + "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 729, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumProd", + "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 745, + "end_line": 756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Any", + "long_name": "PyArray_Any( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 762, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_All", + "long_name": "PyArray_All( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 779, + "end_line": 790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Compress", + "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 3, + "token_count": 102, + "parameters": [ + "self", + "condition", + "axis" + ], + "start_line": 797, + "end_line": 817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Nonzero", + "long_name": "PyArray_Nonzero( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 13, + "token_count": 414, + "parameters": [ + "self" + ], + "start_line": 823, + "end_line": 882, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Clip", + "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", + "filename": "multiarraymodule.c", + "nloc": 28, + "complexity": 6, + "token_count": 237, + "parameters": [ + "self", + "min", + "max" + ], + "start_line": 888, + "end_line": 918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Conjugate", + "long_name": "PyArray_Conjugate( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 9, + "token_count": 228, + "parameters": [ + "self" + ], + "start_line": 924, + "end_line": 960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Trace", + "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 966, + "end_line": 976, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Diagonal", + "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", + "filename": "multiarraymodule.c", + "nloc": 104, + "complexity": 23, + "token_count": 776, + "parameters": [ + "self", + "offset", + "axis1", + "axis2" + ], + "start_line": 982, + "end_line": 1101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AsCArray", + "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , PyArray_Descr * typedescr)", + "filename": "multiarraymodule.c", + "nloc": 50, + "complexity": 12, + "token_count": 402, + "parameters": [ + "op", + "ptr", + "dims", + "nd", + "typedescr" + ], + "start_line": 1117, + "end_line": 1168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As1D", + "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 71, + "parameters": [ + "op", + "ptr", + "d1", + "typecode" + ], + "start_line": 1176, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As2D", + "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 92, + "parameters": [ + "op", + "ptr", + "d1", + "d2", + "typecode" + ], + "start_line": 1192, + "end_line": 1204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Free", + "long_name": "PyArray_Free( PyObject * op , * ptr)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 4, + "token_count": 67, + "parameters": [ + "op", + "ptr" + ], + "start_line": 1212, + "end_line": 1223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_swap_and_concat", + "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 6, + "token_count": 185, + "parameters": [ + "op", + "axis", + "n" + ], + "start_line": 1227, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Concatenate", + "long_name": "PyArray_Concatenate( PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 93, + "complexity": 21, + "token_count": 623, + "parameters": [ + "op", + "axis" + ], + "start_line": 1267, + "end_line": 1372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SwapAxes", + "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 12, + "token_count": 227, + "parameters": [ + "ap", + "a1", + "a2" + ], + "start_line": 1378, + "end_line": 1419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Transpose", + "long_name": "PyArray_Transpose( PyArrayObject * ap , PyArray_Dims * permute)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 10, + "token_count": 309, + "parameters": [ + "ap", + "permute" + ], + "start_line": 1425, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Repeat", + "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 78, + "complexity": 15, + "token_count": 523, + "parameters": [ + "aop", + "op", + "axis" + ], + "start_line": 1484, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "_signbit_set", + "long_name": "_signbit_set( PyArrayObject * arr)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 89, + "parameters": [ + "arr" + ], + "start_line": 1583, + "end_line": 1600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ScalarKind", + "long_name": "PyArray_ScalarKind( int typenum , PyArrayObject ** arr)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 8, + "token_count": 80, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 1605, + "end_line": 1617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCoerceScalar", + "long_name": "PyArray_CanCoerceScalar( char thistype , char neededtype , PyArray_SCALARKIND scalar)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 1621, + "end_line": 1643, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 73, + "complexity": 15, + "token_count": 482, + "parameters": [ + "op", + "retn" + ], + "start_line": 1651, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 80, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Choose", + "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 15, + "token_count": 518, + "parameters": [ + "ip", + "op" + ], + "start_line": 1737, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 0 + }, + { + "name": "_strided_copy", + "long_name": "_strided_copy( char * dst , intp dststride , char * src , intp srcstride , intp num , int elsize)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 48, + "parameters": [ + "dst", + "dststride", + "src", + "srcstride", + "num", + "elsize" + ], + "start_line": 1821, + "end_line": 1828, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_new_sort", + "long_name": "_new_sort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 8, + "token_count": 284, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 1839, + "end_line": 1893, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "_new_argsort", + "long_name": "_new_argsort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 67, + "complexity": 13, + "token_count": 498, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 1896, + "end_line": 1974, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "qsortCompare", + "long_name": "qsortCompare( const * a , const * b)", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "a", + "b" + ], + "start_line": 1982, + "end_line": 1985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sort", + "long_name": "PyArray_Sort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 52, + "complexity": 14, + "token_count": 355, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 2040, + "end_line": 2106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "argsort_static_compare", + "long_name": "argsort_static_compare( const * ip1 , const * ip2)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 1, + "token_count": 67, + "parameters": [ + "ip1", + "ip2" + ], + "start_line": 2112, + "end_line": 2120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgSort", + "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 66, + "complexity": 15, + "token_count": 493, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 2126, + "end_line": 2206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_LexSort", + "long_name": "PyArray_LexSort( PyObject * sort_keys , int axis)", + "filename": "multiarraymodule.c", + "nloc": 132, + "complexity": 36, + "token_count": 1162, + "parameters": [ + "sort_keys", + "axis" + ], + "start_line": 2218, + "end_line": 2362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 145, + "top_nesting_level": 0 + }, + { + "name": "local_where", + "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 243, + "parameters": [ + "ap1", + "ap2", + "ret" + ], + "start_line": 2366, + "end_line": 2401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SearchSorted", + "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 5, + "token_count": 231, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2407, + "end_line": 2452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "new_array_for_sum", + "long_name": "new_array_for_sum( PyArrayObject * ap1 , PyArrayObject * ap2 , int nd , intp dimensions [ ] , int typenum)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 4, + "token_count": 147, + "parameters": [ + "ap1", + "ap2", + "nd", + "typenum" + ], + "start_line": 2459, + "end_line": 2483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_InnerProduct", + "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 79, + "complexity": 15, + "token_count": 624, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2492, + "end_line": 2590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 89, + "complexity": 17, + "token_count": 680, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2598, + "end_line": 2709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 112, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyAndTranspose", + "long_name": "PyArray_CopyAndTranspose( PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 6, + "token_count": 286, + "parameters": [ + "op" + ], + "start_line": 2715, + "end_line": 2769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Correlate", + "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", + "filename": "multiarraymodule.c", + "nloc": 86, + "complexity": 13, + "token_count": 601, + "parameters": [ + "op1", + "op2", + "mode" + ], + "start_line": 2775, + "end_line": 2872, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 98, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMin", + "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 5, + "token_count": 141, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2879, + "end_line": 2903, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Max", + "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2909, + "end_line": 2920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Min", + "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2926, + "end_line": 2937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ptp", + "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 138, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2943, + "end_line": 2966, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMax", + "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 7, + "token_count": 326, + "parameters": [ + "op", + "axis" + ], + "start_line": 2973, + "end_line": 3030, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Take", + "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 473, + "parameters": [ + "self0", + "indices0", + "axis" + ], + "start_line": 3037, + "end_line": 3112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Put", + "long_name": "PyArray_Put( PyArrayObject * self , PyObject * values0 , PyObject * indices0)", + "filename": "multiarraymodule.c", + "nloc": 64, + "complexity": 15, + "token_count": 479, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 3118, + "end_line": 3188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 71, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PutMask", + "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * values0 , PyObject * mask0)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 422, + "parameters": [ + "self", + "values0", + "mask0" + ], + "start_line": 3194, + "end_line": 3265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Converter", + "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 68, + "parameters": [ + "object", + "address" + ], + "start_line": 3281, + "end_line": 3293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BoolConverter", + "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "object", + "val" + ], + "start_line": 3299, + "end_line": 3307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_OrderConverter", + "long_name": "PyArray_OrderConverter( PyObject * object , PyArray_ORDER * val)", + "filename": "multiarraymodule.c", + "nloc": 29, + "complexity": 12, + "token_count": 159, + "parameters": [ + "object", + "val" + ], + "start_line": 3313, + "end_line": 3341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_TypestrConvert", + "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", + "filename": "multiarraymodule.c", + "nloc": 96, + "complexity": 35, + "token_count": 308, + "parameters": [ + "itemsize", + "gentype" + ], + "start_line": 3348, + "end_line": 3463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 116, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BufferConverter", + "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 6, + "token_count": 147, + "parameters": [ + "obj", + "buf" + ], + "start_line": 3481, + "end_line": 3506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpConverter", + "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 10, + "token_count": 189, + "parameters": [ + "obj", + "seq" + ], + "start_line": 3521, + "end_line": 3557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "_use_inherit", + "long_name": "_use_inherit( PyArray_Descr * type , PyObject * newobj , int * errflag)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 171, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3575, + "end_line": 3613, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 66, + "complexity": 16, + "token_count": 400, + "parameters": [ + "obj" + ], + "start_line": 3616, + "end_line": 3694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 93, + "complexity": 24, + "token_count": 596, + "parameters": [ + "obj" + ], + "start_line": 3702, + "end_line": 3797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 13, + "token_count": 428, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3808, + "end_line": 3879, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_commastring", + "long_name": "_convert_from_commastring( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 92, + "parameters": [ + "obj", + "align" + ], + "start_line": 3892, + "end_line": 3908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_use_fields_dict", + "long_name": "_use_fields_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "obj", + "align" + ], + "start_line": 3945, + "end_line": 3950, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_dict", + "long_name": "_convert_from_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 117, + "complexity": 30, + "token_count": 752, + "parameters": [ + "obj", + "align" + ], + "start_line": 3953, + "end_line": 4079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter2", + "long_name": "PyArray_DescrConverter2( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 37, + "parameters": [ + "obj", + "at" + ], + "start_line": 4097, + "end_line": 4104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter", + "long_name": "PyArray_DescrConverter( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 141, + "complexity": 55, + "token_count": 886, + "parameters": [ + "obj", + "at" + ], + "start_line": 4121, + "end_line": 4301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 181, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ByteorderConverter", + "long_name": "PyArray_ByteorderConverter( PyObject * obj , char * endian)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 16, + "token_count": 218, + "parameters": [ + "obj", + "endian" + ], + "start_line": 4307, + "end_line": 4339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SortkindConverter", + "long_name": "PyArray_SortkindConverter( PyObject * obj , PyArray_SORTKIND * sortkind)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 11, + "token_count": 162, + "parameters": [ + "obj", + "sortkind" + ], + "start_line": 4345, + "end_line": 4371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EquivTypes", + "long_name": "PyArray_EquivTypes( PyArray_Descr * typ1 , PyArray_Descr * typ2)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 8, + "token_count": 138, + "parameters": [ + "typ1", + "typ2" + ], + "start_line": 4380, + "end_line": 4399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_prepend_ones", + "long_name": "_prepend_ones( PyArrayObject * arr , int nd , int ndmin)", + "filename": "multiarraymodule.c", + "nloc": 23, + "complexity": 3, + "token_count": 175, + "parameters": [ + "arr", + "nd", + "ndmin" + ], + "start_line": 4404, + "end_line": 4429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 76, + "complexity": 22, + "token_count": 437, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4469, + "end_line": 4556, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Empty", + "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 14, + "complexity": 4, + "token_count": 96, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 4564, + "end_line": 4579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_empty", + "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 24, + "complexity": 3, + "token_count": 148, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4585, + "end_line": 4613, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_scalar", + "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 10, + "token_count": 254, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4618, + "end_line": 4676, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zeros", + "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 134, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 4685, + "end_line": 4709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_zeros", + "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 3, + "token_count": 153, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4715, + "end_line": 4742, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "array_set_typeDict", + "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "ignored", + "args" + ], + "start_line": 4749, + "end_line": 4758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_skip_sep", + "long_name": "_skip_sep( char ** ptr , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 78, + "parameters": [ + "ptr", + "sep" + ], + "start_line": 4761, + "end_line": 4772, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 133, + "complexity": 22, + "token_count": 711, + "parameters": [ + "data", + "slen", + "dtype", + "n", + "sep" + ], + "start_line": 4777, + "end_line": 4919, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 143, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 2, + "token_count": 116, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4924, + "end_line": 4941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 114, + "complexity": 22, + "token_count": 664, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4955, + "end_line": 5083, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "array_fromfile", + "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 225, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 5101, + "end_line": 5139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromBuffer", + "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Descr * type , intp count , intp offset)", + "filename": "multiarraymodule.c", + "nloc": 83, + "complexity": 16, + "token_count": 446, + "parameters": [ + "buf", + "type", + "count", + "offset" + ], + "start_line": 5143, + "end_line": 5236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_frombuffer", + "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 121, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 5252, + "end_line": 5269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_concatenate", + "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 73, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5275, + "end_line": 5286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_innerproduct", + "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5293, + "end_line": 5299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_matrixproduct", + "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5306, + "end_line": 5312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_fastCopyAndTranspose", + "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 41, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5316, + "end_line": 5322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_correlate", + "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5326, + "end_line": 5335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Arange", + "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", + "filename": "multiarraymodule.c", + "nloc": 40, + "complexity": 9, + "token_count": 300, + "parameters": [ + "start", + "stop", + "step", + "type_num" + ], + "start_line": 5342, + "end_line": 5393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_calc_length", + "long_name": "_calc_length( PyObject * start , PyObject * stop , PyObject * step , PyObject ** next , int cmplx)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 10, + "token_count": 235, + "parameters": [ + "start", + "stop", + "step", + "next", + "cmplx" + ], + "start_line": 5399, + "end_line": 5431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArangeObj", + "long_name": "PyArray_ArangeObj( PyObject * start , PyObject * stop , PyObject * step , PyArray_Descr * dtype)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 19, + "token_count": 461, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 5438, + "end_line": 5522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "array_arange", + "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 100, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 5535, + "end_line": 5547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNDArrayCVersion", + "long_name": "PyArray_GetNDArrayCVersion()", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 5554, + "end_line": 5557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array__get_ndarray_c_version", + "long_name": "array__get_ndarray_c_version( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 55, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5563, + "end_line": 5569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_set_string_function", + "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 98, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5575, + "end_line": 5591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "array_set_ops_function", + "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 5597, + "end_line": 5614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Where", + "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 8, + "token_count": 233, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 5621, + "end_line": 5661, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_where", + "long_name": "array_where( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 60, + "parameters": [ + "ignored", + "args" + ], + "start_line": 5669, + "end_line": 5677, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_lexsort", + "long_name": "array_lexsort( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 5689, + "end_line": 5699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_register_dtype", + "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 3, + "token_count": 64, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5708, + "end_line": 5719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_can_cast_safely", + "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 5, + "token_count": 128, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5726, + "end_line": 5749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "new_buffer", + "long_name": "new_buffer( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "dummy", + "args" + ], + "start_line": 5756, + "end_line": 5764, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "buffer_buffer", + "long_name": "buffer_buffer( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 120, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 5773, + "end_line": 5791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setup_scalartypes", + "long_name": "setup_scalartypes( PyObject * dict)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 10, + "token_count": 351, + "parameters": [ + "dict" + ], + "start_line": 5857, + "end_line": 5970, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "set_flaginfo", + "long_name": "set_flaginfo( PyObject * d)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 1, + "token_count": 152, + "parameters": [ + "d" + ], + "start_line": 5975, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "initmultiarray", + "long_name": "initmultiarray()", + "filename": "multiarraymodule.c", + "nloc": 57, + "complexity": 16, + "token_count": 392, + "parameters": [], + "start_line": 6004, + "end_line": 6079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_new_sort", + "long_name": "_new_sort( PyArrayObject * op , int axis , PyArray_SORTKIND which)", + "filename": "multiarraymodule.c", + "nloc": 55, + "complexity": 11, + "token_count": 347, + "parameters": [ + "op", + "axis", + "which" + ], + "start_line": 1839, + "end_line": 1901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + } + ], + "nloc": 4651, + "complexity": 1043, + "token_count": 30033, + "diff_parsed": { + "added": [ + "\tint needcopy=0, swap;", + "\tswap = !PyArray_ISNOTSWAPPED(op);", + "\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize) \\", + "\t\t|| swap;", + "\t\t\tif (swap) {", + "\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);", + "\t\t\t}", + "\t\t\tif (swap) {", + "\t\t\t\top->descr->f->copyswapn(buffer, NULL, N, 1, elsize);", + "\t\t\t}" + ], + "deleted": [ + "\tint needcopy=0;", + "\tneedcopy = !(op->flags & ALIGNED) || (astride != (intp) elsize);" + ] + } + } + ] + }, + { + "hash": "f2337b8095ca09312b4486c99b82dea05ae3ac58", + "msg": "site.scfg.example added", + "author": { + "name": "Robert Cimrman", + "email": "cimrman3@ntc.zcu.cz" + }, + "committer": { + "name": "Robert Cimrman", + "email": "cimrman3@ntc.zcu.cz" + }, + "author_date": "2006-04-06T12:06:47+00:00", + "author_timezone": 0, + "committer_date": "2006-04-06T12:06:47+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "035720e9fa8fe6ba910ec92b38aa7a28cc63e692" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 0, + "insertions": 8, + "lines": 8, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": null, + "new_path": "site.cfg.example", + "filename": "site.cfg.example", + "extension": "example", + "change_type": "ADD", + "diff": "@@ -0,0 +1,8 @@\n+[atlas]\n+library_dirs = \n+atlas_libs = lapack, blas, cblas, atlas\n+\n+[umfpack]\n+library_dirs = \n+include_dirs = \n+umfpack_libs = umfpack, amd\n", + "added_lines": 8, + "deleted_lines": 0, + "source_code": "[atlas]\nlibrary_dirs = \natlas_libs = lapack, blas, cblas, atlas\n\n[umfpack]\nlibrary_dirs = \ninclude_dirs = \numfpack_libs = umfpack, amd\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "[atlas]", + "library_dirs = ", + "atlas_libs = lapack, blas, cblas, atlas", + "", + "[umfpack]", + "library_dirs = ", + "include_dirs = ", + "umfpack_libs = umfpack, amd" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "b6427785d14ee282c6e4251771f8a48283a0ecaf", + "msg": "more array methods in ma (thanks Pierre GM )", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-04-06T23:08:24+00:00", + "author_timezone": 0, + "committer_date": "2006-04-06T23:08:24+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f2337b8095ca09312b4486c99b82dea05ae3ac58" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 8, + "insertions": 71, + "lines": 79, + "files": 2, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.5849056603773585, + "modified_files": [ + { + "old_path": "numpy/core/ma.py", + "new_path": "numpy/core/ma.py", + "filename": "ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2138,8 +2138,10 @@ def _choose(self, *args):\n del _choose\n \n def _clip(self,a_min,a_max):\n- return MaskedArray(data = self.data.clip(a_min, a_max),\n- mask = self.mask)\n+ return MaskedArray(data = self.data.clip(asarray(a_min).data, \n+ asarray(a_max).data),\n+ mask = mask_or(self.mask,\n+ mask_or(getmask(a_min),getmask(a_max))))\n array.clip = _m(_clip)\n \n def _compress(self, cond, axis=None):\n@@ -2149,8 +2151,21 @@ def _compress(self, cond, axis=None):\n \n array.conj = array.conjugate = _m(conjugate)\n array.copy = _m(not_implemented)\n-array.cumprod = _m(not_implemented)\n-array.cumsum = _m(not_implemented)\n+\n+def _cumprod(self, axis=0, dtype=None):\n+ m = self.mask\n+ if m is not nomask:\n+ m = umath.logical_and.accumulate(self.mask, axis)\n+ return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)\n+array.cumprod = _m(_cumprod)\n+\n+def _cumsum(self, axis=0, dtype=None):\n+ m = self.mask\n+ if m is not nomask:\n+ m = umath.logical_and.accumulate(self.mask, axis)\n+ return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)\n+array.cumsum = _m(_cumsum)\n+\n array.diagonal = _m(diagonal)\n array.dump = _m(not_implemented)\n array.dumps = _m(not_implemented)\n@@ -2158,6 +2173,7 @@ def _compress(self, cond, axis=None):\n array.flags = property(_m(not_implemented))\n array.flatten = _m(ravel)\n array.getfield = _m(not_implemented)\n+\n def _max(a, axis=None):\n if axis is None:\n return maximum(a)\n@@ -2180,7 +2196,6 @@ def _min(a, axis=None):\n \n def _ptp(a,axis=0):\n return a.max(axis)-a.min(axis)\n-\n array.ptp = _m(_ptp)\n array.repeat = _m(repeat)\n array.resize = _m(resize)\n@@ -2188,8 +2203,16 @@ def _ptp(a,axis=0):\n array.setfield = _m(not_implemented)\n array.setflags = _m(not_implemented)\n array.sort = _m(not_implemented) # NB: ndarray.sort is inplace\n-array.squeeze = _m(not_implemented)\n-array.std = _m(not_implemented)\n+\n+def _squeeze(self):\n+ try:\n+ result = MaskedArray(data = self.data.squeeze(),\n+ mask = self.mask.squeeze())\n+ except AttributeError:\n+ result = _wrapit(self, 'squeeze')\n+ return result\n+array.squeeze = _m(_squeeze) \n+\n array.strides = property(_m(not_implemented))\n array.sum = _m(sum)\n def _swapaxes(self,axis1,axis2):\n@@ -2200,7 +2223,20 @@ def _swapaxes(self,axis1,axis2):\n array.tofile = _m(not_implemented)\n array.trace = _m(trace)\n array.transpose = _m(transpose)\n-array.var = _m(not_implemented)\n+\n+def _var(self,axis=0,dtype=None):\n+ if axis is None:\n+ return asarray(self.compressed()).var()\n+ a = self.swapaxes(axis,0)\n+ a = a - a.mean(axis=0)\n+ a *= a\n+ a /= (a.count(axis=0)-1)\n+ return a.swapaxes(0,axis).sum(axis)\n+def _std(self,axis=0,dtype=None):\n+ return (self.var(axis,dtype))**0.5\n+array.var = _m(_var)\n+array.std = _m(_std)\n+\n array.view = _m(not_implemented)\n array.round = _m(around)\n del _m, MethodType, not_implemented\n", + "added_lines": 44, + "deleted_lines": 8, + "source_code": "\"\"\"MA: a facility for dealing with missing observations\nMA is generally used as a numpy.array look-alike.\nby Paul F. Dubois.\n\nCopyright 1999, 2000, 2001 Regents of the University of California.\nReleased for unlimited redistribution.\nAdapted for numpy_core 2005 by Travis Oliphant and\n(mainly) Paul Dubois.\n\"\"\"\nimport types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import bool_\nimport numeric\nimport warnings\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType = bool_\nnomask = MaskType(0)\ndivide_tolerance = 1.e-35\n\nclass MAError (Exception):\n def __init__ (self, args=None):\n \"Create an exception\"\n self.args = args\n def __str__(self):\n \"Calculate the string representation\"\n return str(self.args)\n __repr__ = __str__\n\nclass _MaskedPrintOption:\n \"One instance of this class, masked_print_option, is created.\"\n def __init__ (self, display):\n \"Create the masked print option object.\"\n self.set_display(display)\n self._enabled = 1\n\n def display (self):\n \"Show what prints for masked values.\"\n return self._display\n\n def set_display (self, s):\n \"set_display(s) sets what prints for masked values.\"\n self._display = s\n\n def enabled (self):\n \"Is the use of the display value enabled?\"\n return self._enabled\n\n def enable(self, flag=1):\n \"Set the enabling flag to flag.\"\n self._enabled = flag\n\n def __str__ (self):\n return str(self._display)\n\n __repr__ = __str__\n\n#if you single index into a masked location you get this object.\nmasked_print_option = _MaskedPrintOption('--')\n\n# Use single element arrays or scalars.\ndefault_real_fill_value = 1.e20\ndefault_complex_fill_value = 1.e20 + 0.0j\ndefault_character_fill_value = '-'\ndefault_integer_fill_value = 999999\ndefault_object_fill_value = '?'\n\ndef default_fill_value (obj):\n \"Function to calculate default fill value for an object.\"\n if isinstance(obj, types.FloatType):\n return default_real_fill_value\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return default_integer_fill_value\n elif isinstance(obj, types.StringType):\n return default_character_fill_value\n elif isinstance(obj, types.ComplexType):\n return default_complex_fill_value\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return default_real_fill_value\n if x in typecodes['Integer']:\n return default_integer_fill_value\n if x in typecodes['Complex']:\n return default_complex_fill_value\n if x in typecodes['Character']:\n return default_character_fill_value\n if x in typecodes['UnsignedInteger']:\n return umath.absolute(default_integer_fill_value)\n return default_object_fill_value\n else:\n return default_object_fill_value\n\ndef minimum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking minima.\"\n if isinstance(obj, types.FloatType):\n return numeric.inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return numeric.inf\n if x in typecodes['Integer']:\n return sys.maxint\n if x in typecodes['UnsignedInteger']:\n return sys.maxint\n else:\n raise TypeError, 'Unsuitable type for calculating minimum.'\n\ndef maximum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking maxima.\"\n if isinstance(obj, types.FloatType):\n return -inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return -sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return -inf\n if x in typecodes['Integer']:\n return -sys.maxint\n if x in typecodes['UnsignedInteger']:\n return 0\n else:\n raise TypeError, 'Unsuitable type for calculating maximum.'\n\ndef set_fill_value (a, fill_value):\n \"Set fill value of a if it is a masked array.\"\n if isMaskedArray(a):\n a.set_fill_value (fill_value)\n\ndef getmask (a):\n \"\"\"Mask of values in a; could be nomask.\n Returns nomask if a is not a masked array.\n To get an array for sure use getmaskarray.\"\"\"\n if isinstance(a, MaskedArray):\n return a.raw_mask()\n else:\n return nomask\n\ndef getmaskarray (a):\n \"\"\"Mask of values in a; an array of zeros if mask is nomask\n or not a masked array, and is a byte-sized integer.\n Do not try to add up entries, for example.\n \"\"\"\n m = getmask(a)\n if m is nomask:\n return make_mask_none(shape(a))\n else:\n return m\n\ndef is_mask (m):\n \"\"\"Is m a legal mask? Does not check contents, only type.\n \"\"\"\n try:\n return m.dtype.type is MaskType\n except AttributeError:\n return False\n\ndef make_mask (m, copy=0, flag=0):\n \"\"\"make_mask(m, copy=0, flag=0)\n return m as a mask, creating a copy if necessary or requested.\n Can accept any sequence of integers or nomask. Does not check\n that contents must be 0s and 1s.\n if flag, return nomask if m contains no true elements.\n \"\"\"\n if m is nomask:\n return nomask\n elif isinstance(m, ndarray):\n if m.dtype.type is MaskType:\n if copy:\n result = numeric.array(m, dtype=MaskType, copy=copy)\n else:\n result = m\n else:\n result = m.astype(MaskType)\n else:\n result = filled(m, True).astype(MaskType)\n\n if flag and not oldnumeric.sometrue(oldnumeric.ravel(result)):\n return nomask\n else:\n return result\n\ndef make_mask_none (s):\n \"Return a mask of all zeros of shape s.\"\n result = numeric.zeros(s, dtype=MaskType)\n result.shape = s\n return result\n\ndef mask_or (m1, m2):\n \"\"\"Logical or of the mask candidates m1 and m2, treating nomask as false.\n Result may equal m1 or m2 if the other is nomask.\n \"\"\"\n if m1 is nomask: return make_mask(m2)\n if m2 is nomask: return make_mask(m1)\n if m1 is m2 and is_mask(m1): return m1\n return make_mask(umath.logical_or(m1, m2))\n\ndef filled (a, value = None):\n \"\"\"a as a contiguous numeric array with any masked areas replaced by value\n if value is None or the special element \"masked\", get_fill_value(a)\n is used instead.\n\n If a is already a contiguous numeric array, a itself is returned.\n\n filled(a) can be used to be sure that the result is numeric when\n passing an object a to other software ignorant of MA, in particular to\n numeric itself.\n \"\"\"\n if isinstance(a, MaskedArray):\n return a.filled(value)\n elif isinstance(a, ndarray) and a.flags['CONTIGUOUS']:\n return a\n elif isinstance(a, types.DictType):\n return numeric.array(a, 'O')\n else:\n return numeric.array(a)\n\ndef get_fill_value (a):\n \"\"\"\n The fill value of a, if it has one; otherwise, the default fill value\n for that type.\n \"\"\"\n if isMaskedArray(a):\n result = a.fill_value()\n else:\n result = default_fill_value(a)\n return result\n\ndef common_fill_value (a, b):\n \"The common fill_value of a and b, if there is one, or None\"\n t1 = get_fill_value(a)\n t2 = get_fill_value(b)\n if t1 == t2: return t1\n return None\n\n# Domain functions return 1 where the argument(s) are not in the domain.\nclass domain_check_interval:\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n def __init__(self, y1, y2):\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n self.y1 = y1\n self.y2 = y2\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.logical_or(umath.greater (x, self.y2),\n umath.less(x, self.y1)\n )\n\nclass domain_tan:\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n def __init__(self, eps):\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n self.eps = eps\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less(umath.absolute(umath.cos(x)), self.eps)\n\nclass domain_greater:\n \"domain_greater(v)(x) = true where x <= v\"\n def __init__(self, critical_value):\n \"domain_greater(v)(x) = true where x <= v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less_equal (x, self.critical_value)\n\nclass domain_greater_equal:\n \"domain_greater_equal(v)(x) = true where x < v\"\n def __init__(self, critical_value):\n \"domain_greater_equal(v)(x) = true where x < v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less (x, self.critical_value)\n\nclass masked_unary_operation:\n def __init__ (self, aufunc, fill=0, domain=None):\n \"\"\" masked_unary_operation(aufunc, fill=0, domain=None)\n aufunc(fill) must be defined\n self(x) returns aufunc(x)\n with masked values where domain(x) is true or getmask(x) is true.\n \"\"\"\n self.f = aufunc\n self.fill = fill\n self.domain = domain\n self.__doc__ = getattr(aufunc, \"__doc__\", str(aufunc))\n self.__name__ = getattr(aufunc, \"__name__\", str(aufunc))\n ufunc_domain[aufunc] = domain\n ufunc_fills[aufunc] = fill,\n\n def __call__ (self, a, *args, **kwargs):\n \"Execute the call behavior.\"\n# numeric tries to return scalars rather than arrays when given scalars.\n m = getmask(a)\n d1 = filled(a, self.fill)\n if self.domain is not None:\n m = mask_or(m, self.domain(d1))\n result = self.f(d1, *args, **kwargs)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\n\nclass domain_safe_divide:\n def __init__ (self, tolerance=divide_tolerance):\n self.tolerance = tolerance\n def __call__ (self, a, b):\n return umath.absolute(a) * self.tolerance >= umath.absolute(b)\n\nclass domained_binary_operation:\n \"\"\"Binary operations that have a domain, like divide. These are complicated\n so they are a separate class. They have no reduce, outer or accumulate.\n \"\"\"\n def __init__ (self, abfunc, domain, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.domain = domain\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n self.__name__ = getattr(abfunc, \"__name__\", str(abfunc))\n ufunc_domain[abfunc] = domain\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__(self, a, b):\n \"Execute the call behavior.\"\n ma = getmask(a)\n mb = getmask(b)\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n t = self.domain(d1, d2)\n\n if oldnumeric.sometrue(t, None):\n d2 = where(t, self.filly, d2)\n mb = mask_or(mb, t)\n m = mask_or(ma, mb)\n result = self.f(d1, d2)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nclass masked_binary_operation:\n def __init__ (self, abfunc, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n ufunc_domain[abfunc] = None\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__ (self, a, b, *args, **kwargs):\n \"Execute the call behavior.\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n result = self.f(d1, d2, *args, **kwargs)\n return masked_array(result, m)\n\n def reduce (self, target, axis=0, dtype=None):\n \"\"\"Reduce target along the given axis with this function.\"\"\"\n m = getmask(target)\n t = filled(target, self.filly)\n if t.shape == ():\n t = t.reshape(1)\n if m is not nomask:\n m = make_mask(m, copy=1)\n m.shape = (1,)\n if m is nomask:\n return masked_array (self.f.reduce (t, axis))\n else:\n t = masked_array (t, m)\n # XXX: \"or t.dtype\" below is a workaround for what appears\n # XXX: to be a bug in reduce.\n t = self.f.reduce(filled(t, self.filly), axis, dtype=dtype or t.dtype)\n m = umath.logical_and.reduce(m, axis)\n if isinstance(t, ndarray):\n return masked_array(t, m, get_fill_value(target))\n elif m:\n return masked\n else:\n return t\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = self.f.outer(filled(a, self.fillx), filled(b, self.filly))\n return masked_array(d, m)\n\n def accumulate (self, target, axis=0):\n \"\"\"Accumulate target along axis after filling with y fill value.\"\"\"\n t = filled(target, self.filly)\n return masked_array (self.f.accumulate (t, axis))\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nsqrt = masked_unary_operation(umath.sqrt, 0.0, domain_greater_equal(0.0))\nlog = masked_unary_operation(umath.log, 1.0, domain_greater(0.0))\nlog10 = masked_unary_operation(umath.log10, 1.0, domain_greater(0.0))\nexp = masked_unary_operation(umath.exp)\nconjugate = masked_unary_operation(umath.conjugate)\nsin = masked_unary_operation(umath.sin)\ncos = masked_unary_operation(umath.cos)\ntan = masked_unary_operation(umath.tan, 0.0, domain_tan(1.e-35))\narcsin = masked_unary_operation(umath.arcsin, 0.0, domain_check_interval(-1.0, 1.0))\narccos = masked_unary_operation(umath.arccos, 0.0, domain_check_interval(-1.0, 1.0))\narctan = masked_unary_operation(umath.arctan)\n# Missing from numeric\narcsinh = masked_unary_operation(umath.arcsinh)\narccosh = masked_unary_operation(umath.arccosh, 1.0, domain_greater_equal(1.0))\narctanh = masked_unary_operation(umath.arctanh, 0.0, domain_check_interval(-1.0+1e-15, 1.0-1e-15))\nsinh = masked_unary_operation(umath.sinh)\ncosh = masked_unary_operation(umath.cosh)\ntanh = masked_unary_operation(umath.tanh)\nabsolute = masked_unary_operation(umath.absolute)\nfabs = masked_unary_operation(umath.fabs)\nnegative = masked_unary_operation(umath.negative)\n\ndef nonzero(a):\n \"\"\"returns the indices of the elements of a which are not zero and not masked\n\n a must be 1d\n \"\"\"\n return asarray(filled(a, 0).nonzero())\n\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nlogical_not = masked_unary_operation(umath.logical_not)\n\nadd = masked_binary_operation(umath.add)\nsubtract = masked_binary_operation(umath.subtract)\nsubtract.reduce = None\nmultiply = masked_binary_operation(umath.multiply, 1, 1)\ndivide = domained_binary_operation(umath.divide, domain_safe_divide(), 0, 1)\ntrue_divide = domained_binary_operation(umath.true_divide, domain_safe_divide(), 0, 1)\nfloor_divide = domained_binary_operation(umath.floor_divide, domain_safe_divide(), 0, 1)\nremainder = domained_binary_operation(umath.remainder, domain_safe_divide(), 0, 1)\nfmod = domained_binary_operation(umath.fmod, domain_safe_divide(), 0, 1)\nhypot = masked_binary_operation(umath.hypot)\narctan2 = masked_binary_operation(umath.arctan2, 0.0, 1.0)\narctan2.reduce = None\nequal = masked_binary_operation(umath.equal)\nequal.reduce = None\nnot_equal = masked_binary_operation(umath.not_equal)\nnot_equal.reduce = None\nless_equal = masked_binary_operation(umath.less_equal)\nless_equal.reduce = None\ngreater_equal = masked_binary_operation(umath.greater_equal)\ngreater_equal.reduce = None\nless = masked_binary_operation(umath.less)\nless.reduce = None\ngreater = masked_binary_operation(umath.greater)\ngreater.reduce = None\nlogical_and = masked_binary_operation(umath.logical_and)\nalltrue = masked_binary_operation(umath.logical_and, 1, 1).reduce\nlogical_or = masked_binary_operation(umath.logical_or)\nsometrue = logical_or.reduce\nlogical_xor = masked_binary_operation(umath.logical_xor)\nbitwise_and = masked_binary_operation(umath.bitwise_and)\nbitwise_or = masked_binary_operation(umath.bitwise_or)\nbitwise_xor = masked_binary_operation(umath.bitwise_xor)\n\ndef rank (object):\n return oldnumeric.rank(filled(object))\n\ndef shape (object):\n return oldnumeric.shape(filled(object))\n\ndef size (object, axis=None):\n return oldnumeric.size(filled(object), axis)\n\nclass MaskedArray (object):\n \"\"\"Arrays with possibly masked values.\n Masked values of 1 exclude the corresponding element from\n any computation.\n\n Construction:\n x = array(data, dtype=None, copy=True, order=False,\n mask = nomask, fill_value=None)\n\n If copy=False, every effort is made not to copy the data:\n If data is a MaskedArray, and argument mask=nomask,\n then the candidate data is data.data and the\n mask used is data.mask. If data is a numeric array,\n it is used as the candidate raw data.\n If dtype.char is not None and\n is != data.dtype.char then a data copy is required.\n Otherwise, the candidate is used.\n\n If a data copy is required, raw data stored is the result of:\n numeric.array(data, dtype=dtype.char, copy=copy)\n\n If mask is nomask there are no masked values. Otherwise mask must\n be convertible to an array of booleans with the same shape as x.\n\n fill_value is used to fill in masked values when necessary,\n such as when printing and in method/function filled().\n The fill_value is not used for computation within this module.\n \"\"\"\n __array_priority__ = 10.1\n def __init__(self, data, dtype=None, copy=True, order=False,\n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None)\n If data already a numeric array, its dtype becomes the default value of dtype.\n \"\"\"\n if dtype is None:\n tc = None\n else:\n tc = numeric.dtype(dtype)\n need_data_copied = copy\n if isinstance(data, MaskedArray):\n c = data.data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n if mask is nomask:\n mask = data.mask\n elif mask is not nomask: #attempting to change the mask\n need_data_copied = True\n\n elif isinstance(data, ndarray):\n c = data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n else:\n need_data_copied = False #because I'll do it now\n c = numeric.array(data, dtype=tc, copy=True, order=order)\n tc = c.dtype\n\n if need_data_copied:\n if tc == c.dtype:\n self._data = numeric.array(c, dtype=tc, copy=True, order=order)\n else:\n self._data = c.astype(tc)\n else:\n self._data = c\n\n if mask is nomask:\n self._mask = nomask\n self._shared_mask = 0\n else:\n self._mask = make_mask (mask)\n if self._mask is nomask:\n self._shared_mask = 0\n else:\n self._shared_mask = (self._mask is mask)\n nm = size(self._mask)\n nd = size(self._data)\n if nm != nd:\n if nm == 1:\n self._mask = oldnumeric.resize(self._mask, self._data.shape)\n self._shared_mask = 0\n elif nd == 1:\n self._data = oldnumeric.resize(self._data, self._mask.shape)\n self._data.shape = self._mask.shape\n else:\n raise MAError, \"Mask and data not compatible.\"\n elif nm == 1 and shape(self._mask) != shape(self._data):\n self.unshare_mask()\n self._mask.shape = self._data.shape\n\n self.set_fill_value(fill_value)\n\n def __array__ (self, t=None, context=None):\n \"Special hook for numeric. Converts to numeric if possible.\"\n if self._mask is not nomask:\n if oldnumeric.ravel(self._mask).any():\n if context is None:\n warnings.warn(\"Cannot automatically convert masked array to \"\\\n \"numeric because data\\n is masked in one or \"\\\n \"more locations.\");\n return self._data\n #raise MAError, \\\n # \"\"\"Cannot automatically convert masked array to numeric because data\n # is masked in one or more locations.\n # \"\"\"\n else:\n func, args, i = context\n fills = ufunc_fills.get(func)\n if fills is None:\n raise MAError, \"%s not known to ma\" % func\n return self.filled(fills[i])\n else: # Mask is all false\n # Optimize to avoid future invocations of this section.\n self._mask = nomask\n self._shared_mask = 0\n if t:\n return self._data.astype(t)\n else:\n return self._data\n\n def __array_wrap__ (self, array, context):\n \"\"\"Special hook for ufuncs.\n\n Wraps the numpy array and sets the mask according to\n context.\n \"\"\"\n func, args = context[:2]\n domain = ufunc_domain[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[getattr(a, '_data', a)\n for a in args]))\n if m is not nomask:\n try:\n shape = array.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = reduce(mask_or, [getmaskarray(a) for a in args])\n\n return MaskedArray(array, copy=False, mask=m)\n\n def _get_shape(self):\n \"Return the current shape.\"\n return self._data.shape\n\n def _set_shape (self, newshape):\n \"Set the array's shape.\"\n self._data.shape = newshape\n if self._mask is not nomask:\n self._mask = self._mask.copy()\n self._mask.shape = newshape\n\n def _get_flat(self):\n \"\"\"Calculate the flat value.\n \"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel(), mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.ravel(),\n mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_flat (self, value):\n \"x.flat = value\"\n y = self.ravel()\n y[:] = value\n\n def _get_real(self):\n \"Get the real part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.real, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.real, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_real (self, value):\n \"x.real = value\"\n y = self.real\n y[...] = value\n\n def _get_imaginary(self):\n \"Get the imaginary part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.imag, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.imag, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_imaginary (self, value):\n \"x.imaginary = value\"\n y = self.imaginary\n y[...] = value\n\n def __str__(self):\n \"\"\"Calculate the str representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n if masked_print_option.enabled():\n f = masked_print_option\n # XXX: Without the following special case masked\n # XXX: would print as \"[--]\", not \"--\". Can we avoid\n # XXX: checks for masked by choosing a different value\n # XXX: for the masked singleton? 2005-01-05 -- sasha\n if self is masked:\n return str(f)\n m = self._mask\n if m is not nomask and m.shape == () and m:\n return str(f)\n # convert to object array to make filled work\n self = self.astype(object)\n else:\n f = self.fill_value()\n res = self.filled(f)\n return str(res)\n\n def __repr__(self):\n \"\"\"Calculate the repr representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n with_mask = \"\"\"\\\narray(data =\n %(data)s,\n mask =\n %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n with_mask1 = \"\"\"\\\narray(data = %(data)s,\n mask = %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n without_mask = \"\"\"array(\n %(data)s)\"\"\"\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n\n n = len(self.shape)\n if self._mask is nomask:\n if n <= 1:\n return without_mask1 % {'data':str(self.filled())}\n return without_mask % {'data':str(self.filled())}\n else:\n if n <= 1:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n if self._mask is nomask:\n return without_mask % {'data':str(self.filled())}\n else:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n\n def __float__(self):\n \"Convert self to float.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python float.'\n return float(self.data.item())\n\n def __int__(self):\n \"Convert self to int.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python int.'\n return int(self.data.item())\n\n def __getitem__(self, i):\n \"Get item described by i. Not a copy as in previous versions.\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i]\n if m is nomask:\n return dout\n mi = m[i]\n if mi.size == 1:\n if mi:\n return masked\n else:\n return dout\n else:\n return masked_array(dout, mi, fill_value=self._fill_value)\n\n def __getslice__(self, i, j):\n \"Get slice described by i, j\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i:j]\n if m is nomask:\n return masked_array(dout, fill_value=self._fill_value)\n else:\n return masked_array(dout, mask = m[i:j], fill_value=self._fill_value)\n\n# --------\n# setitem and setslice notes\n# note that if value is masked, it means to mask those locations.\n# setting a value changes the mask to match the value in those locations.\n\n def __setitem__(self, index, value):\n \"Set item described by index. If value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, 'Cannot alter the masked element.'\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n else:\n self.unshare_mask()\n self._mask[index] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[index] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[index] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = True\n else:\n self.unshare_mask()\n self._mask[index] = m\n\n def __setslice__(self, i, j, value):\n \"Set slice i:j; if value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, \"Cannot alter the 'masked' object.\"\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n self._mask[i:j] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[i:j] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[i:j] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(self._data.shape)\n self._shared_mask = False\n self._mask[i:j] = m\n\n def __nonzero__(self):\n \"\"\"returns true if any element is non-zero or masked\n\n \"\"\"\n # XXX: This changes bool conversion logic from MA.\n # XXX: In MA bool(a) == len(a) != 0, but in numpy\n # XXX: scalars do not have len\n m = self._mask\n d = self._data\n return bool(m is not nomask and m.any()\n or d is not nomask and d.any())\n\n def __len__ (self):\n \"\"\"Return length of first dimension. This is weird but Python's\n slicing behavior depends on it.\"\"\"\n return len(self._data)\n\n def __and__(self, other):\n \"Return bitwise_and\"\n return bitwise_and(self, other)\n\n def __or__(self, other):\n \"Return bitwise_or\"\n return bitwise_or(self, other)\n\n def __xor__(self, other):\n \"Return bitwise_xor\"\n return bitwise_xor(self, other)\n\n __rand__ = __and__\n __ror__ = __or__\n __rxor__ = __xor__\n\n def __abs__(self):\n \"Return absolute(self)\"\n return absolute(self)\n\n def __neg__(self):\n \"Return negative(self)\"\n return negative(self)\n\n def __pos__(self):\n \"Return array(self)\"\n return array(self)\n\n def __add__(self, other):\n \"Return add(self, other)\"\n return add(self, other)\n\n __radd__ = __add__\n\n def __mod__ (self, other):\n \"Return remainder(self, other)\"\n return remainder(self, other)\n\n def __rmod__ (self, other):\n \"Return remainder(other, self)\"\n return remainder(other, self)\n\n def __lshift__ (self, n):\n return left_shift(self, n)\n\n def __rshift__ (self, n):\n return right_shift(self, n)\n\n def __sub__(self, other):\n \"Return subtract(self, other)\"\n return subtract(self, other)\n\n def __rsub__(self, other):\n \"Return subtract(other, self)\"\n return subtract(other, self)\n\n def __mul__(self, other):\n \"Return multiply(self, other)\"\n return multiply(self, other)\n\n __rmul__ = __mul__\n\n def __div__(self, other):\n \"Return divide(self, other)\"\n return divide(self, other)\n\n def __rdiv__(self, other):\n \"Return divide(other, self)\"\n return divide(other, self)\n\n def __truediv__(self, other):\n \"Return divide(self, other)\"\n return true_divide(self, other)\n\n def __rtruediv__(self, other):\n \"Return divide(other, self)\"\n return true_divide(other, self)\n\n def __floordiv__(self, other):\n \"Return divide(self, other)\"\n return floor_divide(self, other)\n\n def __rfloordiv__(self, other):\n \"Return divide(other, self)\"\n return floor_divide(other, self)\n\n def __pow__(self, other, third=None):\n \"Return power(self, other, third)\"\n return power(self, other, third)\n\n def __sqrt__(self):\n \"Return sqrt(self)\"\n return sqrt(self)\n\n def __iadd__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data += f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = add(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __imul__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data *= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = multiply(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __isub__(self, other):\n \"Subtract other from self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data -= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = subtract(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n\n\n def __idiv__(self, other):\n \"Divide self by other in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n mo = getmask(other)\n result = divide(self, masked_array(f, mask=mo))\n self._data = result.data\n dm = result.raw_mask()\n if dm is not self._mask:\n self._mask = dm\n self._shared_mask = 1\n return self\n\n def __eq__(self, other):\n return equal(self,other)\n\n def __ne__(self, other):\n return not_equal(self,other)\n\n def __lt__(self, other):\n return less(self,other)\n\n def __le__(self, other):\n return less_equal(self,other)\n\n def __gt__(self, other):\n return greater(self,other)\n\n def __ge__(self, other):\n return greater_equal(self,other)\n\n def astype (self, tc):\n \"return self as array of given type.\"\n d = self._data.astype(tc)\n return array(d, mask=self._mask)\n\n def byte_swapped(self):\n \"\"\"Returns the raw data field, byte_swapped. Included for consistency\n with numeric but doesn't make sense in this context.\n \"\"\"\n return self._data.byte_swapped()\n\n def compressed (self):\n \"A 1-D array of all the non-masked data.\"\n d = oldnumeric.ravel(self._data)\n if self._mask is nomask:\n return array(d)\n else:\n m = 1 - oldnumeric.ravel(self._mask)\n c = oldnumeric.compress(m, d)\n return array(c, copy=0)\n\n def count (self, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n m = self._mask\n s = self._data.shape\n ls = len(s)\n if m is nomask:\n if ls == 0:\n return 1\n if ls == 1:\n return s[0]\n if axis is None:\n return reduce(lambda x, y:x*y, s)\n else:\n n = s[axis]\n t = list(s)\n del t[axis]\n return ones(t) * n\n if axis is None:\n w = oldnumeric.ravel(m).astype(int)\n n1 = size(w)\n if n1 == 1:\n n2 = w[0]\n else:\n n2 = umath.add.reduce(w)\n return n1 - n2\n else:\n n1 = size(m, axis)\n n2 = sum(m.astype(int), axis)\n return n1 - n2\n\n def dot (self, other):\n \"s.dot(other) = innerproduct(s, other)\"\n return innerproduct(self, other)\n\n def fill_value(self):\n \"Get the current fill value.\"\n return self._fill_value\n\n def filled (self, fill_value=None):\n \"\"\"A numeric array with masked values filled. If fill_value is None,\n use self.fill_value().\n\n If mask is nomask, copy data only if not contiguous.\n Result is always a contiguous, numeric array.\n# Is contiguous really necessary now?\n \"\"\"\n d = self._data\n m = self._mask\n if m is nomask:\n if d.flags['CONTIGUOUS']:\n return d\n else:\n return d.copy()\n else:\n if fill_value is None:\n value = self._fill_value\n else:\n value = fill_value\n\n if self is masked:\n result = numeric.array(value)\n else:\n try:\n result = numeric.array(d, dtype=d.dtype, copy=1)\n result[m] = value\n except (TypeError, AttributeError):\n #ok, can't put that value in here\n value = numeric.array(value, dtype=object)\n d = d.astype(object)\n result = oldnumeric.choose(m, (d, value))\n except IndexError:\n #ok, if scalar\n if d.shape:\n raise\n elif m:\n result = numeric.array(value, dtype=d.dtype)\n else:\n result = d\n return result\n\n def ids (self):\n \"\"\"Return the ids of the data and mask areas\"\"\"\n return (id(self._data), id(self._mask))\n\n def iscontiguous (self):\n \"Is the data contiguous?\"\n return self._data.flags['CONTIGUOUS']\n\n def itemsize(self):\n \"Item size of each data item.\"\n return self._data.itemsize\n\n\n def outer(self, other):\n \"s.outer(other) = outerproduct(s, other)\"\n return outerproduct(self, other)\n\n def put (self, values):\n \"\"\"Set the non-masked entries of self to filled(values).\n No change to mask\n \"\"\"\n iota = numeric.arange(self.size)\n d = self._data\n if self._mask is nomask:\n ind = iota\n else:\n ind = oldnumeric.compress(1 - self._mask, iota)\n d[ind] = filled(values).astype(d.dtype)\n\n def putmask (self, values):\n \"\"\"Set the masked entries of self to filled(values).\n Mask changed to nomask.\n \"\"\"\n d = self._data\n if self._mask is not nomask:\n d[self._mask] = filled(values).astype(d.dtype)\n self._shared_mask = 0\n self._mask = nomask\n\n def ravel (self):\n \"\"\"Return a 1-D view of self.\"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel())\n else:\n return masked_array(self._data.ravel(), self._mask.ravel())\n\n def raw_data (self):\n \"\"\" Obsolete; use data property instead.\n The raw data; portions may be meaningless.\n May be noncontiguous. Expert use only.\"\"\"\n return self._data\n data = property(fget=raw_data,\n doc=\"The data, but values at masked locations are meaningless.\")\n\n def raw_mask (self):\n \"\"\" Obsolete; use mask property instead.\n May be noncontiguous. Expert use only.\n \"\"\"\n return self._mask\n mask = property(fget=raw_mask,\n doc=\"The mask, may be nomask. Values where mask true are meaningless.\")\n\n def reshape (self, *s):\n \"\"\"This array reshaped to shape s\"\"\"\n d = self._data.reshape(*s)\n if self._mask is nomask:\n return masked_array(d)\n else:\n m = self._mask.reshape(*s)\n return masked_array(d, m)\n\n def set_fill_value (self, v=None):\n \"Set the fill value to v. Omit v to restore default.\"\n if v is None:\n v = default_fill_value (self.raw_data())\n self._fill_value = v\n\n def _get_ndim(self):\n return self._data.ndim\n ndim = property(_get_ndim, doc=numeric.ndarray.ndim.__doc__)\n\n def _get_size (self):\n return self._data.size\n size = property(fget=_get_size, doc=\"Number of elements in the array.\")\n## CHECK THIS: signature of numeric.array.size?\n\n def _get_dtype(self):\n return self._data.dtype\n dtype = property(fget=_get_dtype, doc=\"type of the array elements.\")\n\n def item(self):\n \"Return Python scalar if possible.\"\n if self._mask is not nomask:\n m = oldnumeric.ravel(self._mask)\n try:\n if m[0]:\n return masked\n except IndexError:\n return masked\n return self._data.item()\n\n def tolist(self, fill_value=None):\n \"Convert to list\"\n return self.filled(fill_value).tolist()\n\n def tostring(self, fill_value=None):\n \"Convert to string\"\n return self.filled(fill_value).tostring()\n\n def unmask (self):\n \"Replace the mask by nomask if possible.\"\n if self._mask is nomask: return\n m = make_mask(self._mask, flag=1)\n if m is nomask:\n self._mask = nomask\n self._shared_mask = 0\n\n def unshare_mask (self):\n \"If currently sharing mask, make a copy.\"\n if self._shared_mask:\n self._mask = make_mask (self._mask, copy=1, flag=0)\n self._shared_mask = 0\n\n shape = property(_get_shape, _set_shape,\n doc = 'tuple giving the shape of the array')\n\n flat = property(_get_flat, _set_flat,\n doc = 'Access array in flat form.')\n\n real = property(_get_real, _set_real,\n doc = 'Access the real part of the array')\n\n imaginary = property(_get_imaginary, _set_imaginary,\n doc = 'Access the imaginary part of the array')\n\n imag = imaginary\n\n#end class MaskedArray\n\narray = MaskedArray\n\ndef isMaskedArray (x):\n \"Is x a masked array, that is, an instance of MaskedArray?\"\n return isinstance(x, MaskedArray)\n\nisarray = isMaskedArray\nisMA = isMaskedArray #backward compatibility\n\ndef allclose (a, b, fill_value=1, rtol=1.e-5, atol=1.e-8):\n \"\"\" Returns true if all components of a and b are equal\n subject to given tolerances.\n If fill_value is 1, masked values considered equal.\n If fill_value is 0, masked values considered unequal.\n The relative error rtol should be positive and << 1.0\n The absolute error atol comes into play for those elements\n of b that are very small or zero; it says how small a must be also.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a)\n d2 = filled(b)\n x = filled(array(d1, copy=0, mask=m), fill_value).astype(float)\n y = filled(array(d2, copy=0, mask=m), 1).astype(float)\n d = umath.less_equal(umath.absolute(x-y), atol + rtol * umath.absolute(y))\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n\ndef allequal (a, b, fill_value=1):\n \"\"\"\n True if all entries of a and b are equal, using\n fill_value as a truth value where either or both are masked.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n if m is nomask:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n elif fill_value:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n dm = array(d, mask=m, copy=0)\n return oldnumeric.alltrue(oldnumeric.ravel(filled(dm, 1)))\n else:\n return 0\n\ndef masked_values (data, value, rtol=1.e-5, atol=1.e-8, copy=1):\n \"\"\"\n masked_values(data, value, rtol=1.e-5, atol=1.e-8)\n Create a masked array; mask is nomask if possible.\n If copy==0, and otherwise possible, result\n may share data values with original array.\n Let d = filled(data, value). Returns d\n masked where abs(data-value)<= atol + rtol * abs(value)\n if d is of a floating point type. Otherwise returns\n masked_object(d, value, copy)\n \"\"\"\n abs = umath.absolute\n d = filled(data, value)\n if issubclass(d.dtype.type, numeric.floating):\n m = umath.less_equal(abs(d-value), atol+rtol*abs(value))\n m = make_mask(m, flag=1)\n return array(d, mask = m, copy=copy,\n fill_value=value)\n else:\n return masked_object(d, value, copy=copy)\n\ndef masked_object (data, value, copy=1):\n \"Create array masked where exactly data equal to value\"\n d = filled(data, value)\n dm = make_mask(umath.equal(d, value), flag=1)\n return array(d, mask=dm, copy=copy, fill_value=value)\n\ndef arrayrange(start, stop=None, step=1, dtype=None):\n \"\"\"Just like range() except it returns a array whose type can be specified\n by the keyword argument dtype.\n \"\"\"\n return array(numeric.arrayrange(start, stop, step, dtype))\n\narange = arrayrange\n\ndef fromstring (s, t):\n \"Construct a masked array from a string. Result will have no mask.\"\n return masked_array(numeric.fromstring(s, t))\n\ndef left_shift (a, n):\n \"Left shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.left_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.left_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef right_shift (a, n):\n \"Right shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.right_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.right_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef resize (a, new_shape):\n \"\"\"resize(a, new_shape) returns a new array with the specified shape.\n The original array's total size can be any size.\"\"\"\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.resize(m, new_shape)\n result = array(oldnumeric.resize(filled(a), new_shape), mask=m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n \"\"\"\n af = filled(a)\n if isinstance(repeats, types.IntType):\n repeats = tuple([repeats]*(shape(af)[axis]))\n\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.repeat(m, repeats, axis)\n d = oldnumeric.repeat(af, repeats, axis)\n result = masked_array(d, m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef identity(n):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n return array(numeric.identity(n))\n\ndef indices (dimensions, dtype=None):\n \"\"\"indices(dimensions,dtype=None) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n return array(numeric.indices(dimensions, dtype))\n\ndef zeros (shape, dtype=int):\n \"\"\"zeros(n, dtype=int) =\n an array of all zeros of the given length or shape.\"\"\"\n return array(numeric.zeros(shape, dtype))\n\ndef ones (shape, dtype=int):\n \"\"\"ones(n, dtype=int) =\n an array of all ones of the given length or shape.\"\"\"\n return array(numeric.ones(shape, dtype))\n\n\ndef count (a, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n a = masked_array(a)\n return a.count(axis)\n\ndef power (a, b, third=None):\n \"a**b\"\n if third is not None:\n raise MAError, \"3-argument power not supported.\"\n ma = getmask(a)\n mb = getmask(b)\n m = mask_or(ma, mb)\n fa = filled(a, 1)\n fb = filled(b, 1)\n if fb.dtype.char in typecodes[\"Integer\"]:\n return masked_array(umath.power(fa, fb), m)\n md = make_mask(umath.less_equal (fa, 0), flag=1)\n m = mask_or(m, md)\n if m is nomask:\n return masked_array(umath.power(fa, fb))\n else:\n fa = numeric.where(m, 1, fa)\n return masked_array(umath.power(fa, fb), m)\n\ndef masked_array (a, mask=nomask, fill_value=None):\n \"\"\"masked_array(a, mask=nomask) =\n array(a, mask=mask, copy=0, fill_value=fill_value)\n \"\"\"\n return array(a, mask=mask, copy=0, fill_value=fill_value)\n\nsum = add.reduce\nproduct = multiply.reduce\n\ndef average (a, axis=0, weights=None, returned = 0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis.\n If axis is None, average over the entire array\n Inputs can be integer or floating types; result is of type float.\n\n If weights are given, result is sum(a*weights)/(sum(weights)*1.0)\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis.\n\n If returned, return a tuple: the result and the sum of the weights\n or count of values. Results will have the same shape.\n\n masked values in the weights will be set to 0.0\n \"\"\"\n a = masked_array(a)\n mask = a.mask\n ash = a.shape\n if ash == ():\n ash = (1,)\n if axis is None:\n if mask is nomask:\n if weights is None:\n n = add.reduce(a.raw_data().ravel())\n d = reduce(lambda x, y: x * y, ash, 1.0)\n else:\n w = filled(weights, 0.0).ravel()\n n = umath.add.reduce(a.raw_data().ravel() * w)\n d = umath.add.reduce(w)\n del w\n else:\n if weights is None:\n n = add.reduce(a.ravel())\n w = oldnumeric.choose(mask, (1.0, 0.0)).ravel()\n d = umath.add.reduce(w)\n del w\n else:\n w = array(filled(weights, 0.0), float, mask=mask).ravel()\n n = add.reduce(a.ravel() * w)\n d = add.reduce(w)\n del w\n else:\n if mask is nomask:\n if weights is None:\n d = ash[axis] * 1.0\n n = umath.add.reduce(a.raw_data(), axis)\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = numeric.array(w, float, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * ones(ash, float)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w, r\n else:\n raise ValueError, 'average: weights wrong shape.'\n else:\n if weights is None:\n n = add.reduce(a, axis)\n w = numeric.choose(mask, (1.0, 0.0))\n d = umath.add.reduce(w, axis)\n del w\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = array(w, float, mask=mask, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * masked_array(ones(ash, float), mask)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n del w\n #print n, d, repr(mask), repr(weights)\n if n is masked or d is masked: return masked\n result = divide (n, d)\n del n\n\n if isinstance(result, MaskedArray):\n result.unmask()\n if returned:\n if not isinstance(d, MaskedArray):\n d = masked_array(d)\n if not d.shape == result.shape:\n d = ones(result.shape, float) * d\n d.unmask()\n if returned:\n return result, d\n else:\n return result\n\ndef where (condition, x, y):\n \"\"\"where(condition, x, y) is x where condition is nonzero, y otherwise.\n condition must be convertible to an integer array.\n Answer is always the shape of condition.\n The type depends on x and y. It is integer if both x and y are\n the value masked.\n \"\"\"\n fc = filled(not_equal(condition, 0), 0)\n xv = filled(x)\n xm = getmask(x)\n yv = filled(y)\n ym = getmask(y)\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n m = make_mask(mask_or(m, md), copy=0, flag=1)\n return masked_array(d, m)\n\ndef choose (indices, t):\n \"Returns array shaped like indices with elements chosen from t\"\n def fmask (x):\n if x is masked: return 1\n return filled(x)\n def nmask (x):\n if x is masked: return 1\n m = getmask(x)\n if m is nomask: return 0\n return m\n c = filled(indices, 0)\n masks = [nmask(x) for x in t]\n a = [fmask(x) for x in t]\n d = numeric.choose(c, a)\n m = numeric.choose(c, masks)\n m = make_mask(mask_or(m, getmask(indices)), copy=0, flag=1)\n return masked_array(d, m)\n\ndef masked_where(condition, x, copy=1):\n \"\"\"Return x as an array masked where condition is true.\n Also masked where x or condition masked.\n \"\"\"\n cm = filled(condition,1)\n m = mask_or(getmask(x), cm)\n return array(filled(x), copy=copy, mask=m)\n\ndef masked_greater(x, value, copy=1):\n \"masked_greater(x, value) = x masked where x > value\"\n return masked_where(greater(x, value), x, copy)\n\ndef masked_greater_equal(x, value, copy=1):\n \"masked_greater_equal(x, value) = x masked where x >= value\"\n return masked_where(greater_equal(x, value), x, copy)\n\ndef masked_less(x, value, copy=1):\n \"masked_less(x, value) = x masked where x < value\"\n return masked_where(less(x, value), x, copy)\n\ndef masked_less_equal(x, value, copy=1):\n \"masked_less_equal(x, value) = x masked where x <= value\"\n return masked_where(less_equal(x, value), x, copy)\n\ndef masked_not_equal(x, value, copy=1):\n \"masked_not_equal(x, value) = x masked where x != value\"\n d = filled(x, 0)\n c = umath.not_equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_equal(x, value, copy=1):\n \"\"\"masked_equal(x, value) = x masked where x == value\n For floating point consider masked_values(x, value) instead.\n \"\"\"\n d = filled(x, 0)\n c = umath.equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_inside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are inside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_and(umath.less_equal(d, v2), umath.greater_equal(d, v1))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef masked_outside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are outside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_or(umath.less(d, v1), umath.greater(d, v2))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef reshape (a, *newshape):\n \"Copy of a with a new shape.\"\n m = getmask(a)\n d = filled(a).reshape(*newshape)\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.reshape(m, *newshape))\n\ndef ravel (a):\n \"a as one-dimensional, may share data and mask\"\n m = getmask(a)\n d = oldnumeric.ravel(filled(a))\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.ravel(m))\n\ndef concatenate (arrays, axis=0):\n \"Concatenate the arrays along the given axis\"\n d = []\n for x in arrays:\n d.append(filled(x))\n d = numeric.concatenate(d, axis)\n for x in arrays:\n if getmask(x) is not nomask: break\n else:\n return masked_array(d)\n dm = []\n for x in arrays:\n dm.append(getmaskarray(x))\n dm = numeric.concatenate(dm, axis)\n return masked_array(d, mask=dm)\n\ndef swapaxes (a, axis1, axis2):\n m = getmask(a)\n d = masked_array(a).data\n if m is nomask:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2))\n else:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2),\n mask=numeric.swapaxes(m, axis1, axis2),)\n\n\ndef take (a, indices, axis=0):\n \"take(a, indices, axis=0) returns selection of items from a.\"\n m = getmask(a)\n # d = masked_array(a).raw_data()\n d = masked_array(a).data\n if m is nomask:\n return masked_array(numeric.take(d, indices, axis))\n else:\n return masked_array(numeric.take(d, indices, axis),\n mask = numeric.take(m, indices, axis))\n\ndef transpose(a, axes=None):\n \"transpose(a, axes=None) reorder dimensions per tuple axes\"\n m = getmask(a)\n d = filled(a)\n if m is nomask:\n return masked_array(numeric.transpose(d, axes))\n else:\n return masked_array(numeric.transpose(d, axes),\n mask = numeric.transpose(m, axes))\n\n\ndef put(a, indices, values):\n \"\"\"put(a, indices, values) sets storage-indexed locations to corresponding values.\n\n Values and indices are filled if necessary.\n\n \"\"\"\n d = a.raw_data()\n ind = filled(indices)\n v = filled(values)\n numeric.put (d, ind, v)\n m = getmask(a)\n if m is not nomask:\n a.unshare_mask()\n numeric.put(a.raw_mask(), ind, 0)\n\ndef putmask(a, mask, values):\n \"putmask(a, mask, values) sets a where mask is true.\"\n if mask is nomask:\n return\n numeric.putmask(a.raw_data(), mask, values)\n m = getmask(a)\n if m is nomask: return\n a.unshare_mask()\n numeric.putmask(a.raw_mask(), mask, 0)\n\ndef innerproduct(a, b):\n \"\"\"innerproduct(a,b) returns the dot product of two arrays, which has\n shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the\n product of the elements from the last dimensions of a and b.\n Masked elements are replace by zeros.\n \"\"\"\n fa = filled(a, 0)\n fb = filled(b, 0)\n if len(fa.shape) == 0: fa.shape = (1,)\n if len(fb.shape) == 0: fb.shape = (1,)\n return masked_array(numeric.innerproduct(fa, fb))\n\ndef outerproduct(a, b):\n \"\"\"outerproduct(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))\"\"\"\n fa = filled(a, 0).ravel()\n fb = filled(b, 0).ravel()\n d = numeric.outerproduct(fa, fb)\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n return masked_array(d)\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = make_mask(1-numeric.outerproduct(1-ma, 1-mb), copy=0)\n return masked_array(d, m)\n\ndef dot(a, b):\n \"\"\"dot(a,b) returns matrix-multiplication between a and b. The product-sum\n is over the last dimension of a and the second-to-last dimension of b.\n Masked values are replaced by zeros. See also innerproduct.\n \"\"\"\n return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))\n\ndef compress(condition, x, dimension=-1):\n \"\"\"Select those parts of x for which condition is true.\n Masked values in condition are considered false.\n \"\"\"\n c = filled(condition, 0)\n m = getmask(x)\n if m is not nomask:\n m = numeric.compress(c, m, dimension)\n d = numeric.compress(c, filled(x), dimension)\n return masked_array(d, m)\n\nclass _minimum_operation:\n \"Object to calculate minima\"\n def __init__ (self):\n \"\"\"minimum(a, b) or minimum(a)\n In one argument case returns the scalar minimum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amin(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amin(ac.raw_data())\n else:\n return where(less(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.minimum.reduce (t, axis))\n else:\n t = umath.minimum.reduce(filled(target, minimum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.minimum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nminimum = _minimum_operation ()\n\nclass _maximum_operation:\n \"Object to calculate maxima\"\n def __init__ (self):\n \"\"\"maximum(a, b) or maximum(a)\n In one argument case returns the scalar maximum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amax(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amax(ac.raw_data())\n else:\n return where(greater(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.maximum.reduce (t, axis))\n else:\n t = umath.maximum.reduce(filled(target, maximum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.maximum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nmaximum = _maximum_operation ()\n\ndef sort (x, axis = -1, fill_value=None):\n \"\"\"If x does not have a mask, return a masked array formed from the\n result of numeric.sort(x, axis).\n Otherwise, fill x with fill_value. Sort it.\n Set a mask where the result is equal to fill_value.\n Note that this may have unintended consequences if the data contains the\n fill value at a non-masked site.\n\n If fill_value is not given the default fill value for x's type will be\n used.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n d = filled(x, fill_value)\n s = oldnumeric.sort(d, axis)\n if getmask(x) is nomask:\n return masked_array(s)\n return masked_values(s, fill_value, copy=0)\n\ndef diagonal(a, k = 0, axis1=0, axis2=1):\n \"\"\"diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a\"\"\"\n d = oldnumeric.diagonal(filled(a), k, axis1, axis2)\n m = getmask(a)\n if m is nomask:\n return masked_array(d, m)\n else:\n return masked_array(d, oldnumeric.diagonal(m, k, axis1, axis2))\n \ndef trace (a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return diagonal(a, offset, axis1, axis2).sum(dtype=dtype)\n\ndef argsort (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for sorting along given axis.\n if fill_value is None, use get_fill_value(x)\n Returns a numpy array.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argsort(d, axis)\n\ndef argmin (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return indices for minimum values along given axis.\n if fill_value is None, use get_fill_value(x).\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argmin(d, axis)\n\ndef argmax (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for maximum along given axis.\n if fill_value is None, use -get_fill_value(x) if it exists.\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n try:\n fill_value = - fill_value\n except:\n pass\n d = filled(x, fill_value)\n return oldnumeric.argmax(d, axis)\n\ndef fromfunction (f, s):\n \"\"\"apply f to s to create array as in umath.\"\"\"\n return masked_array(numeric.fromfunction(f, s))\n\ndef asarray(data, dtype=None):\n \"\"\"asarray(data, dtype) = array(data, dtype, copy=0)\n \"\"\"\n if isinstance(data, MaskedArray) and \\\n (dtype is None or dtype == data.dtype):\n return data\n return array(data, dtype=dtype, copy=0)\n\n# Add methods to support ndarray interface\n# XXX: I is better to to change the masked_*_operation adaptors\n# XXX: to wrap ndarray methods directly to create ma.array methods.\nfrom types import MethodType\ndef _m(f):\n return MethodType(f, None, array)\ndef not_implemented(*args, **kwds):\n raise NotImplementedError, \"not yet implemented for numpy.ma arrays\"\narray.all = _m(alltrue)\narray.any = _m(sometrue)\narray.argmax = _m(argmax)\narray.argmin = _m(argmin)\narray.argsort = _m(argsort)\narray.base = property(_m(not_implemented))\narray.byteswap = _m(not_implemented)\n\ndef _choose(self, *args):\n return choose(self, args)\narray.choose = _m(_choose)\ndel _choose\n\ndef _clip(self,a_min,a_max):\n return MaskedArray(data = self.data.clip(asarray(a_min).data, \n asarray(a_max).data),\n mask = mask_or(self.mask,\n mask_or(getmask(a_min),getmask(a_max))))\narray.clip = _m(_clip)\n\ndef _compress(self, cond, axis=None):\n return compress(cond, self, axis)\narray.compress = _m(_compress)\ndel _compress\n\narray.conj = array.conjugate = _m(conjugate)\narray.copy = _m(not_implemented)\n\ndef _cumprod(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_and.accumulate(self.mask, axis)\n return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)\narray.cumprod = _m(_cumprod)\n\ndef _cumsum(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_and.accumulate(self.mask, axis)\n return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)\narray.cumsum = _m(_cumsum)\n\narray.diagonal = _m(diagonal)\narray.dump = _m(not_implemented)\narray.dumps = _m(not_implemented)\narray.fill = _m(not_implemented)\narray.flags = property(_m(not_implemented))\narray.flatten = _m(ravel)\narray.getfield = _m(not_implemented)\n\ndef _max(a, axis=None):\n if axis is None:\n return maximum(a)\n else:\n return maximum.reduce(a, axis)\narray.max = _m(_max)\ndel _max\ndef _min(a, axis=None):\n if axis is None:\n return minimum(a)\n else:\n return minimum.reduce(a, axis)\narray.min = _m(_min)\ndel _min\narray.mean = _m(average)\narray.nbytes = property(_m(not_implemented))\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\n\ndef _ptp(a,axis=0):\n return a.max(axis)-a.min(axis)\narray.ptp = _m(_ptp)\narray.repeat = _m(repeat)\narray.resize = _m(resize)\narray.searchsorted = _m(not_implemented)\narray.setfield = _m(not_implemented)\narray.setflags = _m(not_implemented)\narray.sort = _m(not_implemented) # NB: ndarray.sort is inplace\n\ndef _squeeze(self):\n try:\n result = MaskedArray(data = self.data.squeeze(),\n mask = self.mask.squeeze())\n except AttributeError:\n result = _wrapit(self, 'squeeze')\n return result\narray.squeeze = _m(_squeeze) \n\narray.strides = property(_m(not_implemented))\narray.sum = _m(sum)\ndef _swapaxes(self,axis1,axis2):\n return MaskedArray(data = self.data.swapaxes(axis1, axis2),\n mask = self.mask.swapaxes(axis1, axis2))\narray.swapaxes = _m(_swapaxes)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(trace)\narray.transpose = _m(transpose)\n\ndef _var(self,axis=0,dtype=None):\n if axis is None:\n return asarray(self.compressed()).var()\n a = self.swapaxes(axis,0)\n a = a - a.mean(axis=0)\n a *= a\n a /= (a.count(axis=0)-1)\n return a.swapaxes(0,axis).sum(axis)\ndef _std(self,axis=0,dtype=None):\n return (self.var(axis,dtype))**0.5\narray.var = _m(_var)\narray.std = _m(_std)\n\narray.view = _m(not_implemented)\narray.round = _m(around)\ndel _m, MethodType, not_implemented\n\n\nmasked = MaskedArray(0, int, mask=1)\n", + "source_code_before": "\"\"\"MA: a facility for dealing with missing observations\nMA is generally used as a numpy.array look-alike.\nby Paul F. Dubois.\n\nCopyright 1999, 2000, 2001 Regents of the University of California.\nReleased for unlimited redistribution.\nAdapted for numpy_core 2005 by Travis Oliphant and\n(mainly) Paul Dubois.\n\"\"\"\nimport types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import bool_\nimport numeric\nimport warnings\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType = bool_\nnomask = MaskType(0)\ndivide_tolerance = 1.e-35\n\nclass MAError (Exception):\n def __init__ (self, args=None):\n \"Create an exception\"\n self.args = args\n def __str__(self):\n \"Calculate the string representation\"\n return str(self.args)\n __repr__ = __str__\n\nclass _MaskedPrintOption:\n \"One instance of this class, masked_print_option, is created.\"\n def __init__ (self, display):\n \"Create the masked print option object.\"\n self.set_display(display)\n self._enabled = 1\n\n def display (self):\n \"Show what prints for masked values.\"\n return self._display\n\n def set_display (self, s):\n \"set_display(s) sets what prints for masked values.\"\n self._display = s\n\n def enabled (self):\n \"Is the use of the display value enabled?\"\n return self._enabled\n\n def enable(self, flag=1):\n \"Set the enabling flag to flag.\"\n self._enabled = flag\n\n def __str__ (self):\n return str(self._display)\n\n __repr__ = __str__\n\n#if you single index into a masked location you get this object.\nmasked_print_option = _MaskedPrintOption('--')\n\n# Use single element arrays or scalars.\ndefault_real_fill_value = 1.e20\ndefault_complex_fill_value = 1.e20 + 0.0j\ndefault_character_fill_value = '-'\ndefault_integer_fill_value = 999999\ndefault_object_fill_value = '?'\n\ndef default_fill_value (obj):\n \"Function to calculate default fill value for an object.\"\n if isinstance(obj, types.FloatType):\n return default_real_fill_value\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return default_integer_fill_value\n elif isinstance(obj, types.StringType):\n return default_character_fill_value\n elif isinstance(obj, types.ComplexType):\n return default_complex_fill_value\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return default_real_fill_value\n if x in typecodes['Integer']:\n return default_integer_fill_value\n if x in typecodes['Complex']:\n return default_complex_fill_value\n if x in typecodes['Character']:\n return default_character_fill_value\n if x in typecodes['UnsignedInteger']:\n return umath.absolute(default_integer_fill_value)\n return default_object_fill_value\n else:\n return default_object_fill_value\n\ndef minimum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking minima.\"\n if isinstance(obj, types.FloatType):\n return numeric.inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return numeric.inf\n if x in typecodes['Integer']:\n return sys.maxint\n if x in typecodes['UnsignedInteger']:\n return sys.maxint\n else:\n raise TypeError, 'Unsuitable type for calculating minimum.'\n\ndef maximum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking maxima.\"\n if isinstance(obj, types.FloatType):\n return -inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return -sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return -inf\n if x in typecodes['Integer']:\n return -sys.maxint\n if x in typecodes['UnsignedInteger']:\n return 0\n else:\n raise TypeError, 'Unsuitable type for calculating maximum.'\n\ndef set_fill_value (a, fill_value):\n \"Set fill value of a if it is a masked array.\"\n if isMaskedArray(a):\n a.set_fill_value (fill_value)\n\ndef getmask (a):\n \"\"\"Mask of values in a; could be nomask.\n Returns nomask if a is not a masked array.\n To get an array for sure use getmaskarray.\"\"\"\n if isinstance(a, MaskedArray):\n return a.raw_mask()\n else:\n return nomask\n\ndef getmaskarray (a):\n \"\"\"Mask of values in a; an array of zeros if mask is nomask\n or not a masked array, and is a byte-sized integer.\n Do not try to add up entries, for example.\n \"\"\"\n m = getmask(a)\n if m is nomask:\n return make_mask_none(shape(a))\n else:\n return m\n\ndef is_mask (m):\n \"\"\"Is m a legal mask? Does not check contents, only type.\n \"\"\"\n try:\n return m.dtype.type is MaskType\n except AttributeError:\n return False\n\ndef make_mask (m, copy=0, flag=0):\n \"\"\"make_mask(m, copy=0, flag=0)\n return m as a mask, creating a copy if necessary or requested.\n Can accept any sequence of integers or nomask. Does not check\n that contents must be 0s and 1s.\n if flag, return nomask if m contains no true elements.\n \"\"\"\n if m is nomask:\n return nomask\n elif isinstance(m, ndarray):\n if m.dtype.type is MaskType:\n if copy:\n result = numeric.array(m, dtype=MaskType, copy=copy)\n else:\n result = m\n else:\n result = m.astype(MaskType)\n else:\n result = filled(m, True).astype(MaskType)\n\n if flag and not oldnumeric.sometrue(oldnumeric.ravel(result)):\n return nomask\n else:\n return result\n\ndef make_mask_none (s):\n \"Return a mask of all zeros of shape s.\"\n result = numeric.zeros(s, dtype=MaskType)\n result.shape = s\n return result\n\ndef mask_or (m1, m2):\n \"\"\"Logical or of the mask candidates m1 and m2, treating nomask as false.\n Result may equal m1 or m2 if the other is nomask.\n \"\"\"\n if m1 is nomask: return make_mask(m2)\n if m2 is nomask: return make_mask(m1)\n if m1 is m2 and is_mask(m1): return m1\n return make_mask(umath.logical_or(m1, m2))\n\ndef filled (a, value = None):\n \"\"\"a as a contiguous numeric array with any masked areas replaced by value\n if value is None or the special element \"masked\", get_fill_value(a)\n is used instead.\n\n If a is already a contiguous numeric array, a itself is returned.\n\n filled(a) can be used to be sure that the result is numeric when\n passing an object a to other software ignorant of MA, in particular to\n numeric itself.\n \"\"\"\n if isinstance(a, MaskedArray):\n return a.filled(value)\n elif isinstance(a, ndarray) and a.flags['CONTIGUOUS']:\n return a\n elif isinstance(a, types.DictType):\n return numeric.array(a, 'O')\n else:\n return numeric.array(a)\n\ndef get_fill_value (a):\n \"\"\"\n The fill value of a, if it has one; otherwise, the default fill value\n for that type.\n \"\"\"\n if isMaskedArray(a):\n result = a.fill_value()\n else:\n result = default_fill_value(a)\n return result\n\ndef common_fill_value (a, b):\n \"The common fill_value of a and b, if there is one, or None\"\n t1 = get_fill_value(a)\n t2 = get_fill_value(b)\n if t1 == t2: return t1\n return None\n\n# Domain functions return 1 where the argument(s) are not in the domain.\nclass domain_check_interval:\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n def __init__(self, y1, y2):\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n self.y1 = y1\n self.y2 = y2\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.logical_or(umath.greater (x, self.y2),\n umath.less(x, self.y1)\n )\n\nclass domain_tan:\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n def __init__(self, eps):\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n self.eps = eps\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less(umath.absolute(umath.cos(x)), self.eps)\n\nclass domain_greater:\n \"domain_greater(v)(x) = true where x <= v\"\n def __init__(self, critical_value):\n \"domain_greater(v)(x) = true where x <= v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less_equal (x, self.critical_value)\n\nclass domain_greater_equal:\n \"domain_greater_equal(v)(x) = true where x < v\"\n def __init__(self, critical_value):\n \"domain_greater_equal(v)(x) = true where x < v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less (x, self.critical_value)\n\nclass masked_unary_operation:\n def __init__ (self, aufunc, fill=0, domain=None):\n \"\"\" masked_unary_operation(aufunc, fill=0, domain=None)\n aufunc(fill) must be defined\n self(x) returns aufunc(x)\n with masked values where domain(x) is true or getmask(x) is true.\n \"\"\"\n self.f = aufunc\n self.fill = fill\n self.domain = domain\n self.__doc__ = getattr(aufunc, \"__doc__\", str(aufunc))\n self.__name__ = getattr(aufunc, \"__name__\", str(aufunc))\n ufunc_domain[aufunc] = domain\n ufunc_fills[aufunc] = fill,\n\n def __call__ (self, a, *args, **kwargs):\n \"Execute the call behavior.\"\n# numeric tries to return scalars rather than arrays when given scalars.\n m = getmask(a)\n d1 = filled(a, self.fill)\n if self.domain is not None:\n m = mask_or(m, self.domain(d1))\n result = self.f(d1, *args, **kwargs)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\n\nclass domain_safe_divide:\n def __init__ (self, tolerance=divide_tolerance):\n self.tolerance = tolerance\n def __call__ (self, a, b):\n return umath.absolute(a) * self.tolerance >= umath.absolute(b)\n\nclass domained_binary_operation:\n \"\"\"Binary operations that have a domain, like divide. These are complicated\n so they are a separate class. They have no reduce, outer or accumulate.\n \"\"\"\n def __init__ (self, abfunc, domain, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.domain = domain\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n self.__name__ = getattr(abfunc, \"__name__\", str(abfunc))\n ufunc_domain[abfunc] = domain\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__(self, a, b):\n \"Execute the call behavior.\"\n ma = getmask(a)\n mb = getmask(b)\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n t = self.domain(d1, d2)\n\n if oldnumeric.sometrue(t, None):\n d2 = where(t, self.filly, d2)\n mb = mask_or(mb, t)\n m = mask_or(ma, mb)\n result = self.f(d1, d2)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nclass masked_binary_operation:\n def __init__ (self, abfunc, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n ufunc_domain[abfunc] = None\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__ (self, a, b, *args, **kwargs):\n \"Execute the call behavior.\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n result = self.f(d1, d2, *args, **kwargs)\n return masked_array(result, m)\n\n def reduce (self, target, axis=0, dtype=None):\n \"\"\"Reduce target along the given axis with this function.\"\"\"\n m = getmask(target)\n t = filled(target, self.filly)\n if t.shape == ():\n t = t.reshape(1)\n if m is not nomask:\n m = make_mask(m, copy=1)\n m.shape = (1,)\n if m is nomask:\n return masked_array (self.f.reduce (t, axis))\n else:\n t = masked_array (t, m)\n # XXX: \"or t.dtype\" below is a workaround for what appears\n # XXX: to be a bug in reduce.\n t = self.f.reduce(filled(t, self.filly), axis, dtype=dtype or t.dtype)\n m = umath.logical_and.reduce(m, axis)\n if isinstance(t, ndarray):\n return masked_array(t, m, get_fill_value(target))\n elif m:\n return masked\n else:\n return t\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = self.f.outer(filled(a, self.fillx), filled(b, self.filly))\n return masked_array(d, m)\n\n def accumulate (self, target, axis=0):\n \"\"\"Accumulate target along axis after filling with y fill value.\"\"\"\n t = filled(target, self.filly)\n return masked_array (self.f.accumulate (t, axis))\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nsqrt = masked_unary_operation(umath.sqrt, 0.0, domain_greater_equal(0.0))\nlog = masked_unary_operation(umath.log, 1.0, domain_greater(0.0))\nlog10 = masked_unary_operation(umath.log10, 1.0, domain_greater(0.0))\nexp = masked_unary_operation(umath.exp)\nconjugate = masked_unary_operation(umath.conjugate)\nsin = masked_unary_operation(umath.sin)\ncos = masked_unary_operation(umath.cos)\ntan = masked_unary_operation(umath.tan, 0.0, domain_tan(1.e-35))\narcsin = masked_unary_operation(umath.arcsin, 0.0, domain_check_interval(-1.0, 1.0))\narccos = masked_unary_operation(umath.arccos, 0.0, domain_check_interval(-1.0, 1.0))\narctan = masked_unary_operation(umath.arctan)\n# Missing from numeric\narcsinh = masked_unary_operation(umath.arcsinh)\narccosh = masked_unary_operation(umath.arccosh, 1.0, domain_greater_equal(1.0))\narctanh = masked_unary_operation(umath.arctanh, 0.0, domain_check_interval(-1.0+1e-15, 1.0-1e-15))\nsinh = masked_unary_operation(umath.sinh)\ncosh = masked_unary_operation(umath.cosh)\ntanh = masked_unary_operation(umath.tanh)\nabsolute = masked_unary_operation(umath.absolute)\nfabs = masked_unary_operation(umath.fabs)\nnegative = masked_unary_operation(umath.negative)\n\ndef nonzero(a):\n \"\"\"returns the indices of the elements of a which are not zero and not masked\n\n a must be 1d\n \"\"\"\n return asarray(filled(a, 0).nonzero())\n\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nlogical_not = masked_unary_operation(umath.logical_not)\n\nadd = masked_binary_operation(umath.add)\nsubtract = masked_binary_operation(umath.subtract)\nsubtract.reduce = None\nmultiply = masked_binary_operation(umath.multiply, 1, 1)\ndivide = domained_binary_operation(umath.divide, domain_safe_divide(), 0, 1)\ntrue_divide = domained_binary_operation(umath.true_divide, domain_safe_divide(), 0, 1)\nfloor_divide = domained_binary_operation(umath.floor_divide, domain_safe_divide(), 0, 1)\nremainder = domained_binary_operation(umath.remainder, domain_safe_divide(), 0, 1)\nfmod = domained_binary_operation(umath.fmod, domain_safe_divide(), 0, 1)\nhypot = masked_binary_operation(umath.hypot)\narctan2 = masked_binary_operation(umath.arctan2, 0.0, 1.0)\narctan2.reduce = None\nequal = masked_binary_operation(umath.equal)\nequal.reduce = None\nnot_equal = masked_binary_operation(umath.not_equal)\nnot_equal.reduce = None\nless_equal = masked_binary_operation(umath.less_equal)\nless_equal.reduce = None\ngreater_equal = masked_binary_operation(umath.greater_equal)\ngreater_equal.reduce = None\nless = masked_binary_operation(umath.less)\nless.reduce = None\ngreater = masked_binary_operation(umath.greater)\ngreater.reduce = None\nlogical_and = masked_binary_operation(umath.logical_and)\nalltrue = masked_binary_operation(umath.logical_and, 1, 1).reduce\nlogical_or = masked_binary_operation(umath.logical_or)\nsometrue = logical_or.reduce\nlogical_xor = masked_binary_operation(umath.logical_xor)\nbitwise_and = masked_binary_operation(umath.bitwise_and)\nbitwise_or = masked_binary_operation(umath.bitwise_or)\nbitwise_xor = masked_binary_operation(umath.bitwise_xor)\n\ndef rank (object):\n return oldnumeric.rank(filled(object))\n\ndef shape (object):\n return oldnumeric.shape(filled(object))\n\ndef size (object, axis=None):\n return oldnumeric.size(filled(object), axis)\n\nclass MaskedArray (object):\n \"\"\"Arrays with possibly masked values.\n Masked values of 1 exclude the corresponding element from\n any computation.\n\n Construction:\n x = array(data, dtype=None, copy=True, order=False,\n mask = nomask, fill_value=None)\n\n If copy=False, every effort is made not to copy the data:\n If data is a MaskedArray, and argument mask=nomask,\n then the candidate data is data.data and the\n mask used is data.mask. If data is a numeric array,\n it is used as the candidate raw data.\n If dtype.char is not None and\n is != data.dtype.char then a data copy is required.\n Otherwise, the candidate is used.\n\n If a data copy is required, raw data stored is the result of:\n numeric.array(data, dtype=dtype.char, copy=copy)\n\n If mask is nomask there are no masked values. Otherwise mask must\n be convertible to an array of booleans with the same shape as x.\n\n fill_value is used to fill in masked values when necessary,\n such as when printing and in method/function filled().\n The fill_value is not used for computation within this module.\n \"\"\"\n __array_priority__ = 10.1\n def __init__(self, data, dtype=None, copy=True, order=False,\n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None)\n If data already a numeric array, its dtype becomes the default value of dtype.\n \"\"\"\n if dtype is None:\n tc = None\n else:\n tc = numeric.dtype(dtype)\n need_data_copied = copy\n if isinstance(data, MaskedArray):\n c = data.data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n if mask is nomask:\n mask = data.mask\n elif mask is not nomask: #attempting to change the mask\n need_data_copied = True\n\n elif isinstance(data, ndarray):\n c = data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n else:\n need_data_copied = False #because I'll do it now\n c = numeric.array(data, dtype=tc, copy=True, order=order)\n tc = c.dtype\n\n if need_data_copied:\n if tc == c.dtype:\n self._data = numeric.array(c, dtype=tc, copy=True, order=order)\n else:\n self._data = c.astype(tc)\n else:\n self._data = c\n\n if mask is nomask:\n self._mask = nomask\n self._shared_mask = 0\n else:\n self._mask = make_mask (mask)\n if self._mask is nomask:\n self._shared_mask = 0\n else:\n self._shared_mask = (self._mask is mask)\n nm = size(self._mask)\n nd = size(self._data)\n if nm != nd:\n if nm == 1:\n self._mask = oldnumeric.resize(self._mask, self._data.shape)\n self._shared_mask = 0\n elif nd == 1:\n self._data = oldnumeric.resize(self._data, self._mask.shape)\n self._data.shape = self._mask.shape\n else:\n raise MAError, \"Mask and data not compatible.\"\n elif nm == 1 and shape(self._mask) != shape(self._data):\n self.unshare_mask()\n self._mask.shape = self._data.shape\n\n self.set_fill_value(fill_value)\n\n def __array__ (self, t=None, context=None):\n \"Special hook for numeric. Converts to numeric if possible.\"\n if self._mask is not nomask:\n if oldnumeric.ravel(self._mask).any():\n if context is None:\n warnings.warn(\"Cannot automatically convert masked array to \"\\\n \"numeric because data\\n is masked in one or \"\\\n \"more locations.\");\n return self._data\n #raise MAError, \\\n # \"\"\"Cannot automatically convert masked array to numeric because data\n # is masked in one or more locations.\n # \"\"\"\n else:\n func, args, i = context\n fills = ufunc_fills.get(func)\n if fills is None:\n raise MAError, \"%s not known to ma\" % func\n return self.filled(fills[i])\n else: # Mask is all false\n # Optimize to avoid future invocations of this section.\n self._mask = nomask\n self._shared_mask = 0\n if t:\n return self._data.astype(t)\n else:\n return self._data\n\n def __array_wrap__ (self, array, context):\n \"\"\"Special hook for ufuncs.\n\n Wraps the numpy array and sets the mask according to\n context.\n \"\"\"\n func, args = context[:2]\n domain = ufunc_domain[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[getattr(a, '_data', a)\n for a in args]))\n if m is not nomask:\n try:\n shape = array.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = reduce(mask_or, [getmaskarray(a) for a in args])\n\n return MaskedArray(array, copy=False, mask=m)\n\n def _get_shape(self):\n \"Return the current shape.\"\n return self._data.shape\n\n def _set_shape (self, newshape):\n \"Set the array's shape.\"\n self._data.shape = newshape\n if self._mask is not nomask:\n self._mask = self._mask.copy()\n self._mask.shape = newshape\n\n def _get_flat(self):\n \"\"\"Calculate the flat value.\n \"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel(), mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.ravel(),\n mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_flat (self, value):\n \"x.flat = value\"\n y = self.ravel()\n y[:] = value\n\n def _get_real(self):\n \"Get the real part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.real, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.real, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_real (self, value):\n \"x.real = value\"\n y = self.real\n y[...] = value\n\n def _get_imaginary(self):\n \"Get the imaginary part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.imag, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.imag, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_imaginary (self, value):\n \"x.imaginary = value\"\n y = self.imaginary\n y[...] = value\n\n def __str__(self):\n \"\"\"Calculate the str representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n if masked_print_option.enabled():\n f = masked_print_option\n # XXX: Without the following special case masked\n # XXX: would print as \"[--]\", not \"--\". Can we avoid\n # XXX: checks for masked by choosing a different value\n # XXX: for the masked singleton? 2005-01-05 -- sasha\n if self is masked:\n return str(f)\n m = self._mask\n if m is not nomask and m.shape == () and m:\n return str(f)\n # convert to object array to make filled work\n self = self.astype(object)\n else:\n f = self.fill_value()\n res = self.filled(f)\n return str(res)\n\n def __repr__(self):\n \"\"\"Calculate the repr representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n with_mask = \"\"\"\\\narray(data =\n %(data)s,\n mask =\n %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n with_mask1 = \"\"\"\\\narray(data = %(data)s,\n mask = %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n without_mask = \"\"\"array(\n %(data)s)\"\"\"\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n\n n = len(self.shape)\n if self._mask is nomask:\n if n <= 1:\n return without_mask1 % {'data':str(self.filled())}\n return without_mask % {'data':str(self.filled())}\n else:\n if n <= 1:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n if self._mask is nomask:\n return without_mask % {'data':str(self.filled())}\n else:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n\n def __float__(self):\n \"Convert self to float.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python float.'\n return float(self.data.item())\n\n def __int__(self):\n \"Convert self to int.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python int.'\n return int(self.data.item())\n\n def __getitem__(self, i):\n \"Get item described by i. Not a copy as in previous versions.\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i]\n if m is nomask:\n return dout\n mi = m[i]\n if mi.size == 1:\n if mi:\n return masked\n else:\n return dout\n else:\n return masked_array(dout, mi, fill_value=self._fill_value)\n\n def __getslice__(self, i, j):\n \"Get slice described by i, j\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i:j]\n if m is nomask:\n return masked_array(dout, fill_value=self._fill_value)\n else:\n return masked_array(dout, mask = m[i:j], fill_value=self._fill_value)\n\n# --------\n# setitem and setslice notes\n# note that if value is masked, it means to mask those locations.\n# setting a value changes the mask to match the value in those locations.\n\n def __setitem__(self, index, value):\n \"Set item described by index. If value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, 'Cannot alter the masked element.'\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n else:\n self.unshare_mask()\n self._mask[index] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[index] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[index] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = True\n else:\n self.unshare_mask()\n self._mask[index] = m\n\n def __setslice__(self, i, j, value):\n \"Set slice i:j; if value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, \"Cannot alter the 'masked' object.\"\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n self._mask[i:j] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[i:j] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[i:j] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(self._data.shape)\n self._shared_mask = False\n self._mask[i:j] = m\n\n def __nonzero__(self):\n \"\"\"returns true if any element is non-zero or masked\n\n \"\"\"\n # XXX: This changes bool conversion logic from MA.\n # XXX: In MA bool(a) == len(a) != 0, but in numpy\n # XXX: scalars do not have len\n m = self._mask\n d = self._data\n return bool(m is not nomask and m.any()\n or d is not nomask and d.any())\n\n def __len__ (self):\n \"\"\"Return length of first dimension. This is weird but Python's\n slicing behavior depends on it.\"\"\"\n return len(self._data)\n\n def __and__(self, other):\n \"Return bitwise_and\"\n return bitwise_and(self, other)\n\n def __or__(self, other):\n \"Return bitwise_or\"\n return bitwise_or(self, other)\n\n def __xor__(self, other):\n \"Return bitwise_xor\"\n return bitwise_xor(self, other)\n\n __rand__ = __and__\n __ror__ = __or__\n __rxor__ = __xor__\n\n def __abs__(self):\n \"Return absolute(self)\"\n return absolute(self)\n\n def __neg__(self):\n \"Return negative(self)\"\n return negative(self)\n\n def __pos__(self):\n \"Return array(self)\"\n return array(self)\n\n def __add__(self, other):\n \"Return add(self, other)\"\n return add(self, other)\n\n __radd__ = __add__\n\n def __mod__ (self, other):\n \"Return remainder(self, other)\"\n return remainder(self, other)\n\n def __rmod__ (self, other):\n \"Return remainder(other, self)\"\n return remainder(other, self)\n\n def __lshift__ (self, n):\n return left_shift(self, n)\n\n def __rshift__ (self, n):\n return right_shift(self, n)\n\n def __sub__(self, other):\n \"Return subtract(self, other)\"\n return subtract(self, other)\n\n def __rsub__(self, other):\n \"Return subtract(other, self)\"\n return subtract(other, self)\n\n def __mul__(self, other):\n \"Return multiply(self, other)\"\n return multiply(self, other)\n\n __rmul__ = __mul__\n\n def __div__(self, other):\n \"Return divide(self, other)\"\n return divide(self, other)\n\n def __rdiv__(self, other):\n \"Return divide(other, self)\"\n return divide(other, self)\n\n def __truediv__(self, other):\n \"Return divide(self, other)\"\n return true_divide(self, other)\n\n def __rtruediv__(self, other):\n \"Return divide(other, self)\"\n return true_divide(other, self)\n\n def __floordiv__(self, other):\n \"Return divide(self, other)\"\n return floor_divide(self, other)\n\n def __rfloordiv__(self, other):\n \"Return divide(other, self)\"\n return floor_divide(other, self)\n\n def __pow__(self, other, third=None):\n \"Return power(self, other, third)\"\n return power(self, other, third)\n\n def __sqrt__(self):\n \"Return sqrt(self)\"\n return sqrt(self)\n\n def __iadd__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data += f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = add(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __imul__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data *= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = multiply(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __isub__(self, other):\n \"Subtract other from self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data -= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = subtract(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n\n\n def __idiv__(self, other):\n \"Divide self by other in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n mo = getmask(other)\n result = divide(self, masked_array(f, mask=mo))\n self._data = result.data\n dm = result.raw_mask()\n if dm is not self._mask:\n self._mask = dm\n self._shared_mask = 1\n return self\n\n def __eq__(self, other):\n return equal(self,other)\n\n def __ne__(self, other):\n return not_equal(self,other)\n\n def __lt__(self, other):\n return less(self,other)\n\n def __le__(self, other):\n return less_equal(self,other)\n\n def __gt__(self, other):\n return greater(self,other)\n\n def __ge__(self, other):\n return greater_equal(self,other)\n\n def astype (self, tc):\n \"return self as array of given type.\"\n d = self._data.astype(tc)\n return array(d, mask=self._mask)\n\n def byte_swapped(self):\n \"\"\"Returns the raw data field, byte_swapped. Included for consistency\n with numeric but doesn't make sense in this context.\n \"\"\"\n return self._data.byte_swapped()\n\n def compressed (self):\n \"A 1-D array of all the non-masked data.\"\n d = oldnumeric.ravel(self._data)\n if self._mask is nomask:\n return array(d)\n else:\n m = 1 - oldnumeric.ravel(self._mask)\n c = oldnumeric.compress(m, d)\n return array(c, copy=0)\n\n def count (self, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n m = self._mask\n s = self._data.shape\n ls = len(s)\n if m is nomask:\n if ls == 0:\n return 1\n if ls == 1:\n return s[0]\n if axis is None:\n return reduce(lambda x, y:x*y, s)\n else:\n n = s[axis]\n t = list(s)\n del t[axis]\n return ones(t) * n\n if axis is None:\n w = oldnumeric.ravel(m).astype(int)\n n1 = size(w)\n if n1 == 1:\n n2 = w[0]\n else:\n n2 = umath.add.reduce(w)\n return n1 - n2\n else:\n n1 = size(m, axis)\n n2 = sum(m.astype(int), axis)\n return n1 - n2\n\n def dot (self, other):\n \"s.dot(other) = innerproduct(s, other)\"\n return innerproduct(self, other)\n\n def fill_value(self):\n \"Get the current fill value.\"\n return self._fill_value\n\n def filled (self, fill_value=None):\n \"\"\"A numeric array with masked values filled. If fill_value is None,\n use self.fill_value().\n\n If mask is nomask, copy data only if not contiguous.\n Result is always a contiguous, numeric array.\n# Is contiguous really necessary now?\n \"\"\"\n d = self._data\n m = self._mask\n if m is nomask:\n if d.flags['CONTIGUOUS']:\n return d\n else:\n return d.copy()\n else:\n if fill_value is None:\n value = self._fill_value\n else:\n value = fill_value\n\n if self is masked:\n result = numeric.array(value)\n else:\n try:\n result = numeric.array(d, dtype=d.dtype, copy=1)\n result[m] = value\n except (TypeError, AttributeError):\n #ok, can't put that value in here\n value = numeric.array(value, dtype=object)\n d = d.astype(object)\n result = oldnumeric.choose(m, (d, value))\n except IndexError:\n #ok, if scalar\n if d.shape:\n raise\n elif m:\n result = numeric.array(value, dtype=d.dtype)\n else:\n result = d\n return result\n\n def ids (self):\n \"\"\"Return the ids of the data and mask areas\"\"\"\n return (id(self._data), id(self._mask))\n\n def iscontiguous (self):\n \"Is the data contiguous?\"\n return self._data.flags['CONTIGUOUS']\n\n def itemsize(self):\n \"Item size of each data item.\"\n return self._data.itemsize\n\n\n def outer(self, other):\n \"s.outer(other) = outerproduct(s, other)\"\n return outerproduct(self, other)\n\n def put (self, values):\n \"\"\"Set the non-masked entries of self to filled(values).\n No change to mask\n \"\"\"\n iota = numeric.arange(self.size)\n d = self._data\n if self._mask is nomask:\n ind = iota\n else:\n ind = oldnumeric.compress(1 - self._mask, iota)\n d[ind] = filled(values).astype(d.dtype)\n\n def putmask (self, values):\n \"\"\"Set the masked entries of self to filled(values).\n Mask changed to nomask.\n \"\"\"\n d = self._data\n if self._mask is not nomask:\n d[self._mask] = filled(values).astype(d.dtype)\n self._shared_mask = 0\n self._mask = nomask\n\n def ravel (self):\n \"\"\"Return a 1-D view of self.\"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel())\n else:\n return masked_array(self._data.ravel(), self._mask.ravel())\n\n def raw_data (self):\n \"\"\" Obsolete; use data property instead.\n The raw data; portions may be meaningless.\n May be noncontiguous. Expert use only.\"\"\"\n return self._data\n data = property(fget=raw_data,\n doc=\"The data, but values at masked locations are meaningless.\")\n\n def raw_mask (self):\n \"\"\" Obsolete; use mask property instead.\n May be noncontiguous. Expert use only.\n \"\"\"\n return self._mask\n mask = property(fget=raw_mask,\n doc=\"The mask, may be nomask. Values where mask true are meaningless.\")\n\n def reshape (self, *s):\n \"\"\"This array reshaped to shape s\"\"\"\n d = self._data.reshape(*s)\n if self._mask is nomask:\n return masked_array(d)\n else:\n m = self._mask.reshape(*s)\n return masked_array(d, m)\n\n def set_fill_value (self, v=None):\n \"Set the fill value to v. Omit v to restore default.\"\n if v is None:\n v = default_fill_value (self.raw_data())\n self._fill_value = v\n\n def _get_ndim(self):\n return self._data.ndim\n ndim = property(_get_ndim, doc=numeric.ndarray.ndim.__doc__)\n\n def _get_size (self):\n return self._data.size\n size = property(fget=_get_size, doc=\"Number of elements in the array.\")\n## CHECK THIS: signature of numeric.array.size?\n\n def _get_dtype(self):\n return self._data.dtype\n dtype = property(fget=_get_dtype, doc=\"type of the array elements.\")\n\n def item(self):\n \"Return Python scalar if possible.\"\n if self._mask is not nomask:\n m = oldnumeric.ravel(self._mask)\n try:\n if m[0]:\n return masked\n except IndexError:\n return masked\n return self._data.item()\n\n def tolist(self, fill_value=None):\n \"Convert to list\"\n return self.filled(fill_value).tolist()\n\n def tostring(self, fill_value=None):\n \"Convert to string\"\n return self.filled(fill_value).tostring()\n\n def unmask (self):\n \"Replace the mask by nomask if possible.\"\n if self._mask is nomask: return\n m = make_mask(self._mask, flag=1)\n if m is nomask:\n self._mask = nomask\n self._shared_mask = 0\n\n def unshare_mask (self):\n \"If currently sharing mask, make a copy.\"\n if self._shared_mask:\n self._mask = make_mask (self._mask, copy=1, flag=0)\n self._shared_mask = 0\n\n shape = property(_get_shape, _set_shape,\n doc = 'tuple giving the shape of the array')\n\n flat = property(_get_flat, _set_flat,\n doc = 'Access array in flat form.')\n\n real = property(_get_real, _set_real,\n doc = 'Access the real part of the array')\n\n imaginary = property(_get_imaginary, _set_imaginary,\n doc = 'Access the imaginary part of the array')\n\n imag = imaginary\n\n#end class MaskedArray\n\narray = MaskedArray\n\ndef isMaskedArray (x):\n \"Is x a masked array, that is, an instance of MaskedArray?\"\n return isinstance(x, MaskedArray)\n\nisarray = isMaskedArray\nisMA = isMaskedArray #backward compatibility\n\ndef allclose (a, b, fill_value=1, rtol=1.e-5, atol=1.e-8):\n \"\"\" Returns true if all components of a and b are equal\n subject to given tolerances.\n If fill_value is 1, masked values considered equal.\n If fill_value is 0, masked values considered unequal.\n The relative error rtol should be positive and << 1.0\n The absolute error atol comes into play for those elements\n of b that are very small or zero; it says how small a must be also.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a)\n d2 = filled(b)\n x = filled(array(d1, copy=0, mask=m), fill_value).astype(float)\n y = filled(array(d2, copy=0, mask=m), 1).astype(float)\n d = umath.less_equal(umath.absolute(x-y), atol + rtol * umath.absolute(y))\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n\ndef allequal (a, b, fill_value=1):\n \"\"\"\n True if all entries of a and b are equal, using\n fill_value as a truth value where either or both are masked.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n if m is nomask:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n elif fill_value:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n dm = array(d, mask=m, copy=0)\n return oldnumeric.alltrue(oldnumeric.ravel(filled(dm, 1)))\n else:\n return 0\n\ndef masked_values (data, value, rtol=1.e-5, atol=1.e-8, copy=1):\n \"\"\"\n masked_values(data, value, rtol=1.e-5, atol=1.e-8)\n Create a masked array; mask is nomask if possible.\n If copy==0, and otherwise possible, result\n may share data values with original array.\n Let d = filled(data, value). Returns d\n masked where abs(data-value)<= atol + rtol * abs(value)\n if d is of a floating point type. Otherwise returns\n masked_object(d, value, copy)\n \"\"\"\n abs = umath.absolute\n d = filled(data, value)\n if issubclass(d.dtype.type, numeric.floating):\n m = umath.less_equal(abs(d-value), atol+rtol*abs(value))\n m = make_mask(m, flag=1)\n return array(d, mask = m, copy=copy,\n fill_value=value)\n else:\n return masked_object(d, value, copy=copy)\n\ndef masked_object (data, value, copy=1):\n \"Create array masked where exactly data equal to value\"\n d = filled(data, value)\n dm = make_mask(umath.equal(d, value), flag=1)\n return array(d, mask=dm, copy=copy, fill_value=value)\n\ndef arrayrange(start, stop=None, step=1, dtype=None):\n \"\"\"Just like range() except it returns a array whose type can be specified\n by the keyword argument dtype.\n \"\"\"\n return array(numeric.arrayrange(start, stop, step, dtype))\n\narange = arrayrange\n\ndef fromstring (s, t):\n \"Construct a masked array from a string. Result will have no mask.\"\n return masked_array(numeric.fromstring(s, t))\n\ndef left_shift (a, n):\n \"Left shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.left_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.left_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef right_shift (a, n):\n \"Right shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.right_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.right_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef resize (a, new_shape):\n \"\"\"resize(a, new_shape) returns a new array with the specified shape.\n The original array's total size can be any size.\"\"\"\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.resize(m, new_shape)\n result = array(oldnumeric.resize(filled(a), new_shape), mask=m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n \"\"\"\n af = filled(a)\n if isinstance(repeats, types.IntType):\n repeats = tuple([repeats]*(shape(af)[axis]))\n\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.repeat(m, repeats, axis)\n d = oldnumeric.repeat(af, repeats, axis)\n result = masked_array(d, m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef identity(n):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n return array(numeric.identity(n))\n\ndef indices (dimensions, dtype=None):\n \"\"\"indices(dimensions,dtype=None) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n return array(numeric.indices(dimensions, dtype))\n\ndef zeros (shape, dtype=int):\n \"\"\"zeros(n, dtype=int) =\n an array of all zeros of the given length or shape.\"\"\"\n return array(numeric.zeros(shape, dtype))\n\ndef ones (shape, dtype=int):\n \"\"\"ones(n, dtype=int) =\n an array of all ones of the given length or shape.\"\"\"\n return array(numeric.ones(shape, dtype))\n\n\ndef count (a, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n a = masked_array(a)\n return a.count(axis)\n\ndef power (a, b, third=None):\n \"a**b\"\n if third is not None:\n raise MAError, \"3-argument power not supported.\"\n ma = getmask(a)\n mb = getmask(b)\n m = mask_or(ma, mb)\n fa = filled(a, 1)\n fb = filled(b, 1)\n if fb.dtype.char in typecodes[\"Integer\"]:\n return masked_array(umath.power(fa, fb), m)\n md = make_mask(umath.less_equal (fa, 0), flag=1)\n m = mask_or(m, md)\n if m is nomask:\n return masked_array(umath.power(fa, fb))\n else:\n fa = numeric.where(m, 1, fa)\n return masked_array(umath.power(fa, fb), m)\n\ndef masked_array (a, mask=nomask, fill_value=None):\n \"\"\"masked_array(a, mask=nomask) =\n array(a, mask=mask, copy=0, fill_value=fill_value)\n \"\"\"\n return array(a, mask=mask, copy=0, fill_value=fill_value)\n\nsum = add.reduce\nproduct = multiply.reduce\n\ndef average (a, axis=0, weights=None, returned = 0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis.\n If axis is None, average over the entire array\n Inputs can be integer or floating types; result is of type float.\n\n If weights are given, result is sum(a*weights)/(sum(weights)*1.0)\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis.\n\n If returned, return a tuple: the result and the sum of the weights\n or count of values. Results will have the same shape.\n\n masked values in the weights will be set to 0.0\n \"\"\"\n a = masked_array(a)\n mask = a.mask\n ash = a.shape\n if ash == ():\n ash = (1,)\n if axis is None:\n if mask is nomask:\n if weights is None:\n n = add.reduce(a.raw_data().ravel())\n d = reduce(lambda x, y: x * y, ash, 1.0)\n else:\n w = filled(weights, 0.0).ravel()\n n = umath.add.reduce(a.raw_data().ravel() * w)\n d = umath.add.reduce(w)\n del w\n else:\n if weights is None:\n n = add.reduce(a.ravel())\n w = oldnumeric.choose(mask, (1.0, 0.0)).ravel()\n d = umath.add.reduce(w)\n del w\n else:\n w = array(filled(weights, 0.0), float, mask=mask).ravel()\n n = add.reduce(a.ravel() * w)\n d = add.reduce(w)\n del w\n else:\n if mask is nomask:\n if weights is None:\n d = ash[axis] * 1.0\n n = umath.add.reduce(a.raw_data(), axis)\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = numeric.array(w, float, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * ones(ash, float)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w, r\n else:\n raise ValueError, 'average: weights wrong shape.'\n else:\n if weights is None:\n n = add.reduce(a, axis)\n w = numeric.choose(mask, (1.0, 0.0))\n d = umath.add.reduce(w, axis)\n del w\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = array(w, float, mask=mask, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * masked_array(ones(ash, float), mask)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n del w\n #print n, d, repr(mask), repr(weights)\n if n is masked or d is masked: return masked\n result = divide (n, d)\n del n\n\n if isinstance(result, MaskedArray):\n result.unmask()\n if returned:\n if not isinstance(d, MaskedArray):\n d = masked_array(d)\n if not d.shape == result.shape:\n d = ones(result.shape, float) * d\n d.unmask()\n if returned:\n return result, d\n else:\n return result\n\ndef where (condition, x, y):\n \"\"\"where(condition, x, y) is x where condition is nonzero, y otherwise.\n condition must be convertible to an integer array.\n Answer is always the shape of condition.\n The type depends on x and y. It is integer if both x and y are\n the value masked.\n \"\"\"\n fc = filled(not_equal(condition, 0), 0)\n xv = filled(x)\n xm = getmask(x)\n yv = filled(y)\n ym = getmask(y)\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n m = make_mask(mask_or(m, md), copy=0, flag=1)\n return masked_array(d, m)\n\ndef choose (indices, t):\n \"Returns array shaped like indices with elements chosen from t\"\n def fmask (x):\n if x is masked: return 1\n return filled(x)\n def nmask (x):\n if x is masked: return 1\n m = getmask(x)\n if m is nomask: return 0\n return m\n c = filled(indices, 0)\n masks = [nmask(x) for x in t]\n a = [fmask(x) for x in t]\n d = numeric.choose(c, a)\n m = numeric.choose(c, masks)\n m = make_mask(mask_or(m, getmask(indices)), copy=0, flag=1)\n return masked_array(d, m)\n\ndef masked_where(condition, x, copy=1):\n \"\"\"Return x as an array masked where condition is true.\n Also masked where x or condition masked.\n \"\"\"\n cm = filled(condition,1)\n m = mask_or(getmask(x), cm)\n return array(filled(x), copy=copy, mask=m)\n\ndef masked_greater(x, value, copy=1):\n \"masked_greater(x, value) = x masked where x > value\"\n return masked_where(greater(x, value), x, copy)\n\ndef masked_greater_equal(x, value, copy=1):\n \"masked_greater_equal(x, value) = x masked where x >= value\"\n return masked_where(greater_equal(x, value), x, copy)\n\ndef masked_less(x, value, copy=1):\n \"masked_less(x, value) = x masked where x < value\"\n return masked_where(less(x, value), x, copy)\n\ndef masked_less_equal(x, value, copy=1):\n \"masked_less_equal(x, value) = x masked where x <= value\"\n return masked_where(less_equal(x, value), x, copy)\n\ndef masked_not_equal(x, value, copy=1):\n \"masked_not_equal(x, value) = x masked where x != value\"\n d = filled(x, 0)\n c = umath.not_equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_equal(x, value, copy=1):\n \"\"\"masked_equal(x, value) = x masked where x == value\n For floating point consider masked_values(x, value) instead.\n \"\"\"\n d = filled(x, 0)\n c = umath.equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_inside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are inside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_and(umath.less_equal(d, v2), umath.greater_equal(d, v1))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef masked_outside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are outside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_or(umath.less(d, v1), umath.greater(d, v2))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef reshape (a, *newshape):\n \"Copy of a with a new shape.\"\n m = getmask(a)\n d = filled(a).reshape(*newshape)\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.reshape(m, *newshape))\n\ndef ravel (a):\n \"a as one-dimensional, may share data and mask\"\n m = getmask(a)\n d = oldnumeric.ravel(filled(a))\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.ravel(m))\n\ndef concatenate (arrays, axis=0):\n \"Concatenate the arrays along the given axis\"\n d = []\n for x in arrays:\n d.append(filled(x))\n d = numeric.concatenate(d, axis)\n for x in arrays:\n if getmask(x) is not nomask: break\n else:\n return masked_array(d)\n dm = []\n for x in arrays:\n dm.append(getmaskarray(x))\n dm = numeric.concatenate(dm, axis)\n return masked_array(d, mask=dm)\n\ndef swapaxes (a, axis1, axis2):\n m = getmask(a)\n d = masked_array(a).data\n if m is nomask:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2))\n else:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2),\n mask=numeric.swapaxes(m, axis1, axis2),)\n\n\ndef take (a, indices, axis=0):\n \"take(a, indices, axis=0) returns selection of items from a.\"\n m = getmask(a)\n # d = masked_array(a).raw_data()\n d = masked_array(a).data\n if m is nomask:\n return masked_array(numeric.take(d, indices, axis))\n else:\n return masked_array(numeric.take(d, indices, axis),\n mask = numeric.take(m, indices, axis))\n\ndef transpose(a, axes=None):\n \"transpose(a, axes=None) reorder dimensions per tuple axes\"\n m = getmask(a)\n d = filled(a)\n if m is nomask:\n return masked_array(numeric.transpose(d, axes))\n else:\n return masked_array(numeric.transpose(d, axes),\n mask = numeric.transpose(m, axes))\n\n\ndef put(a, indices, values):\n \"\"\"put(a, indices, values) sets storage-indexed locations to corresponding values.\n\n Values and indices are filled if necessary.\n\n \"\"\"\n d = a.raw_data()\n ind = filled(indices)\n v = filled(values)\n numeric.put (d, ind, v)\n m = getmask(a)\n if m is not nomask:\n a.unshare_mask()\n numeric.put(a.raw_mask(), ind, 0)\n\ndef putmask(a, mask, values):\n \"putmask(a, mask, values) sets a where mask is true.\"\n if mask is nomask:\n return\n numeric.putmask(a.raw_data(), mask, values)\n m = getmask(a)\n if m is nomask: return\n a.unshare_mask()\n numeric.putmask(a.raw_mask(), mask, 0)\n\ndef innerproduct(a, b):\n \"\"\"innerproduct(a,b) returns the dot product of two arrays, which has\n shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the\n product of the elements from the last dimensions of a and b.\n Masked elements are replace by zeros.\n \"\"\"\n fa = filled(a, 0)\n fb = filled(b, 0)\n if len(fa.shape) == 0: fa.shape = (1,)\n if len(fb.shape) == 0: fb.shape = (1,)\n return masked_array(numeric.innerproduct(fa, fb))\n\ndef outerproduct(a, b):\n \"\"\"outerproduct(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))\"\"\"\n fa = filled(a, 0).ravel()\n fb = filled(b, 0).ravel()\n d = numeric.outerproduct(fa, fb)\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n return masked_array(d)\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = make_mask(1-numeric.outerproduct(1-ma, 1-mb), copy=0)\n return masked_array(d, m)\n\ndef dot(a, b):\n \"\"\"dot(a,b) returns matrix-multiplication between a and b. The product-sum\n is over the last dimension of a and the second-to-last dimension of b.\n Masked values are replaced by zeros. See also innerproduct.\n \"\"\"\n return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))\n\ndef compress(condition, x, dimension=-1):\n \"\"\"Select those parts of x for which condition is true.\n Masked values in condition are considered false.\n \"\"\"\n c = filled(condition, 0)\n m = getmask(x)\n if m is not nomask:\n m = numeric.compress(c, m, dimension)\n d = numeric.compress(c, filled(x), dimension)\n return masked_array(d, m)\n\nclass _minimum_operation:\n \"Object to calculate minima\"\n def __init__ (self):\n \"\"\"minimum(a, b) or minimum(a)\n In one argument case returns the scalar minimum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amin(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amin(ac.raw_data())\n else:\n return where(less(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.minimum.reduce (t, axis))\n else:\n t = umath.minimum.reduce(filled(target, minimum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.minimum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nminimum = _minimum_operation ()\n\nclass _maximum_operation:\n \"Object to calculate maxima\"\n def __init__ (self):\n \"\"\"maximum(a, b) or maximum(a)\n In one argument case returns the scalar maximum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amax(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amax(ac.raw_data())\n else:\n return where(greater(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.maximum.reduce (t, axis))\n else:\n t = umath.maximum.reduce(filled(target, maximum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.maximum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nmaximum = _maximum_operation ()\n\ndef sort (x, axis = -1, fill_value=None):\n \"\"\"If x does not have a mask, return a masked array formed from the\n result of numeric.sort(x, axis).\n Otherwise, fill x with fill_value. Sort it.\n Set a mask where the result is equal to fill_value.\n Note that this may have unintended consequences if the data contains the\n fill value at a non-masked site.\n\n If fill_value is not given the default fill value for x's type will be\n used.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n d = filled(x, fill_value)\n s = oldnumeric.sort(d, axis)\n if getmask(x) is nomask:\n return masked_array(s)\n return masked_values(s, fill_value, copy=0)\n\ndef diagonal(a, k = 0, axis1=0, axis2=1):\n \"\"\"diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a\"\"\"\n d = oldnumeric.diagonal(filled(a), k, axis1, axis2)\n m = getmask(a)\n if m is nomask:\n return masked_array(d, m)\n else:\n return masked_array(d, oldnumeric.diagonal(m, k, axis1, axis2))\n \ndef trace (a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return diagonal(a, offset, axis1, axis2).sum(dtype=dtype)\n\ndef argsort (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for sorting along given axis.\n if fill_value is None, use get_fill_value(x)\n Returns a numpy array.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argsort(d, axis)\n\ndef argmin (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return indices for minimum values along given axis.\n if fill_value is None, use get_fill_value(x).\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argmin(d, axis)\n\ndef argmax (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for maximum along given axis.\n if fill_value is None, use -get_fill_value(x) if it exists.\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n try:\n fill_value = - fill_value\n except:\n pass\n d = filled(x, fill_value)\n return oldnumeric.argmax(d, axis)\n\ndef fromfunction (f, s):\n \"\"\"apply f to s to create array as in umath.\"\"\"\n return masked_array(numeric.fromfunction(f, s))\n\ndef asarray(data, dtype=None):\n \"\"\"asarray(data, dtype) = array(data, dtype, copy=0)\n \"\"\"\n if isinstance(data, MaskedArray) and \\\n (dtype is None or dtype == data.dtype):\n return data\n return array(data, dtype=dtype, copy=0)\n\n# Add methods to support ndarray interface\n# XXX: I is better to to change the masked_*_operation adaptors\n# XXX: to wrap ndarray methods directly to create ma.array methods.\nfrom types import MethodType\ndef _m(f):\n return MethodType(f, None, array)\ndef not_implemented(*args, **kwds):\n raise NotImplementedError, \"not yet implemented for numpy.ma arrays\"\narray.all = _m(alltrue)\narray.any = _m(sometrue)\narray.argmax = _m(argmax)\narray.argmin = _m(argmin)\narray.argsort = _m(argsort)\narray.base = property(_m(not_implemented))\narray.byteswap = _m(not_implemented)\n\ndef _choose(self, *args):\n return choose(self, args)\narray.choose = _m(_choose)\ndel _choose\n\ndef _clip(self,a_min,a_max):\n return MaskedArray(data = self.data.clip(a_min, a_max),\n mask = self.mask)\narray.clip = _m(_clip)\n\ndef _compress(self, cond, axis=None):\n return compress(cond, self, axis)\narray.compress = _m(_compress)\ndel _compress\n\narray.conj = array.conjugate = _m(conjugate)\narray.copy = _m(not_implemented)\narray.cumprod = _m(not_implemented)\narray.cumsum = _m(not_implemented)\narray.diagonal = _m(diagonal)\narray.dump = _m(not_implemented)\narray.dumps = _m(not_implemented)\narray.fill = _m(not_implemented)\narray.flags = property(_m(not_implemented))\narray.flatten = _m(ravel)\narray.getfield = _m(not_implemented)\ndef _max(a, axis=None):\n if axis is None:\n return maximum(a)\n else:\n return maximum.reduce(a, axis)\narray.max = _m(_max)\ndel _max\ndef _min(a, axis=None):\n if axis is None:\n return minimum(a)\n else:\n return minimum.reduce(a, axis)\narray.min = _m(_min)\ndel _min\narray.mean = _m(average)\narray.nbytes = property(_m(not_implemented))\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\n\ndef _ptp(a,axis=0):\n return a.max(axis)-a.min(axis)\n\narray.ptp = _m(_ptp)\narray.repeat = _m(repeat)\narray.resize = _m(resize)\narray.searchsorted = _m(not_implemented)\narray.setfield = _m(not_implemented)\narray.setflags = _m(not_implemented)\narray.sort = _m(not_implemented) # NB: ndarray.sort is inplace\narray.squeeze = _m(not_implemented)\narray.std = _m(not_implemented)\narray.strides = property(_m(not_implemented))\narray.sum = _m(sum)\ndef _swapaxes(self,axis1,axis2):\n return MaskedArray(data = self.data.swapaxes(axis1, axis2),\n mask = self.mask.swapaxes(axis1, axis2))\narray.swapaxes = _m(_swapaxes)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(trace)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\narray.round = _m(around)\ndel _m, MethodType, not_implemented\n\n\nmasked = MaskedArray(0, int, mask=1)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self , args = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 30, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , display )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "display" + ], + "start_line": 40, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "display", + "long_name": "display( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "set_display", + "long_name": "set_display( self , s )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "s" + ], + "start_line": 49, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enabled", + "long_name": "enabled( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enable", + "long_name": "enable( self , flag = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "flag" + ], + "start_line": 57, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "default_fill_value", + "long_name": "default_fill_value( obj )", + "filename": "ma.py", + "nloc": 25, + "complexity": 13, + "token_count": 146, + "parameters": [ + "obj" + ], + "start_line": 76, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "minimum_fill_value", + "long_name": "minimum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 107, + "parameters": [ + "obj" + ], + "start_line": 102, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "maximum_fill_value", + "long_name": "maximum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 105, + "parameters": [ + "obj" + ], + "start_line": 119, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( a , fill_value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 20, + "parameters": [ + "a", + "fill_value" + ], + "start_line": 136, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getmask", + "long_name": "getmask( a )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "a" + ], + "start_line": 141, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getmaskarray", + "long_name": "getmaskarray( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 150, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "is_mask", + "long_name": "is_mask( m )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "m" + ], + "start_line": 161, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "make_mask", + "long_name": "make_mask( m , copy = 0 , flag = 0 )", + "filename": "ma.py", + "nloc": 17, + "complexity": 7, + "token_count": 109, + "parameters": [ + "m", + "copy", + "flag" + ], + "start_line": 169, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "make_mask_none", + "long_name": "make_mask_none( s )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "mask_or", + "long_name": "mask_or( m1 , m2 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 5, + "token_count": 52, + "parameters": [ + "m1", + "m2" + ], + "start_line": 200, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "filled", + "long_name": "filled( a , value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 5, + "token_count": 70, + "parameters": [ + "a", + "value" + ], + "start_line": 209, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "get_fill_value", + "long_name": "get_fill_value( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 229, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "common_fill_value", + "long_name": "common_fill_value( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a", + "b" + ], + "start_line": 240, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , y1 , y2 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "y1", + "y2" + ], + "start_line": 250, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "x" + ], + "start_line": 255, + "end_line": 259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , eps )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "eps" + ], + "start_line": 263, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "x" + ], + "start_line": 267, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 273, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 277, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 283, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 287, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , aufunc , fill = 0 , domain = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 306, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "__init__", + "long_name": "__init__( self , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 321, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 323, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , domain , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 330, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 13, + "complexity": 2, + "token_count": 107, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 343, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "abfunc", + "fillx", + "filly" + ], + "start_line": 362, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 373, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 20, + "complexity": 7, + "token_count": 169, + "parameters": [ + "self", + "target", + "axis", + "dtype" + ], + "start_line": 381, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "accumulate", + "long_name": "accumulate( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 418, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "nonzero", + "long_name": "nonzero( a )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 447, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 492, + "end_line": 493, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 495, + "end_line": 496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( object , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "object", + "axis" + ], + "start_line": 498, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , data , dtype = None , copy = True , order = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "order", + "mask", + "fill_value" + ], + "start_line": 530, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None , context = None )", + "filename": "ma.py", + "nloc": 22, + "complexity": 6, + "token_count": 124, + "parameters": [ + "self", + "t", + "context" + ], + "start_line": 596, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 16, + "complexity": 8, + "token_count": 129, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 624, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_shape", + "long_name": "_get_shape( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 647, + "end_line": 649, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_set_shape", + "long_name": "_set_shape( self , newshape )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "newshape" + ], + "start_line": 651, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_get_flat", + "long_name": "_get_flat( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 658, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "_set_flat", + "long_name": "_set_flat( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "value" + ], + "start_line": 669, + "end_line": 672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_real", + "long_name": "_get_real( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 674, + "end_line": 681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_real", + "long_name": "_set_real( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 683, + "end_line": 686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_imaginary", + "long_name": "_get_imaginary( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 688, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_imaginary", + "long_name": "_set_imaginary( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 697, + "end_line": 700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 13, + "complexity": 6, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 702, + "end_line": 722, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "ma.py", + "nloc": 42, + "complexity": 5, + "token_count": 207, + "parameters": [ + "self" + ], + "start_line": 724, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "__float__", + "long_name": "__float__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__int__", + "long_name": "__int__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , i )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 70, + "parameters": [ + "self", + "i" + ], + "start_line": 785, + "end_line": 799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 801, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , index , value )", + "filename": "ma.py", + "nloc": 27, + "complexity": 7, + "token_count": 157, + "parameters": [ + "self", + "index", + "value" + ], + "start_line": 816, + "end_line": 842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__setslice__", + "long_name": "__setslice__( self , i , j , value )", + "filename": "ma.py", + "nloc": 23, + "complexity": 7, + "token_count": 155, + "parameters": [ + "self", + "i", + "j", + "value" + ], + "start_line": 844, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "__nonzero__", + "long_name": "__nonzero__( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 868, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 880, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__and__", + "long_name": "__and__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 885, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__or__", + "long_name": "__or__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 889, + "end_line": 891, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__xor__", + "long_name": "__xor__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 893, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__abs__", + "long_name": "__abs__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 901, + "end_line": 903, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__neg__", + "long_name": "__neg__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 905, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pos__", + "long_name": "__pos__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 909, + "end_line": 911, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 913, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 919, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 923, + "end_line": 925, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__lshift__", + "long_name": "__lshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 927, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__rshift__", + "long_name": "__rshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 933, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 937, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 941, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 947, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 951, + "end_line": 953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__truediv__", + "long_name": "__truediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 955, + "end_line": 957, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rtruediv__", + "long_name": "__rtruediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 959, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__floordiv__", + "long_name": "__floordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 963, + "end_line": 965, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rfloordiv__", + "long_name": "__rfloordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 967, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other , third = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "other", + "third" + ], + "start_line": 971, + "end_line": 973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__sqrt__", + "long_name": "__sqrt__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 975, + "end_line": 977, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__iadd__", + "long_name": "__iadd__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 979, + "end_line": 1020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 255, + "parameters": [ + "self", + "other" + ], + "start_line": 1022, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__isub__", + "long_name": "__isub__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 1065, + "end_line": 1106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__idiv__", + "long_name": "__idiv__( self , other )", + "filename": "ma.py", + "nloc": 38, + "complexity": 12, + "token_count": 237, + "parameters": [ + "self", + "other" + ], + "start_line": 1110, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1149, + "end_line": 1150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1152, + "end_line": 1153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1155, + "end_line": 1156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1158, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1161, + "end_line": 1162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1164, + "end_line": 1165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "astype", + "long_name": "astype( self , tc )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "tc" + ], + "start_line": 1167, + "end_line": 1170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "byte_swapped", + "long_name": "byte_swapped( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "compressed", + "long_name": "compressed( self )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "count", + "long_name": "count( self , axis = None )", + "filename": "ma.py", + "nloc": 29, + "complexity": 7, + "token_count": 173, + "parameters": [ + "self", + "axis" + ], + "start_line": 1188, + "end_line": 1216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dot", + "long_name": "dot( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1218, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "fill_value", + "long_name": "fill_value( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1222, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "filled", + "long_name": "filled( self , fill_value = None )", + "filename": "ma.py", + "nloc": 31, + "complexity": 9, + "token_count": 175, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1226, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 1 + }, + { + "name": "ids", + "long_name": "ids( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 1268, + "end_line": 1270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "iscontiguous", + "long_name": "iscontiguous( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 1272, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "itemsize", + "long_name": "itemsize( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 1276, + "end_line": 1278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1281, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "put", + "long_name": "put( self , values )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "values" + ], + "start_line": 1285, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "putmask", + "long_name": "putmask( self , values )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "values" + ], + "start_line": 1297, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "ravel", + "long_name": "ravel( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 1307, + "end_line": 1312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "raw_data", + "long_name": "raw_data( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1314, + "end_line": 1318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "raw_mask", + "long_name": "raw_mask( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1322, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "reshape", + "long_name": "reshape( self , * s )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self", + "s" + ], + "start_line": 1330, + "end_line": 1337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( self , v = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "v" + ], + "start_line": 1339, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_ndim", + "long_name": "_get_ndim( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1345, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_size", + "long_name": "_get_size( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1349, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_dtype", + "long_name": "_get_dtype( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1354, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "item", + "long_name": "item( self )", + "filename": "ma.py", + "nloc": 10, + "complexity": 4, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 1358, + "end_line": 1367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1369, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "tostring", + "long_name": "tostring( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1373, + "end_line": 1375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unmask", + "long_name": "unmask( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 3, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1377, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "unshare_mask", + "long_name": "unshare_mask( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 1385, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "isMaskedArray", + "long_name": "isMaskedArray( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "x" + ], + "start_line": 1409, + "end_line": 1411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , fill_value = 1 , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 140, + "parameters": [ + "a", + "b", + "fill_value", + "rtol", + "atol" + ], + "start_line": 1416, + "end_line": 1431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "allequal", + "long_name": "allequal( a , b , fill_value = 1 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 3, + "token_count": 125, + "parameters": [ + "a", + "b", + "fill_value" + ], + "start_line": 1433, + "end_line": 1451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "masked_values", + "long_name": "masked_values( data , value , rtol = 1 . e - 5 , atol = 1 . e - 8 , copy = 1 )", + "filename": "ma.py", + "nloc": 10, + "complexity": 2, + "token_count": 117, + "parameters": [ + "data", + "value", + "rtol", + "atol", + "copy" + ], + "start_line": 1453, + "end_line": 1472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "masked_object", + "long_name": "masked_object( data , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "data", + "value", + "copy" + ], + "start_line": 1474, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayrange", + "long_name": "arrayrange( start , stop = None , step = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 1480, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( s , t )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "s", + "t" + ], + "start_line": 1488, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "left_shift", + "long_name": "left_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1492, + "end_line": 1500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "right_shift", + "long_name": "right_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1502, + "end_line": 1510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 1512, + "end_line": 1520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 101, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 1522, + "end_line": 1537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "n" + ], + "start_line": 1539, + "end_line": 1542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 1544, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "zeros", + "long_name": "zeros( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1550, + "end_line": 1553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1555, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "count", + "long_name": "count( a , axis = None )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 1561, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( a , b , third = None )", + "filename": "ma.py", + "nloc": 18, + "complexity": 4, + "token_count": 154, + "parameters": [ + "a", + "b", + "third" + ], + "start_line": 1566, + "end_line": 1583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "masked_array", + "long_name": "masked_array( a , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "mask", + "fill_value" + ], + "start_line": 1585, + "end_line": 1589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "average", + "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", + "filename": "ma.py", + "nloc": 92, + "complexity": 22, + "token_count": 741, + "parameters": [ + "a", + "axis", + "weights", + "returned" + ], + "start_line": 1594, + "end_line": 1701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 107, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1703, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "choose.fmask", + "long_name": "choose.fmask( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "x" + ], + "start_line": 1723, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "choose.nmask", + "long_name": "choose.nmask( x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 3, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 1726, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "choose", + "long_name": "choose( indices , t )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 93, + "parameters": [ + "indices", + "t" + ], + "start_line": 1721, + "end_line": 1737, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "masked_where", + "long_name": "masked_where( condition , x , copy = 1 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "condition", + "x", + "copy" + ], + "start_line": 1739, + "end_line": 1745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "masked_greater", + "long_name": "masked_greater( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1747, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_greater_equal", + "long_name": "masked_greater_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1751, + "end_line": 1753, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less", + "long_name": "masked_less( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1755, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less_equal", + "long_name": "masked_less_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1759, + "end_line": 1761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_not_equal", + "long_name": "masked_not_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1763, + "end_line": 1768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "masked_equal", + "long_name": "masked_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1770, + "end_line": 1777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "masked_inside", + "long_name": "masked_inside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1779, + "end_line": 1790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "masked_outside", + "long_name": "masked_outside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1792, + "end_line": 1803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , * newshape )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 56, + "parameters": [ + "a", + "newshape" + ], + "start_line": 1805, + "end_line": 1812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( a )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "a" + ], + "start_line": 1814, + "end_line": 1821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "concatenate", + "long_name": "concatenate( arrays , axis = 0 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 5, + "token_count": 97, + "parameters": [ + "arrays", + "axis" + ], + "start_line": 1823, + "end_line": 1837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 1839, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1849, + "end_line": 1858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1860, + "end_line": 1868, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , indices , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 70, + "parameters": [ + "a", + "indices", + "values" + ], + "start_line": 1871, + "end_line": 1884, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 61, + "parameters": [ + "a", + "mask", + "values" + ], + "start_line": 1886, + "end_line": 1894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "innerproduct", + "long_name": "innerproduct( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 72, + "parameters": [ + "a", + "b" + ], + "start_line": 1896, + "end_line": 1906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "outerproduct", + "long_name": "outerproduct( a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 110, + "parameters": [ + "a", + "b" + ], + "start_line": 1908, + "end_line": 1920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dot", + "long_name": "dot( a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 36, + "parameters": [ + "a", + "b" + ], + "start_line": 1922, + "end_line": 1927, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , x , dimension = - 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 67, + "parameters": [ + "condition", + "x", + "dimension" + ], + "start_line": 1929, + "end_line": 1938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1942, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1948, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 1963, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1974, + "end_line": 1985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1991, + "end_line": 1995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1997, + "end_line": 2010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 2012, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 2023, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "sort", + "long_name": "sort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 3, + "token_count": 68, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2038, + "end_line": 2055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , k = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 73, + "parameters": [ + "a", + "k", + "axis1", + "axis2" + ], + "start_line": 2057, + "end_line": 2064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 2066, + "end_line": 2070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2072, + "end_line": 2079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2081, + "end_line": 2089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2091, + "end_line": 2105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( f , s )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "f", + "s" + ], + "start_line": 2107, + "end_line": 2109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( data , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 46, + "parameters": [ + "data", + "dtype" + ], + "start_line": 2111, + "end_line": 2117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_m", + "long_name": "_m( f )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "f" + ], + "start_line": 2123, + "end_line": 2124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( * args , ** kwds )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "args", + "kwds" + ], + "start_line": 2125, + "end_line": 2126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_choose", + "long_name": "_choose( self , * args )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 2135, + "end_line": 2136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_clip", + "long_name": "_clip( self , a_min , a_max )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "a_min", + "a_max" + ], + "start_line": 2140, + "end_line": 2144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_compress", + "long_name": "_compress( self , cond , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "cond", + "axis" + ], + "start_line": 2147, + "end_line": 2148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_cumprod", + "long_name": "_cumprod( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2155, + "end_line": 2159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_cumsum", + "long_name": "_cumsum( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2162, + "end_line": 2166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_max", + "long_name": "_max( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2177, + "end_line": 2181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_min", + "long_name": "_min( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2184, + "end_line": 2188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_ptp", + "long_name": "_ptp( a , axis = 0 )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 2197, + "end_line": 2198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_squeeze", + "long_name": "_squeeze( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 2207, + "end_line": 2213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_swapaxes", + "long_name": "_swapaxes( self , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "axis1", + "axis2" + ], + "start_line": 2218, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_var", + "long_name": "_var( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 86, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2227, + "end_line": 2234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_std", + "long_name": "_std( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2235, + "end_line": 2236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self , args = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 30, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , display )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "display" + ], + "start_line": 40, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "display", + "long_name": "display( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "set_display", + "long_name": "set_display( self , s )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "s" + ], + "start_line": 49, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enabled", + "long_name": "enabled( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enable", + "long_name": "enable( self , flag = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "flag" + ], + "start_line": 57, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "default_fill_value", + "long_name": "default_fill_value( obj )", + "filename": "ma.py", + "nloc": 25, + "complexity": 13, + "token_count": 146, + "parameters": [ + "obj" + ], + "start_line": 76, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "minimum_fill_value", + "long_name": "minimum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 107, + "parameters": [ + "obj" + ], + "start_line": 102, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "maximum_fill_value", + "long_name": "maximum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 105, + "parameters": [ + "obj" + ], + "start_line": 119, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( a , fill_value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 20, + "parameters": [ + "a", + "fill_value" + ], + "start_line": 136, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getmask", + "long_name": "getmask( a )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "a" + ], + "start_line": 141, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getmaskarray", + "long_name": "getmaskarray( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 150, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "is_mask", + "long_name": "is_mask( m )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "m" + ], + "start_line": 161, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "make_mask", + "long_name": "make_mask( m , copy = 0 , flag = 0 )", + "filename": "ma.py", + "nloc": 17, + "complexity": 7, + "token_count": 109, + "parameters": [ + "m", + "copy", + "flag" + ], + "start_line": 169, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "make_mask_none", + "long_name": "make_mask_none( s )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "mask_or", + "long_name": "mask_or( m1 , m2 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 5, + "token_count": 52, + "parameters": [ + "m1", + "m2" + ], + "start_line": 200, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "filled", + "long_name": "filled( a , value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 5, + "token_count": 70, + "parameters": [ + "a", + "value" + ], + "start_line": 209, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "get_fill_value", + "long_name": "get_fill_value( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 229, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "common_fill_value", + "long_name": "common_fill_value( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a", + "b" + ], + "start_line": 240, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , y1 , y2 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "y1", + "y2" + ], + "start_line": 250, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "x" + ], + "start_line": 255, + "end_line": 259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , eps )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "eps" + ], + "start_line": 263, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "x" + ], + "start_line": 267, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 273, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 277, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 283, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 287, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , aufunc , fill = 0 , domain = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 306, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "__init__", + "long_name": "__init__( self , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 321, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 323, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , domain , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 330, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 13, + "complexity": 2, + "token_count": 107, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 343, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "abfunc", + "fillx", + "filly" + ], + "start_line": 362, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 373, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 20, + "complexity": 7, + "token_count": 169, + "parameters": [ + "self", + "target", + "axis", + "dtype" + ], + "start_line": 381, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "accumulate", + "long_name": "accumulate( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 418, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "nonzero", + "long_name": "nonzero( a )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 447, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 492, + "end_line": 493, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 495, + "end_line": 496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( object , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "object", + "axis" + ], + "start_line": 498, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , data , dtype = None , copy = True , order = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "order", + "mask", + "fill_value" + ], + "start_line": 530, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None , context = None )", + "filename": "ma.py", + "nloc": 22, + "complexity": 6, + "token_count": 124, + "parameters": [ + "self", + "t", + "context" + ], + "start_line": 596, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 16, + "complexity": 8, + "token_count": 129, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 624, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_shape", + "long_name": "_get_shape( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 647, + "end_line": 649, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_set_shape", + "long_name": "_set_shape( self , newshape )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "newshape" + ], + "start_line": 651, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_get_flat", + "long_name": "_get_flat( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 658, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "_set_flat", + "long_name": "_set_flat( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "value" + ], + "start_line": 669, + "end_line": 672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_real", + "long_name": "_get_real( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 674, + "end_line": 681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_real", + "long_name": "_set_real( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 683, + "end_line": 686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_imaginary", + "long_name": "_get_imaginary( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 688, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_imaginary", + "long_name": "_set_imaginary( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 697, + "end_line": 700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 13, + "complexity": 6, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 702, + "end_line": 722, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "ma.py", + "nloc": 42, + "complexity": 5, + "token_count": 207, + "parameters": [ + "self" + ], + "start_line": 724, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "__float__", + "long_name": "__float__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__int__", + "long_name": "__int__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , i )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 70, + "parameters": [ + "self", + "i" + ], + "start_line": 785, + "end_line": 799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 801, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , index , value )", + "filename": "ma.py", + "nloc": 27, + "complexity": 7, + "token_count": 157, + "parameters": [ + "self", + "index", + "value" + ], + "start_line": 816, + "end_line": 842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__setslice__", + "long_name": "__setslice__( self , i , j , value )", + "filename": "ma.py", + "nloc": 23, + "complexity": 7, + "token_count": 155, + "parameters": [ + "self", + "i", + "j", + "value" + ], + "start_line": 844, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "__nonzero__", + "long_name": "__nonzero__( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 868, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 880, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__and__", + "long_name": "__and__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 885, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__or__", + "long_name": "__or__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 889, + "end_line": 891, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__xor__", + "long_name": "__xor__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 893, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__abs__", + "long_name": "__abs__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 901, + "end_line": 903, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__neg__", + "long_name": "__neg__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 905, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pos__", + "long_name": "__pos__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 909, + "end_line": 911, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 913, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 919, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 923, + "end_line": 925, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__lshift__", + "long_name": "__lshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 927, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__rshift__", + "long_name": "__rshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 933, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 937, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 941, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 947, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 951, + "end_line": 953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__truediv__", + "long_name": "__truediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 955, + "end_line": 957, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rtruediv__", + "long_name": "__rtruediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 959, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__floordiv__", + "long_name": "__floordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 963, + "end_line": 965, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rfloordiv__", + "long_name": "__rfloordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 967, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other , third = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "other", + "third" + ], + "start_line": 971, + "end_line": 973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__sqrt__", + "long_name": "__sqrt__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 975, + "end_line": 977, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__iadd__", + "long_name": "__iadd__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 979, + "end_line": 1020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 255, + "parameters": [ + "self", + "other" + ], + "start_line": 1022, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__isub__", + "long_name": "__isub__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 1065, + "end_line": 1106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__idiv__", + "long_name": "__idiv__( self , other )", + "filename": "ma.py", + "nloc": 38, + "complexity": 12, + "token_count": 237, + "parameters": [ + "self", + "other" + ], + "start_line": 1110, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1149, + "end_line": 1150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1152, + "end_line": 1153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1155, + "end_line": 1156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1158, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1161, + "end_line": 1162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1164, + "end_line": 1165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "astype", + "long_name": "astype( self , tc )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "tc" + ], + "start_line": 1167, + "end_line": 1170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "byte_swapped", + "long_name": "byte_swapped( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "compressed", + "long_name": "compressed( self )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "count", + "long_name": "count( self , axis = None )", + "filename": "ma.py", + "nloc": 29, + "complexity": 7, + "token_count": 173, + "parameters": [ + "self", + "axis" + ], + "start_line": 1188, + "end_line": 1216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dot", + "long_name": "dot( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1218, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "fill_value", + "long_name": "fill_value( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1222, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "filled", + "long_name": "filled( self , fill_value = None )", + "filename": "ma.py", + "nloc": 31, + "complexity": 9, + "token_count": 175, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1226, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 1 + }, + { + "name": "ids", + "long_name": "ids( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 1268, + "end_line": 1270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "iscontiguous", + "long_name": "iscontiguous( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 1272, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "itemsize", + "long_name": "itemsize( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 1276, + "end_line": 1278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1281, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "put", + "long_name": "put( self , values )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "values" + ], + "start_line": 1285, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "putmask", + "long_name": "putmask( self , values )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "values" + ], + "start_line": 1297, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "ravel", + "long_name": "ravel( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 1307, + "end_line": 1312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "raw_data", + "long_name": "raw_data( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1314, + "end_line": 1318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "raw_mask", + "long_name": "raw_mask( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1322, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "reshape", + "long_name": "reshape( self , * s )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self", + "s" + ], + "start_line": 1330, + "end_line": 1337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( self , v = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "v" + ], + "start_line": 1339, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_ndim", + "long_name": "_get_ndim( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1345, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_size", + "long_name": "_get_size( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1349, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_dtype", + "long_name": "_get_dtype( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1354, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "item", + "long_name": "item( self )", + "filename": "ma.py", + "nloc": 10, + "complexity": 4, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 1358, + "end_line": 1367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1369, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "tostring", + "long_name": "tostring( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1373, + "end_line": 1375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unmask", + "long_name": "unmask( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 3, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1377, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "unshare_mask", + "long_name": "unshare_mask( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 1385, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "isMaskedArray", + "long_name": "isMaskedArray( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "x" + ], + "start_line": 1409, + "end_line": 1411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , fill_value = 1 , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 140, + "parameters": [ + "a", + "b", + "fill_value", + "rtol", + "atol" + ], + "start_line": 1416, + "end_line": 1431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "allequal", + "long_name": "allequal( a , b , fill_value = 1 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 3, + "token_count": 125, + "parameters": [ + "a", + "b", + "fill_value" + ], + "start_line": 1433, + "end_line": 1451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "masked_values", + "long_name": "masked_values( data , value , rtol = 1 . e - 5 , atol = 1 . e - 8 , copy = 1 )", + "filename": "ma.py", + "nloc": 10, + "complexity": 2, + "token_count": 117, + "parameters": [ + "data", + "value", + "rtol", + "atol", + "copy" + ], + "start_line": 1453, + "end_line": 1472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "masked_object", + "long_name": "masked_object( data , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "data", + "value", + "copy" + ], + "start_line": 1474, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayrange", + "long_name": "arrayrange( start , stop = None , step = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 1480, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( s , t )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "s", + "t" + ], + "start_line": 1488, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "left_shift", + "long_name": "left_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1492, + "end_line": 1500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "right_shift", + "long_name": "right_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1502, + "end_line": 1510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 1512, + "end_line": 1520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 101, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 1522, + "end_line": 1537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "n" + ], + "start_line": 1539, + "end_line": 1542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 1544, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "zeros", + "long_name": "zeros( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1550, + "end_line": 1553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1555, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "count", + "long_name": "count( a , axis = None )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 1561, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( a , b , third = None )", + "filename": "ma.py", + "nloc": 18, + "complexity": 4, + "token_count": 154, + "parameters": [ + "a", + "b", + "third" + ], + "start_line": 1566, + "end_line": 1583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "masked_array", + "long_name": "masked_array( a , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "mask", + "fill_value" + ], + "start_line": 1585, + "end_line": 1589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "average", + "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", + "filename": "ma.py", + "nloc": 92, + "complexity": 22, + "token_count": 741, + "parameters": [ + "a", + "axis", + "weights", + "returned" + ], + "start_line": 1594, + "end_line": 1701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 107, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1703, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "choose.fmask", + "long_name": "choose.fmask( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "x" + ], + "start_line": 1723, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "choose.nmask", + "long_name": "choose.nmask( x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 3, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 1726, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "choose", + "long_name": "choose( indices , t )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 93, + "parameters": [ + "indices", + "t" + ], + "start_line": 1721, + "end_line": 1737, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "masked_where", + "long_name": "masked_where( condition , x , copy = 1 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "condition", + "x", + "copy" + ], + "start_line": 1739, + "end_line": 1745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "masked_greater", + "long_name": "masked_greater( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1747, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_greater_equal", + "long_name": "masked_greater_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1751, + "end_line": 1753, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less", + "long_name": "masked_less( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1755, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less_equal", + "long_name": "masked_less_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1759, + "end_line": 1761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_not_equal", + "long_name": "masked_not_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1763, + "end_line": 1768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "masked_equal", + "long_name": "masked_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1770, + "end_line": 1777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "masked_inside", + "long_name": "masked_inside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1779, + "end_line": 1790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "masked_outside", + "long_name": "masked_outside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1792, + "end_line": 1803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , * newshape )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 56, + "parameters": [ + "a", + "newshape" + ], + "start_line": 1805, + "end_line": 1812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( a )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "a" + ], + "start_line": 1814, + "end_line": 1821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "concatenate", + "long_name": "concatenate( arrays , axis = 0 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 5, + "token_count": 97, + "parameters": [ + "arrays", + "axis" + ], + "start_line": 1823, + "end_line": 1837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 1839, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1849, + "end_line": 1858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1860, + "end_line": 1868, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , indices , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 70, + "parameters": [ + "a", + "indices", + "values" + ], + "start_line": 1871, + "end_line": 1884, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 61, + "parameters": [ + "a", + "mask", + "values" + ], + "start_line": 1886, + "end_line": 1894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "innerproduct", + "long_name": "innerproduct( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 72, + "parameters": [ + "a", + "b" + ], + "start_line": 1896, + "end_line": 1906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "outerproduct", + "long_name": "outerproduct( a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 110, + "parameters": [ + "a", + "b" + ], + "start_line": 1908, + "end_line": 1920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dot", + "long_name": "dot( a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 36, + "parameters": [ + "a", + "b" + ], + "start_line": 1922, + "end_line": 1927, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , x , dimension = - 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 67, + "parameters": [ + "condition", + "x", + "dimension" + ], + "start_line": 1929, + "end_line": 1938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1942, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1948, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 1963, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1974, + "end_line": 1985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1991, + "end_line": 1995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1997, + "end_line": 2010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 2012, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 2023, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "sort", + "long_name": "sort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 3, + "token_count": 68, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2038, + "end_line": 2055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , k = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 73, + "parameters": [ + "a", + "k", + "axis1", + "axis2" + ], + "start_line": 2057, + "end_line": 2064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 2066, + "end_line": 2070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2072, + "end_line": 2079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2081, + "end_line": 2089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2091, + "end_line": 2105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( f , s )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "f", + "s" + ], + "start_line": 2107, + "end_line": 2109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( data , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 46, + "parameters": [ + "data", + "dtype" + ], + "start_line": 2111, + "end_line": 2117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_m", + "long_name": "_m( f )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "f" + ], + "start_line": 2123, + "end_line": 2124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( * args , ** kwds )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "args", + "kwds" + ], + "start_line": 2125, + "end_line": 2126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_choose", + "long_name": "_choose( self , * args )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 2135, + "end_line": 2136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_clip", + "long_name": "_clip( self , a_min , a_max )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "a_min", + "a_max" + ], + "start_line": 2140, + "end_line": 2142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_compress", + "long_name": "_compress( self , cond , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "cond", + "axis" + ], + "start_line": 2145, + "end_line": 2146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_max", + "long_name": "_max( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2161, + "end_line": 2165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_min", + "long_name": "_min( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2168, + "end_line": 2172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_ptp", + "long_name": "_ptp( a , axis = 0 )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 2181, + "end_line": 2182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_swapaxes", + "long_name": "_swapaxes( self , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "axis1", + "axis2" + ], + "start_line": 2195, + "end_line": 2197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_cumprod", + "long_name": "_cumprod( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2155, + "end_line": 2159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_var", + "long_name": "_var( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 86, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2227, + "end_line": 2234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_clip", + "long_name": "_clip( self , a_min , a_max )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "a_min", + "a_max" + ], + "start_line": 2140, + "end_line": 2144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_squeeze", + "long_name": "_squeeze( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 2207, + "end_line": 2213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_std", + "long_name": "_std( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2235, + "end_line": 2236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_cumsum", + "long_name": "_cumsum( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2162, + "end_line": 2166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 1737, + "complexity": 474, + "token_count": 12423, + "diff_parsed": { + "added": [ + " return MaskedArray(data = self.data.clip(asarray(a_min).data,", + " asarray(a_max).data),", + " mask = mask_or(self.mask,", + " mask_or(getmask(a_min),getmask(a_max))))", + "", + "def _cumprod(self, axis=0, dtype=None):", + " m = self.mask", + " if m is not nomask:", + " m = umath.logical_and.accumulate(self.mask, axis)", + " return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)", + "array.cumprod = _m(_cumprod)", + "", + "def _cumsum(self, axis=0, dtype=None):", + " m = self.mask", + " if m is not nomask:", + " m = umath.logical_and.accumulate(self.mask, axis)", + " return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)", + "array.cumsum = _m(_cumsum)", + "", + "", + "", + "def _squeeze(self):", + " try:", + " result = MaskedArray(data = self.data.squeeze(),", + " mask = self.mask.squeeze())", + " except AttributeError:", + " result = _wrapit(self, 'squeeze')", + " return result", + "array.squeeze = _m(_squeeze)", + "", + "", + "def _var(self,axis=0,dtype=None):", + " if axis is None:", + " return asarray(self.compressed()).var()", + " a = self.swapaxes(axis,0)", + " a = a - a.mean(axis=0)", + " a *= a", + " a /= (a.count(axis=0)-1)", + " return a.swapaxes(0,axis).sum(axis)", + "def _std(self,axis=0,dtype=None):", + " return (self.var(axis,dtype))**0.5", + "array.var = _m(_var)", + "array.std = _m(_std)", + "" + ], + "deleted": [ + " return MaskedArray(data = self.data.clip(a_min, a_max),", + " mask = self.mask)", + "array.cumprod = _m(not_implemented)", + "array.cumsum = _m(not_implemented)", + "", + "array.squeeze = _m(not_implemented)", + "array.std = _m(not_implemented)", + "array.var = _m(not_implemented)" + ] + } + }, + { + "old_path": "numpy/core/tests/test_ma.py", + "new_path": "numpy/core/tests/test_ma.py", + "filename": "test_ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -768,6 +768,33 @@ def test_swapaxes(self):\n self.assertEqual(mXXswapped.shape,(2,2,3,3))\n \n \n+ def test_cumprod(self):\n+ (x,X,XX,m,mx,mX,mXX,) = self.d\n+ mXcp = mX.cumprod(0)\n+ self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(0)))\n+ mXcp = mX.cumprod(1)\n+ self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(1)))\n+ \n+ def test_cumsum(self):\n+ (x,X,XX,m,mx,mX,mXX,) = self.d\n+ mXcp = mX.cumsum(0)\n+ self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(0)))\n+ mXcp = mX.cumsum(1)\n+ self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(1)))\n+ \n+ def test_varstd(self):\n+ (x,X,XX,m,mx,mX,mXX,) = self.d\n+ self.failUnless(eq(mX.var(axis=None),mX.compressed().var()))\n+ self.failUnless(eq(mX.std(axis=None),mX.compressed().std()))\n+ self.failUnless(eq(mXX.var(axis=3).shape,XX.var(axis=3).shape))\n+ self.failUnless(eq(mX.var().shape,X.var().shape))\n+ (mXvar0,mXvar1) = (mX.var(axis=0), mX.var(axis=1))\n+ for k in range(6):\n+ self.failUnless(eq(mXvar1[k],mX[k].compressed().var()))\n+ self.failUnless(eq(mXvar0[k],mX[:,k].compressed().var()))\n+ self.failUnless(eq(numpy.sqrt(mXvar0[k]),\n+ mX[:,k].compressed().std()))\n+ \n \n def eqmask(m1, m2):\n if m1 is nomask:\n", + "added_lines": 27, + "deleted_lines": 0, + "source_code": "import numpy\nimport types, time\nfrom numpy.core.ma import *\nfrom numpy.core.numerictypes import float32\nfrom numpy.testing import ScipyTestCase, ScipyTest\npi = numpy.pi\ndef eq(v,w, msg=''):\n result = allclose(v,w)\n if not result:\n print \"\"\"Not eq:%s\n%s\n----\n%s\"\"\"% (msg, str(v), str(w))\n return result\n\nclass test_ma(ScipyTestCase):\n def __init__(self, *args, **kwds):\n ScipyTestCase.__init__(self, *args, **kwds)\n self.setUp()\n\n def setUp (self):\n x=numpy.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])\n y=numpy.array([5.,0.,3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])\n a10 = 10.\n m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]\n m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 ,0, 1]\n xm = array(x, mask=m1)\n ym = array(y, mask=m2)\n z = numpy.array([-.5, 0., .5, .8])\n zm = array(z, mask=[0,1,0,0])\n xf = numpy.where(m1, 1.e+20, x)\n s = x.shape\n xm.set_fill_value(1.e+20)\n self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s)\n\n def check_testBasic1d(self):\n \"Test of basic array creation and properties in 1 dimension.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual(xm.dtype, x.dtype)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual(count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n\n def check_testBasic2d(self):\n \"Test of basic array creation and properties in 2 dimensions.\"\n for s in [(4,3), (6,2)]:\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n x.shape = s\n y.shape = s\n xm.shape = s\n ym.shape = s\n xf.shape = s\n\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual( count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n self.setUp()\n\n def check_testArithmetic (self):\n \"Test of basic arithmetic.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n a2d = array([[1,2],[0,4]])\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n self.failUnless(eq (a2d * a2d, a2d * a2dm))\n self.failUnless(eq (a2d + a2d, a2d + a2dm))\n self.failUnless(eq (a2d - a2d, a2d - a2dm))\n for s in [(12,), (4,3), (2,6)]:\n x = x.reshape(s)\n y = y.reshape(s)\n xm = xm.reshape(s)\n ym = ym.reshape(s)\n xf = xf.reshape(s)\n self.failUnless(eq(-x, -xm))\n self.failUnless(eq(x + y, xm + ym))\n self.failUnless(eq(x - y, xm - ym))\n self.failUnless(eq(x * y, xm * ym))\n self.failUnless(eq(x / y, xm / ym))\n self.failUnless(eq(a10 + y, a10 + ym))\n self.failUnless(eq(a10 - y, a10 - ym))\n self.failUnless(eq(a10 * y, a10 * ym))\n self.failUnless(eq(a10 / y, a10 / ym))\n self.failUnless(eq(x + a10, xm + a10))\n self.failUnless(eq(x - a10, xm - a10))\n self.failUnless(eq(x * a10, xm * a10))\n self.failUnless(eq(x / a10, xm / a10))\n self.failUnless(eq(x**2, xm**2))\n self.failUnless(eq(abs(x)**2.5, abs(xm) **2.5))\n self.failUnless(eq(x**y, xm**ym))\n self.failUnless(eq(numpy.add(x,y), add(xm, ym)))\n self.failUnless(eq(numpy.subtract(x,y), subtract(xm, ym)))\n self.failUnless(eq(numpy.multiply(x,y), multiply(xm, ym)))\n self.failUnless(eq(numpy.divide(x,y), divide(xm, ym)))\n\n\n def check_testMixedArithmetic(self):\n na = numpy.array([1])\n ma = array([1])\n self.failUnless(isinstance(na + ma, MaskedArray))\n self.failUnless(isinstance(ma + na, MaskedArray))\n\n def check_testUfuncs1 (self):\n \"Test various functions such as sin, cos.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(numpy.cos(x), cos(xm)))\n self.failUnless (eq(numpy.cosh(x), cosh(xm)))\n self.failUnless (eq(numpy.sin(x), sin(xm)))\n self.failUnless (eq(numpy.sinh(x), sinh(xm)))\n self.failUnless (eq(numpy.tan(x), tan(xm)))\n self.failUnless (eq(numpy.tanh(x), tanh(xm)))\n self.failUnless (eq(numpy.sqrt(abs(x)), sqrt(xm)))\n self.failUnless (eq(numpy.log(abs(x)), log(xm)))\n self.failUnless (eq(numpy.log10(abs(x)), log10(xm)))\n self.failUnless (eq(numpy.exp(x), exp(xm)))\n self.failUnless (eq(numpy.arcsin(z), arcsin(zm)))\n self.failUnless (eq(numpy.arccos(z), arccos(zm)))\n self.failUnless (eq(numpy.arctan(z), arctan(zm)))\n self.failUnless (eq(numpy.arctan2(x, y), arctan2(xm, ym)))\n self.failUnless (eq(numpy.absolute(x), absolute(xm)))\n self.failUnless (eq(numpy.equal(x,y), equal(xm, ym)))\n self.failUnless (eq(numpy.not_equal(x,y), not_equal(xm, ym)))\n self.failUnless (eq(numpy.less(x,y), less(xm, ym)))\n self.failUnless (eq(numpy.greater(x,y), greater(xm, ym)))\n self.failUnless (eq(numpy.less_equal(x,y), less_equal(xm, ym)))\n self.failUnless (eq(numpy.greater_equal(x,y), greater_equal(xm, ym)))\n self.failUnless (eq(numpy.conjugate(x), conjugate(xm)))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((xm,ym))))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((x,y))))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((xm,y))))\n self.failUnless (eq(numpy.concatenate((x,y,x)), concatenate((x,ym,x))))\n\n def check_xtestCount (self):\n \"Test count\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless( isinstance(count(ott), types.IntType))\n self.assertEqual(3, count(ott))\n self.assertEqual(1, count(1))\n self.failUnless (eq(0, array(1,mask=[1])))\n ott=ott.reshape((2,2))\n assert isMaskedArray(count(ott,0))\n assert isinstance(count(ott), types.IntType)\n self.failUnless (eq(3, count(ott)))\n assert getmask(count(ott,0)) is nomask\n self.failUnless (eq([1,2],count(ott,0)))\n\n def check_testMinMax (self):\n \"Test minimum and maximum.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n xr = numpy.ravel(x) #max doesn't work if shaped\n xmr = ravel(xm)\n self.failUnless (eq(max(xr), maximum(xmr))) #true because of careful selection of data\n self.failUnless (eq(min(xr), minimum(xmr))) #true because of careful selection of data\n\n def check_testAddSumProd (self):\n \"Test add, sum, product.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(numpy.add.reduce(x), add.reduce(x)))\n self.failUnless (eq(numpy.add.accumulate(x), add.accumulate(x)))\n self.failUnless (eq(4, sum(array(4))))\n self.failUnless (eq(4, sum(array(4), axis=0)))\n self.failUnless (eq(numpy.sum(x), sum(x)))\n self.failUnless (eq(numpy.sum(filled(xm,0)), sum(xm)))\n self.failUnless (eq(numpy.sum(x,0), sum(x,0)))\n self.failUnless (eq(numpy.product(x), product(x)))\n self.failUnless (eq(numpy.product(x,0), product(x,0)))\n self.failUnless (eq(numpy.product(filled(xm,1)), product(xm)))\n if len(s) > 1:\n self.failUnless (eq(numpy.concatenate((x,y),1), concatenate((xm,ym),1)))\n self.failUnless (eq(numpy.add.reduce(x,1), add.reduce(x,1)))\n self.failUnless (eq(numpy.sum(x,1), sum(x,1)))\n self.failUnless (eq(numpy.product(x,1), product(x,1)))\n\n\n def check_testCI(self):\n \"Test of conversions and indexing\"\n x1 = numpy.array([1,2,4,3])\n x2 = array(x1, mask = [1,0,0,0])\n x3 = array(x1, mask = [0,1,0,1])\n x4 = array(x1)\n # test conversion to strings\n junk, garbage = str(x2), repr(x2)\n assert eq(numpy.sort(x1),sort(x2, fill_value=0))\n # tests of indexing\n assert type(x2[1]) is type(x1[1])\n assert x1[1] == x2[1]\n assert x2[0] is masked\n assert eq(x1[2],x2[2])\n assert eq(x1[2:5],x2[2:5])\n assert eq(x1[:],x2[:])\n assert eq(x1[1:], x3[1:])\n x1[2]=9\n x2[2]=9\n assert eq(x1,x2)\n x1[1:3] = 99\n x2[1:3] = 99\n assert eq(x1,x2)\n x2[1] = masked\n assert eq(x1,x2)\n x2[1:3]=masked\n assert eq(x1,x2)\n x2[:] = x1\n x2[1] = masked\n assert allequal(getmask(x2),array([0,1,0,0]))\n x3[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x3), array([0,1,1,0]))\n x4[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x4), array([0,1,1,0]))\n assert allequal(x4, array([1,2,3,4]))\n x1 = numpy.arange(5)*1.0\n x2 = masked_values(x1, 3.0)\n assert eq(x1,x2)\n assert allequal(array([0,0,0,1,0],MaskType), x2.mask)\n assert eq(3.0, x2.fill_value())\n x1 = array([1,'hello',2,3],object)\n x2 = numpy.array([1,'hello',2,3],object)\n s1 = x1[1]\n s2 = x2[1]\n self.assertEqual(type(s2), str)\n self.assertEqual(type(s1), str)\n self.assertEqual(s1, s2)\n assert x1[1:1].shape == (0,)\n\n def check_testCopySize(self):\n \"Tests of some subtle points of copying and sizing.\"\n n = [0,0,1,0,0]\n m = make_mask(n)\n m2 = make_mask(m)\n self.failUnless(m is m2)\n m3 = make_mask(m, copy=1)\n self.failUnless(m is not m3)\n\n x1 = numpy.arange(5)\n y1 = array(x1, mask=m)\n self.failUnless( y1.raw_data() is not x1)\n self.failUnless( allequal(x1,y1.raw_data()))\n self.failUnless( y1.mask is m)\n\n y1a = array(y1, copy=0)\n self.failUnless( y1a.raw_data() is y1.raw_data())\n self.failUnless( y1a.mask is y1.mask)\n\n y2 = array(x1, mask=m, copy=0)\n self.failUnless( y2.raw_data() is x1)\n self.failUnless( y2.mask is m)\n self.failUnless( y2[2] is masked)\n y2[2]=9\n self.failUnless( y2[2] is not masked)\n self.failUnless( y2.mask is not m)\n self.failUnless( allequal(y2.mask, 0))\n\n y3 = array(x1*1.0, mask=m)\n self.failUnless(filled(y3).dtype is (x1*1.0).dtype)\n\n x4 = arange(4)\n x4[2] = masked\n y4 = resize(x4, (8,))\n self.failUnless( eq(concatenate([x4,x4]), y4))\n self.failUnless( eq(getmask(y4),[0,0,1,0,0,0,1,0]))\n y5 = repeat(x4, (2,2,2,2))\n self.failUnless( eq(y5, [0,0,1,1,2,2,3,3]))\n y6 = repeat(x4, 2)\n self.failUnless( eq(y5, y6))\n\n def check_testPut(self):\n \"Test of put\"\n d = arange(5)\n n = [0,0,0,1,1]\n m = make_mask(n)\n x = array(d, mask = m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n x[[1,4]] = [10,40]\n self.failUnless( x.mask is not m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is not masked)\n self.failUnless( eq(x, [0,10,2,-1,40]))\n\n x = array(d, mask = m)\n x.put([-1,100,200])\n self.failUnless( eq(x, [-1,100,200,0,0]))\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n\n x = array(d, mask = m)\n x.putmask([30,40])\n self.failUnless( eq(x, [0,1,2,30,40]))\n self.failUnless( x.mask is nomask)\n\n x = array(d, mask = m)\n y = x.compressed()\n z = array(x, mask = m)\n z.put(y)\n assert eq (x, z)\n\n def check_testMaPut(self):\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]\n i = numpy.nonzero(m)\n putmask(xm, m, z)\n assert take(xm, i) == z\n put(ym, i, zm)\n assert take(ym, i) == zm\n\n def check_testOddFeatures(self):\n \"Test of other odd features\"\n x = arange(20); x=x.reshape(4,5)\n x.flat[5] = 12\n assert x[1,0] == 12\n z = x + 10j * x\n assert eq(z.real, x)\n assert eq(z.imag, 10*x)\n assert eq((z*conjugate(z)).real, 101*x*x)\n z.imag[...] = 0.0\n\n x = arange(10)\n x[3] = masked\n assert str(x[3]) == str(masked)\n c = x >= 8\n assert count(where(c,masked,masked)) == 0\n assert shape(where(c,masked,masked)) == c.shape\n z = where(c , x, masked)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is masked\n assert z[7] is masked\n assert z[8] is not masked\n assert z[9] is not masked\n assert eq(x,z)\n z = where(c , masked, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n z = masked_where(c, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n assert eq(x,z)\n x = array([1.,2.,3.,4.,5.])\n c = array([1,1,1,0,0])\n x[2] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n c[0] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n assert eq(masked_where(greater(x, 2), x), masked_greater(x,2))\n assert eq(masked_where(greater_equal(x, 2), x), masked_greater_equal(x,2))\n assert eq(masked_where(less(x, 2), x), masked_less(x,2))\n assert eq(masked_where(less_equal(x, 2), x), masked_less_equal(x,2))\n assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x,2))\n assert eq(masked_where(equal(x, 2), x), masked_equal(x,2))\n assert eq(masked_where(not_equal(x,2), x), masked_not_equal(x,2))\n assert eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4])\n assert eq(masked_outside(range(5), 1, 3),[199,1,2,3,199])\n assert eq(masked_inside(array(range(5), mask=[1,0,0,0,0]), 1, 3).mask, [1,1,1,1,0])\n assert eq(masked_outside(array(range(5), mask=[0,1,0,0,0]), 1, 3).mask, [1,1,0,0,1])\n assert eq(masked_equal(array(range(5), mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,0])\n assert eq(masked_not_equal(array([2,2,1,2,1], mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,1])\n assert eq(masked_where([1,1,0,0,0], [1,2,3,4,5]), [99,99,3,4,5])\n atest = ones((10,10,10), dtype=float32)\n btest = zeros(atest.shape, MaskType)\n ctest = masked_where(btest,atest)\n assert eq(atest,ctest)\n z = choose(c, (-x, x))\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n x = arange(6)\n x[5] = masked\n y = arange(6)*10\n y[2]= masked\n c = array([1,1,1,0,0,0], mask=[1,0,0,0,0,0])\n cm = c.filled(1)\n z = where(c,x,y)\n zm = where(cm,x,y)\n assert eq(z, zm)\n assert getmask(zm) is nomask\n assert eq(zm, [0,1,2,30,40,50])\n z = where(c, masked, 1)\n assert eq(z, [99,99,99,1,1,1])\n z = where(c, 1, masked)\n assert eq(z, [99, 1, 1, 99, 99, 99])\n\n def check_testMinMax(self):\n \"Test of minumum, maximum.\"\n assert eq(minimum([1,2,3],[4,0,9]), [1,0,3])\n assert eq(maximum([1,2,3],[4,0,9]), [4,2,9])\n x = arange(5)\n y = arange(5) - 2\n x[3] = masked\n y[0] = masked\n assert eq(minimum(x,y), where(less(x,y), x, y))\n assert eq(maximum(x,y), where(greater(x,y), x, y))\n assert minimum(x) == 0\n assert maximum(x) == 4\n\n def check_testTakeTransposeInnerOuter(self):\n \"Test of take, transpose, inner, outer products\"\n x = arange(24)\n y = numpy.arange(24)\n x[5:6] = masked\n x=x.reshape(2,3,4)\n y=y.reshape(2,3,4)\n assert eq(numpy.transpose(y,(2,0,1)), transpose(x,(2,0,1)))\n assert eq(numpy.take(y, (2,0,1), 1), take(x, (2,0,1), 1))\n assert eq(numpy.innerproduct(filled(x,0),filled(y,0)),\n innerproduct(x, y))\n assert eq(numpy.outerproduct(filled(x,0),filled(y,0)),\n outerproduct(x, y))\n y = array(['abc', 1, 'def', 2, 3], object)\n y[2] = masked\n t = take(y,[0,3,4])\n assert t[0] == 'abc'\n assert t[1] == 2\n assert t[2] == 3\n\n def check_testInplace(self):\n \"\"\"Test of inplace operations and rich comparisons\"\"\"\n y = arange(10)\n\n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x += 1\n assert eq(x, y+1)\n xm += 1\n assert eq(x, y+1)\n\n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x -= 1\n assert eq(x, y-1)\n xm -= 1\n assert eq(xm, y-1)\n\n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x *= 2.0\n assert eq(x, y*2)\n xm *= 2.0\n assert eq(xm, y*2)\n\n x = arange(10)*2\n xm = arange(10)\n xm[2] = masked\n x /= 2\n assert eq(x, y)\n xm /= 2\n assert eq(x, y)\n\n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x /= 2.0\n assert eq(x, y/2.0)\n xm /= arange(10)\n assert eq(xm, ones((10,)))\n\n x = arange(10).astype(float32)\n xm = arange(10)\n xm[2] = masked\n id1 = id(x.raw_data())\n x += 1.\n assert id1 == id(x.raw_data())\n assert eq(x, y+1.)\n\n def check_testPickle(self):\n \"Test of pickling\"\n import pickle\n x = arange(12)\n x[4:10:2] = masked\n x = x.reshape(4,3)\n s = pickle.dumps(x)\n y = pickle.loads(s)\n assert eq(x,y)\n\n def check_testMasked(self):\n \"Test of masked element\"\n xx=arange(6)\n xx[1] = masked\n self.failUnless(str(masked) == '--')\n self.failUnless(xx[1] is masked)\n self.failUnlessEqual(filled(xx[1], 0), 0)\n # don't know why these should raise an exception...\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, masked)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, 2)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)\n\n def check_testAverage1(self):\n \"Test of average.\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless(eq(2.0, average(ott)))\n self.failUnless(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))\n result, wts = average(ott, weights=[1.,1.,2.,1.], returned=1)\n self.failUnless(eq(2.0, result))\n self.failUnless(wts == 4.0)\n ott[:] = masked\n self.failUnless(average(ott) is masked)\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n ott=ott.reshape(2,2)\n ott[:,1] = masked\n self.failUnless(eq(average(ott), [2.0, 0.0]))\n self.failUnless(average(ott,axis=1)[0] is masked)\n self.failUnless(eq([2.,0.], average(ott)))\n result, wts = average(ott, returned=1)\n self.failUnless(eq(wts, [1., 0.]))\n\n def check_testAverage2(self):\n \"More tests of average.\"\n w1 = [0,1,1,1,1,0]\n w2 = [[0,1,1,1,1,0],[1,0,0,0,0,1]]\n x=arange(6)\n self.failUnless(allclose(average(x), 2.5))\n self.failUnless(allclose(average(x, weights=w1), 2.5))\n y=array([arange(6), 2.0*arange(6)])\n self.failUnless(allclose(average(y, None), numpy.add.reduce(numpy.arange(6))*3./12.))\n self.failUnless(allclose(average(y, axis=0), numpy.arange(6) * 3./2.))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n self.failUnless(allclose(average(y, None, weights=w2), 20./6.))\n self.failUnless(allclose(average(y, axis=0, weights=w2), [0.,1.,2.,3.,4.,10.]))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n m1 = zeros(6)\n m2 = [0,0,1,1,0,0]\n m3 = [[0,0,1,1,0,0],[0,1,1,1,1,0]]\n m4 = ones(6)\n m5 = [0, 1, 1, 1, 1, 1]\n self.failUnless(allclose(average(masked_array(x, m1)), 2.5))\n self.failUnless(allclose(average(masked_array(x, m2)), 2.5))\n self.failUnless(average(masked_array(x, m4)) is masked)\n self.assertEqual(average(masked_array(x, m5)), 0.0)\n self.assertEqual(count(average(masked_array(x, m4))), 0)\n z = masked_array(y, m3)\n self.failUnless(allclose(average(z, None), 20./6.))\n self.failUnless(allclose(average(z, axis=0), [0.,1.,99.,99.,4.0, 7.5]))\n self.failUnless(allclose(average(z, axis=1), [2.5, 5.0]))\n self.failUnless(allclose( average(z,weights=w2), [0.,1., 99., 99., 4.0, 10.0]))\n\n a = arange(6)\n b = arange(6) * 3\n r1, w1 = average([[a,b],[b,a]], axis=1, returned=1)\n self.assertEqual(shape(r1) , shape(w1))\n self.assertEqual(r1.shape , w1.shape)\n r2, w2 = average(ones((2,2,3)), axis=0, weights=[3,1], returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), weights=ones((2,2,3)), returned=1)\n self.failUnless(shape(w2) == shape(r2))\n a2d = array([[1,2],[0,4]], float)\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n a2da = average(a2d)\n self.failUnless(eq (a2da, [0.5, 3.0]))\n a2dma = average(a2dm)\n self.failUnless(eq( a2dma, [1.0, 3.0]))\n a2dma = average(a2dm, axis=None)\n self.failUnless(eq(a2dma, 7./3.))\n a2dma = average(a2dm, axis=1)\n self.failUnless(eq(a2dma, [1.5, 4.0]))\n\n def check_testToPython(self):\n self.assertEqual(1, int(array(1)))\n self.assertEqual(1.0, float(array(1)))\n self.assertEqual(1, int(array([[[1]]])))\n self.assertEqual(1.0, float(array([[1]])))\n self.failUnlessRaises(ValueError, float, array([1,1]))\n self.failUnlessRaises(MAError, float, array([1],mask=[1]))\n self.failUnless(bool(array([0,1])))\n self.failUnless(bool(array([0,0],mask=[0,1])))\n self.failIf(bool(array([0,0])))\n self.failIf(bool(array([0,0],mask=[0,0])))\n\n def check_testScalarArithmetic(self):\n xm = array(0, mask=1)\n self.failUnless((1/array(0)).mask)\n self.failUnless((1 + xm).mask)\n self.failUnless((-xm).mask)\n self.failUnless((-xm).mask)\n self.failUnless(maximum(xm, xm).mask)\n self.failUnless(minimum(xm, xm).mask)\n self.failUnless(xm.filled().dtype is xm.data.dtype)\n x = array(0, mask=0)\n self.failUnless(x.filled() is x.data)\n self.failUnlessEqual(str(xm), str(masked_print_option))\n\n def check_testArrayMethods(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnless(eq(a.any(), a.data.any()))\n self.failUnless(eq(a.all(), a.data.all()))\n self.failUnless(eq(a.argmax(), a.data.argmax()))\n self.failUnless(eq(a.argmin(), a.data.argmin()))\n self.failUnless(eq(a.choose(0,1,2,3,4), a.data.choose(0,1,2,3,4)))\n self.failUnless(eq(a.compress([1,0,1]), a.data.compress([1,0,1])))\n self.failUnless(eq(a.conj(), a.data.conj()))\n self.failUnless(eq(a.conjugate(), a.data.conjugate()))\n m = array([[1,2],[3,4]])\n self.failUnless(eq(m.diagonal(), m.data.diagonal()))\n self.failUnless(eq(a.sum(), a.data.sum()))\n self.failUnless(eq(a.take([1,2]), a.data.take([1,2])))\n self.failUnless(eq(m.transpose(), m.data.transpose()))\n\n def check_testArrayAttributes(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnlessEqual(a.ndim, 1)\n\n def check_testAPI(self):\n self.failIf([m for m in dir(numpy.ndarray)\n if m not in dir(array) and not m.startswith('_')])\n\n def check_testSingleElementSubscript(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnlessEqual(a[0].shape, ())\n self.failUnlessEqual(b[0].shape, ())\n self.failUnlessEqual(b[1].shape, ())\n\nclass test_ufuncs(ScipyTestCase):\n def setUp(self):\n self.d = (array([1.0, 0, -1, pi/2]*2, mask=[0,1]+[0]*6),\n array([1.0, 0, -1, pi/2]*2, mask=[1,0]+[0]*6),)\n\n\n def check_testUfuncRegression(self):\n for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate',\n 'sin', 'cos', 'tan',\n 'arcsin', 'arccos', 'arctan',\n 'sinh', 'cosh', 'tanh',\n 'arcsinh',\n 'arccosh',\n 'arctanh',\n 'absolute', 'fabs', 'negative',\n # 'nonzero', 'around',\n 'floor', 'ceil',\n # 'sometrue', 'alltrue',\n 'logical_not',\n 'add', 'subtract', 'multiply',\n 'divide', 'true_divide', 'floor_divide',\n 'remainder', 'fmod', 'hypot', 'arctan2',\n 'equal', 'not_equal', 'less_equal', 'greater_equal',\n 'less', 'greater',\n 'logical_and', 'logical_or', 'logical_xor',\n ]:\n try:\n uf = getattr(umath, f)\n except AttributeError:\n uf = getattr(oldnumeric, f)\n mf = getattr(numpy.ma, f)\n args = self.d[:uf.nin]\n ur = uf(*args)\n mr = mf(*args)\n self.failUnless(eq(ur.filled(0), mr.filled(0), f))\n self.failUnless(eqmask(ur.mask, mr.mask))\n\n def test_reduce(self):\n a = self.d[0]\n self.failIf(alltrue(a))\n self.failUnless(sometrue(a))\n self.failUnlessEqual(sum(a[:3]), 0)\n self.failUnlessEqual(product(a), 0)\n\n def test_minmax(self):\n a = arange(1,13).reshape(3,4)\n amask = masked_where(a < 5,a)\n self.failUnlessEqual(amask.max(), a.max())\n self.failUnlessEqual(amask.min(), 5)\n self.failUnless((amask.max(0) == a.max(0)).all())\n self.failUnless((amask.min(0) == [5,6,7,8]).all())\n self.failUnless(amask.max(1)[0].mask)\n self.failUnless(amask.min(1)[0].mask)\n\n def test_nonzero(self):\n for t in \"?bhilqpBHILQPfdgFDGO\":\n x = array([1,0,2,0], mask=[0,0,1,1])\n self.failUnless(eq(nonzero(x), [0]))\n\n\nclass test_array_methods(ScipyTestCase):\n \n def setUp(self):\n x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928, \n 8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732, \n 3.012, 6.022, 5.095, 3.116, 5.238, 3.957, \n 6.04 , 9.63 , 7.712, 3.382, 4.489, 6.479,\n 7.189, 9.645, 5.395, 4.961, 9.894, 2.893, \n 7.357, 9.828, 6.272, 3.758, 6.693, 0.993])\n X = x.reshape(6,6)\n XX = x.reshape(3,2,2,3)\n \n m = numpy.array([0, 1, 0, 1, 0, 0, \n 1, 0, 1, 1, 0, 1, \n 0, 0, 0, 1, 0, 1, \n 0, 0, 0, 1, 1, 1, \n 1, 0, 0, 1, 0, 0, \n 0, 0, 1, 0, 1, 0])\n mx = array(data=x,mask=m)\n mX = array(data=X,mask=m.reshape(X.shape))\n mXX = array(data=XX,mask=m.reshape(XX.shape))\n \n m2 = numpy.array([1, 1, 0, 1, 0, 0, \n 1, 1, 1, 1, 0, 1, \n 0, 0, 1, 1, 0, 1, \n 0, 0, 0, 1, 1, 1, \n 1, 0, 0, 1, 1, 0, \n 0, 0, 1, 0, 1, 1])\n m2x = array(data=x,mask=m2)\n m2X = array(data=X,mask=m2.reshape(X.shape))\n m2XX = array(data=XX,mask=m2.reshape(XX.shape))\n self.d = (x,X,XX,m,mx,mX,mXX)\n\n #------------------------------------------------------\n def test_trace(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXdiag = mX.diagonal()\n self.assertEqual(mX.trace(), mX.diagonal().compressed().sum())\n self.failUnless(eq(mX.trace(),\n X.trace() - sum(mXdiag.mask*X.diagonal())))\n\n def test_clip(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n clipped = mx.clip(2,8)\n self.failUnless(eq(clipped.mask,mx.mask))\n self.failUnless(eq(clipped.data,x.clip(2,8)))\n self.failUnless(eq(clipped.data,mx.data.clip(2,8)))\n\n def test_ptp(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n (n,m) = X.shape\n self.assertEqual(mx.ptp(),mx.compressed().ptp())\n rows = numpy.zeros(n,numpy.float_)\n cols = numpy.zeros(m,numpy.float_)\n for k in range(m):\n cols[k] = mX[:,k].compressed().ptp()\n for k in range(n):\n rows[k] = mX[k].compressed().ptp()\n self.failUnless(eq(mX.ptp(0),cols))\n self.failUnless(eq(mX.ptp(1),rows))\n\n def test_swapaxes(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXswapped = mX.swapaxes(0,1)\n self.failUnless(eq(mXswapped[-1],mX[:,-1]))\n mXXswapped = mXX.swapaxes(0,2)\n self.assertEqual(mXXswapped.shape,(2,2,3,3))\n\n\n def test_cumprod(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXcp = mX.cumprod(0)\n self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(0)))\n mXcp = mX.cumprod(1)\n self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(1)))\n \n def test_cumsum(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXcp = mX.cumsum(0)\n self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(0)))\n mXcp = mX.cumsum(1)\n self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(1)))\n \n def test_varstd(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n self.failUnless(eq(mX.var(axis=None),mX.compressed().var()))\n self.failUnless(eq(mX.std(axis=None),mX.compressed().std()))\n self.failUnless(eq(mXX.var(axis=3).shape,XX.var(axis=3).shape))\n self.failUnless(eq(mX.var().shape,X.var().shape))\n (mXvar0,mXvar1) = (mX.var(axis=0), mX.var(axis=1))\n for k in range(6):\n self.failUnless(eq(mXvar1[k],mX[k].compressed().var()))\n self.failUnless(eq(mXvar0[k],mX[:,k].compressed().var()))\n self.failUnless(eq(numpy.sqrt(mXvar0[k]),\n mX[:,k].compressed().std()))\n \n\ndef eqmask(m1, m2):\n if m1 is nomask:\n return m2 is nomask\n if m2 is nomask:\n return m1 is nomask\n return (m1 == m2).all()\n\ndef timingTest():\n for f in [testf, testinplace]:\n for n in [1000,10000,50000]:\n t = testta(n, f)\n t1 = testtb(n, f)\n t2 = testtc(n, f)\n print f.test_name\n print \"\"\"\\\nn = %7d\nnumpy time (ms) %6.1f\nMA maskless ratio %6.1f\nMA masked ratio %6.1f\n\"\"\" % (n, t*1000.0, t1/t, t2/t)\n\ndef testta(n, f):\n x=numpy.arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtb(n, f):\n x=arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtc(n, f):\n x=arange(n) + 1.0\n x[0] = masked\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testf(x):\n for i in range(25):\n y = x **2 + 2.0 * x - 1.0\n w = x **2 + 1.0\n z = (y / w) ** 2\n return z\ntestf.test_name = 'Simple arithmetic'\n\ndef testinplace(x):\n for i in range(25):\n y = x**2\n y += 2.0*x\n y -= 1.0\n y /= x\n return y\ntestinplace.test_name = 'Inplace operations'\n\nif __name__ == \"__main__\":\n ScipyTest('numpy.core.ma').run()\n #timingTest()\n", + "source_code_before": "import numpy\nimport types, time\nfrom numpy.core.ma import *\nfrom numpy.core.numerictypes import float32\nfrom numpy.testing import ScipyTestCase, ScipyTest\npi = numpy.pi\ndef eq(v,w, msg=''):\n result = allclose(v,w)\n if not result:\n print \"\"\"Not eq:%s\n%s\n----\n%s\"\"\"% (msg, str(v), str(w))\n return result\n\nclass test_ma(ScipyTestCase):\n def __init__(self, *args, **kwds):\n ScipyTestCase.__init__(self, *args, **kwds)\n self.setUp()\n\n def setUp (self):\n x=numpy.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])\n y=numpy.array([5.,0.,3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])\n a10 = 10.\n m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]\n m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 ,0, 1]\n xm = array(x, mask=m1)\n ym = array(y, mask=m2)\n z = numpy.array([-.5, 0., .5, .8])\n zm = array(z, mask=[0,1,0,0])\n xf = numpy.where(m1, 1.e+20, x)\n s = x.shape\n xm.set_fill_value(1.e+20)\n self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s)\n\n def check_testBasic1d(self):\n \"Test of basic array creation and properties in 1 dimension.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual(xm.dtype, x.dtype)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual(count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n\n def check_testBasic2d(self):\n \"Test of basic array creation and properties in 2 dimensions.\"\n for s in [(4,3), (6,2)]:\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n x.shape = s\n y.shape = s\n xm.shape = s\n ym.shape = s\n xf.shape = s\n\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual( count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n self.setUp()\n\n def check_testArithmetic (self):\n \"Test of basic arithmetic.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n a2d = array([[1,2],[0,4]])\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n self.failUnless(eq (a2d * a2d, a2d * a2dm))\n self.failUnless(eq (a2d + a2d, a2d + a2dm))\n self.failUnless(eq (a2d - a2d, a2d - a2dm))\n for s in [(12,), (4,3), (2,6)]:\n x = x.reshape(s)\n y = y.reshape(s)\n xm = xm.reshape(s)\n ym = ym.reshape(s)\n xf = xf.reshape(s)\n self.failUnless(eq(-x, -xm))\n self.failUnless(eq(x + y, xm + ym))\n self.failUnless(eq(x - y, xm - ym))\n self.failUnless(eq(x * y, xm * ym))\n self.failUnless(eq(x / y, xm / ym))\n self.failUnless(eq(a10 + y, a10 + ym))\n self.failUnless(eq(a10 - y, a10 - ym))\n self.failUnless(eq(a10 * y, a10 * ym))\n self.failUnless(eq(a10 / y, a10 / ym))\n self.failUnless(eq(x + a10, xm + a10))\n self.failUnless(eq(x - a10, xm - a10))\n self.failUnless(eq(x * a10, xm * a10))\n self.failUnless(eq(x / a10, xm / a10))\n self.failUnless(eq(x**2, xm**2))\n self.failUnless(eq(abs(x)**2.5, abs(xm) **2.5))\n self.failUnless(eq(x**y, xm**ym))\n self.failUnless(eq(numpy.add(x,y), add(xm, ym)))\n self.failUnless(eq(numpy.subtract(x,y), subtract(xm, ym)))\n self.failUnless(eq(numpy.multiply(x,y), multiply(xm, ym)))\n self.failUnless(eq(numpy.divide(x,y), divide(xm, ym)))\n\n\n def check_testMixedArithmetic(self):\n na = numpy.array([1])\n ma = array([1])\n self.failUnless(isinstance(na + ma, MaskedArray))\n self.failUnless(isinstance(ma + na, MaskedArray))\n\n def check_testUfuncs1 (self):\n \"Test various functions such as sin, cos.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(numpy.cos(x), cos(xm)))\n self.failUnless (eq(numpy.cosh(x), cosh(xm)))\n self.failUnless (eq(numpy.sin(x), sin(xm)))\n self.failUnless (eq(numpy.sinh(x), sinh(xm)))\n self.failUnless (eq(numpy.tan(x), tan(xm)))\n self.failUnless (eq(numpy.tanh(x), tanh(xm)))\n self.failUnless (eq(numpy.sqrt(abs(x)), sqrt(xm)))\n self.failUnless (eq(numpy.log(abs(x)), log(xm)))\n self.failUnless (eq(numpy.log10(abs(x)), log10(xm)))\n self.failUnless (eq(numpy.exp(x), exp(xm)))\n self.failUnless (eq(numpy.arcsin(z), arcsin(zm)))\n self.failUnless (eq(numpy.arccos(z), arccos(zm)))\n self.failUnless (eq(numpy.arctan(z), arctan(zm)))\n self.failUnless (eq(numpy.arctan2(x, y), arctan2(xm, ym)))\n self.failUnless (eq(numpy.absolute(x), absolute(xm)))\n self.failUnless (eq(numpy.equal(x,y), equal(xm, ym)))\n self.failUnless (eq(numpy.not_equal(x,y), not_equal(xm, ym)))\n self.failUnless (eq(numpy.less(x,y), less(xm, ym)))\n self.failUnless (eq(numpy.greater(x,y), greater(xm, ym)))\n self.failUnless (eq(numpy.less_equal(x,y), less_equal(xm, ym)))\n self.failUnless (eq(numpy.greater_equal(x,y), greater_equal(xm, ym)))\n self.failUnless (eq(numpy.conjugate(x), conjugate(xm)))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((xm,ym))))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((x,y))))\n self.failUnless (eq(numpy.concatenate((x,y)), concatenate((xm,y))))\n self.failUnless (eq(numpy.concatenate((x,y,x)), concatenate((x,ym,x))))\n\n def check_xtestCount (self):\n \"Test count\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless( isinstance(count(ott), types.IntType))\n self.assertEqual(3, count(ott))\n self.assertEqual(1, count(1))\n self.failUnless (eq(0, array(1,mask=[1])))\n ott=ott.reshape((2,2))\n assert isMaskedArray(count(ott,0))\n assert isinstance(count(ott), types.IntType)\n self.failUnless (eq(3, count(ott)))\n assert getmask(count(ott,0)) is nomask\n self.failUnless (eq([1,2],count(ott,0)))\n\n def check_testMinMax (self):\n \"Test minimum and maximum.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n xr = numpy.ravel(x) #max doesn't work if shaped\n xmr = ravel(xm)\n self.failUnless (eq(max(xr), maximum(xmr))) #true because of careful selection of data\n self.failUnless (eq(min(xr), minimum(xmr))) #true because of careful selection of data\n\n def check_testAddSumProd (self):\n \"Test add, sum, product.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(numpy.add.reduce(x), add.reduce(x)))\n self.failUnless (eq(numpy.add.accumulate(x), add.accumulate(x)))\n self.failUnless (eq(4, sum(array(4))))\n self.failUnless (eq(4, sum(array(4), axis=0)))\n self.failUnless (eq(numpy.sum(x), sum(x)))\n self.failUnless (eq(numpy.sum(filled(xm,0)), sum(xm)))\n self.failUnless (eq(numpy.sum(x,0), sum(x,0)))\n self.failUnless (eq(numpy.product(x), product(x)))\n self.failUnless (eq(numpy.product(x,0), product(x,0)))\n self.failUnless (eq(numpy.product(filled(xm,1)), product(xm)))\n if len(s) > 1:\n self.failUnless (eq(numpy.concatenate((x,y),1), concatenate((xm,ym),1)))\n self.failUnless (eq(numpy.add.reduce(x,1), add.reduce(x,1)))\n self.failUnless (eq(numpy.sum(x,1), sum(x,1)))\n self.failUnless (eq(numpy.product(x,1), product(x,1)))\n\n\n def check_testCI(self):\n \"Test of conversions and indexing\"\n x1 = numpy.array([1,2,4,3])\n x2 = array(x1, mask = [1,0,0,0])\n x3 = array(x1, mask = [0,1,0,1])\n x4 = array(x1)\n # test conversion to strings\n junk, garbage = str(x2), repr(x2)\n assert eq(numpy.sort(x1),sort(x2, fill_value=0))\n # tests of indexing\n assert type(x2[1]) is type(x1[1])\n assert x1[1] == x2[1]\n assert x2[0] is masked\n assert eq(x1[2],x2[2])\n assert eq(x1[2:5],x2[2:5])\n assert eq(x1[:],x2[:])\n assert eq(x1[1:], x3[1:])\n x1[2]=9\n x2[2]=9\n assert eq(x1,x2)\n x1[1:3] = 99\n x2[1:3] = 99\n assert eq(x1,x2)\n x2[1] = masked\n assert eq(x1,x2)\n x2[1:3]=masked\n assert eq(x1,x2)\n x2[:] = x1\n x2[1] = masked\n assert allequal(getmask(x2),array([0,1,0,0]))\n x3[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x3), array([0,1,1,0]))\n x4[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x4), array([0,1,1,0]))\n assert allequal(x4, array([1,2,3,4]))\n x1 = numpy.arange(5)*1.0\n x2 = masked_values(x1, 3.0)\n assert eq(x1,x2)\n assert allequal(array([0,0,0,1,0],MaskType), x2.mask)\n assert eq(3.0, x2.fill_value())\n x1 = array([1,'hello',2,3],object)\n x2 = numpy.array([1,'hello',2,3],object)\n s1 = x1[1]\n s2 = x2[1]\n self.assertEqual(type(s2), str)\n self.assertEqual(type(s1), str)\n self.assertEqual(s1, s2)\n assert x1[1:1].shape == (0,)\n\n def check_testCopySize(self):\n \"Tests of some subtle points of copying and sizing.\"\n n = [0,0,1,0,0]\n m = make_mask(n)\n m2 = make_mask(m)\n self.failUnless(m is m2)\n m3 = make_mask(m, copy=1)\n self.failUnless(m is not m3)\n\n x1 = numpy.arange(5)\n y1 = array(x1, mask=m)\n self.failUnless( y1.raw_data() is not x1)\n self.failUnless( allequal(x1,y1.raw_data()))\n self.failUnless( y1.mask is m)\n\n y1a = array(y1, copy=0)\n self.failUnless( y1a.raw_data() is y1.raw_data())\n self.failUnless( y1a.mask is y1.mask)\n\n y2 = array(x1, mask=m, copy=0)\n self.failUnless( y2.raw_data() is x1)\n self.failUnless( y2.mask is m)\n self.failUnless( y2[2] is masked)\n y2[2]=9\n self.failUnless( y2[2] is not masked)\n self.failUnless( y2.mask is not m)\n self.failUnless( allequal(y2.mask, 0))\n\n y3 = array(x1*1.0, mask=m)\n self.failUnless(filled(y3).dtype is (x1*1.0).dtype)\n\n x4 = arange(4)\n x4[2] = masked\n y4 = resize(x4, (8,))\n self.failUnless( eq(concatenate([x4,x4]), y4))\n self.failUnless( eq(getmask(y4),[0,0,1,0,0,0,1,0]))\n y5 = repeat(x4, (2,2,2,2))\n self.failUnless( eq(y5, [0,0,1,1,2,2,3,3]))\n y6 = repeat(x4, 2)\n self.failUnless( eq(y5, y6))\n\n def check_testPut(self):\n \"Test of put\"\n d = arange(5)\n n = [0,0,0,1,1]\n m = make_mask(n)\n x = array(d, mask = m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n x[[1,4]] = [10,40]\n self.failUnless( x.mask is not m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is not masked)\n self.failUnless( eq(x, [0,10,2,-1,40]))\n\n x = array(d, mask = m)\n x.put([-1,100,200])\n self.failUnless( eq(x, [-1,100,200,0,0]))\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n\n x = array(d, mask = m)\n x.putmask([30,40])\n self.failUnless( eq(x, [0,1,2,30,40]))\n self.failUnless( x.mask is nomask)\n\n x = array(d, mask = m)\n y = x.compressed()\n z = array(x, mask = m)\n z.put(y)\n assert eq (x, z)\n\n def check_testMaPut(self):\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]\n i = numpy.nonzero(m)\n putmask(xm, m, z)\n assert take(xm, i) == z\n put(ym, i, zm)\n assert take(ym, i) == zm\n\n def check_testOddFeatures(self):\n \"Test of other odd features\"\n x = arange(20); x=x.reshape(4,5)\n x.flat[5] = 12\n assert x[1,0] == 12\n z = x + 10j * x\n assert eq(z.real, x)\n assert eq(z.imag, 10*x)\n assert eq((z*conjugate(z)).real, 101*x*x)\n z.imag[...] = 0.0\n\n x = arange(10)\n x[3] = masked\n assert str(x[3]) == str(masked)\n c = x >= 8\n assert count(where(c,masked,masked)) == 0\n assert shape(where(c,masked,masked)) == c.shape\n z = where(c , x, masked)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is masked\n assert z[7] is masked\n assert z[8] is not masked\n assert z[9] is not masked\n assert eq(x,z)\n z = where(c , masked, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n z = masked_where(c, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n assert eq(x,z)\n x = array([1.,2.,3.,4.,5.])\n c = array([1,1,1,0,0])\n x[2] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n c[0] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n assert eq(masked_where(greater(x, 2), x), masked_greater(x,2))\n assert eq(masked_where(greater_equal(x, 2), x), masked_greater_equal(x,2))\n assert eq(masked_where(less(x, 2), x), masked_less(x,2))\n assert eq(masked_where(less_equal(x, 2), x), masked_less_equal(x,2))\n assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x,2))\n assert eq(masked_where(equal(x, 2), x), masked_equal(x,2))\n assert eq(masked_where(not_equal(x,2), x), masked_not_equal(x,2))\n assert eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4])\n assert eq(masked_outside(range(5), 1, 3),[199,1,2,3,199])\n assert eq(masked_inside(array(range(5), mask=[1,0,0,0,0]), 1, 3).mask, [1,1,1,1,0])\n assert eq(masked_outside(array(range(5), mask=[0,1,0,0,0]), 1, 3).mask, [1,1,0,0,1])\n assert eq(masked_equal(array(range(5), mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,0])\n assert eq(masked_not_equal(array([2,2,1,2,1], mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,1])\n assert eq(masked_where([1,1,0,0,0], [1,2,3,4,5]), [99,99,3,4,5])\n atest = ones((10,10,10), dtype=float32)\n btest = zeros(atest.shape, MaskType)\n ctest = masked_where(btest,atest)\n assert eq(atest,ctest)\n z = choose(c, (-x, x))\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n x = arange(6)\n x[5] = masked\n y = arange(6)*10\n y[2]= masked\n c = array([1,1,1,0,0,0], mask=[1,0,0,0,0,0])\n cm = c.filled(1)\n z = where(c,x,y)\n zm = where(cm,x,y)\n assert eq(z, zm)\n assert getmask(zm) is nomask\n assert eq(zm, [0,1,2,30,40,50])\n z = where(c, masked, 1)\n assert eq(z, [99,99,99,1,1,1])\n z = where(c, 1, masked)\n assert eq(z, [99, 1, 1, 99, 99, 99])\n\n def check_testMinMax(self):\n \"Test of minumum, maximum.\"\n assert eq(minimum([1,2,3],[4,0,9]), [1,0,3])\n assert eq(maximum([1,2,3],[4,0,9]), [4,2,9])\n x = arange(5)\n y = arange(5) - 2\n x[3] = masked\n y[0] = masked\n assert eq(minimum(x,y), where(less(x,y), x, y))\n assert eq(maximum(x,y), where(greater(x,y), x, y))\n assert minimum(x) == 0\n assert maximum(x) == 4\n\n def check_testTakeTransposeInnerOuter(self):\n \"Test of take, transpose, inner, outer products\"\n x = arange(24)\n y = numpy.arange(24)\n x[5:6] = masked\n x=x.reshape(2,3,4)\n y=y.reshape(2,3,4)\n assert eq(numpy.transpose(y,(2,0,1)), transpose(x,(2,0,1)))\n assert eq(numpy.take(y, (2,0,1), 1), take(x, (2,0,1), 1))\n assert eq(numpy.innerproduct(filled(x,0),filled(y,0)),\n innerproduct(x, y))\n assert eq(numpy.outerproduct(filled(x,0),filled(y,0)),\n outerproduct(x, y))\n y = array(['abc', 1, 'def', 2, 3], object)\n y[2] = masked\n t = take(y,[0,3,4])\n assert t[0] == 'abc'\n assert t[1] == 2\n assert t[2] == 3\n\n def check_testInplace(self):\n \"\"\"Test of inplace operations and rich comparisons\"\"\"\n y = arange(10)\n\n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x += 1\n assert eq(x, y+1)\n xm += 1\n assert eq(x, y+1)\n\n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x -= 1\n assert eq(x, y-1)\n xm -= 1\n assert eq(xm, y-1)\n\n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x *= 2.0\n assert eq(x, y*2)\n xm *= 2.0\n assert eq(xm, y*2)\n\n x = arange(10)*2\n xm = arange(10)\n xm[2] = masked\n x /= 2\n assert eq(x, y)\n xm /= 2\n assert eq(x, y)\n\n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x /= 2.0\n assert eq(x, y/2.0)\n xm /= arange(10)\n assert eq(xm, ones((10,)))\n\n x = arange(10).astype(float32)\n xm = arange(10)\n xm[2] = masked\n id1 = id(x.raw_data())\n x += 1.\n assert id1 == id(x.raw_data())\n assert eq(x, y+1.)\n\n def check_testPickle(self):\n \"Test of pickling\"\n import pickle\n x = arange(12)\n x[4:10:2] = masked\n x = x.reshape(4,3)\n s = pickle.dumps(x)\n y = pickle.loads(s)\n assert eq(x,y)\n\n def check_testMasked(self):\n \"Test of masked element\"\n xx=arange(6)\n xx[1] = masked\n self.failUnless(str(masked) == '--')\n self.failUnless(xx[1] is masked)\n self.failUnlessEqual(filled(xx[1], 0), 0)\n # don't know why these should raise an exception...\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, masked)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, 2)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)\n #self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)\n\n def check_testAverage1(self):\n \"Test of average.\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless(eq(2.0, average(ott)))\n self.failUnless(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))\n result, wts = average(ott, weights=[1.,1.,2.,1.], returned=1)\n self.failUnless(eq(2.0, result))\n self.failUnless(wts == 4.0)\n ott[:] = masked\n self.failUnless(average(ott) is masked)\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n ott=ott.reshape(2,2)\n ott[:,1] = masked\n self.failUnless(eq(average(ott), [2.0, 0.0]))\n self.failUnless(average(ott,axis=1)[0] is masked)\n self.failUnless(eq([2.,0.], average(ott)))\n result, wts = average(ott, returned=1)\n self.failUnless(eq(wts, [1., 0.]))\n\n def check_testAverage2(self):\n \"More tests of average.\"\n w1 = [0,1,1,1,1,0]\n w2 = [[0,1,1,1,1,0],[1,0,0,0,0,1]]\n x=arange(6)\n self.failUnless(allclose(average(x), 2.5))\n self.failUnless(allclose(average(x, weights=w1), 2.5))\n y=array([arange(6), 2.0*arange(6)])\n self.failUnless(allclose(average(y, None), numpy.add.reduce(numpy.arange(6))*3./12.))\n self.failUnless(allclose(average(y, axis=0), numpy.arange(6) * 3./2.))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n self.failUnless(allclose(average(y, None, weights=w2), 20./6.))\n self.failUnless(allclose(average(y, axis=0, weights=w2), [0.,1.,2.,3.,4.,10.]))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n m1 = zeros(6)\n m2 = [0,0,1,1,0,0]\n m3 = [[0,0,1,1,0,0],[0,1,1,1,1,0]]\n m4 = ones(6)\n m5 = [0, 1, 1, 1, 1, 1]\n self.failUnless(allclose(average(masked_array(x, m1)), 2.5))\n self.failUnless(allclose(average(masked_array(x, m2)), 2.5))\n self.failUnless(average(masked_array(x, m4)) is masked)\n self.assertEqual(average(masked_array(x, m5)), 0.0)\n self.assertEqual(count(average(masked_array(x, m4))), 0)\n z = masked_array(y, m3)\n self.failUnless(allclose(average(z, None), 20./6.))\n self.failUnless(allclose(average(z, axis=0), [0.,1.,99.,99.,4.0, 7.5]))\n self.failUnless(allclose(average(z, axis=1), [2.5, 5.0]))\n self.failUnless(allclose( average(z,weights=w2), [0.,1., 99., 99., 4.0, 10.0]))\n\n a = arange(6)\n b = arange(6) * 3\n r1, w1 = average([[a,b],[b,a]], axis=1, returned=1)\n self.assertEqual(shape(r1) , shape(w1))\n self.assertEqual(r1.shape , w1.shape)\n r2, w2 = average(ones((2,2,3)), axis=0, weights=[3,1], returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), weights=ones((2,2,3)), returned=1)\n self.failUnless(shape(w2) == shape(r2))\n a2d = array([[1,2],[0,4]], float)\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n a2da = average(a2d)\n self.failUnless(eq (a2da, [0.5, 3.0]))\n a2dma = average(a2dm)\n self.failUnless(eq( a2dma, [1.0, 3.0]))\n a2dma = average(a2dm, axis=None)\n self.failUnless(eq(a2dma, 7./3.))\n a2dma = average(a2dm, axis=1)\n self.failUnless(eq(a2dma, [1.5, 4.0]))\n\n def check_testToPython(self):\n self.assertEqual(1, int(array(1)))\n self.assertEqual(1.0, float(array(1)))\n self.assertEqual(1, int(array([[[1]]])))\n self.assertEqual(1.0, float(array([[1]])))\n self.failUnlessRaises(ValueError, float, array([1,1]))\n self.failUnlessRaises(MAError, float, array([1],mask=[1]))\n self.failUnless(bool(array([0,1])))\n self.failUnless(bool(array([0,0],mask=[0,1])))\n self.failIf(bool(array([0,0])))\n self.failIf(bool(array([0,0],mask=[0,0])))\n\n def check_testScalarArithmetic(self):\n xm = array(0, mask=1)\n self.failUnless((1/array(0)).mask)\n self.failUnless((1 + xm).mask)\n self.failUnless((-xm).mask)\n self.failUnless((-xm).mask)\n self.failUnless(maximum(xm, xm).mask)\n self.failUnless(minimum(xm, xm).mask)\n self.failUnless(xm.filled().dtype is xm.data.dtype)\n x = array(0, mask=0)\n self.failUnless(x.filled() is x.data)\n self.failUnlessEqual(str(xm), str(masked_print_option))\n\n def check_testArrayMethods(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnless(eq(a.any(), a.data.any()))\n self.failUnless(eq(a.all(), a.data.all()))\n self.failUnless(eq(a.argmax(), a.data.argmax()))\n self.failUnless(eq(a.argmin(), a.data.argmin()))\n self.failUnless(eq(a.choose(0,1,2,3,4), a.data.choose(0,1,2,3,4)))\n self.failUnless(eq(a.compress([1,0,1]), a.data.compress([1,0,1])))\n self.failUnless(eq(a.conj(), a.data.conj()))\n self.failUnless(eq(a.conjugate(), a.data.conjugate()))\n m = array([[1,2],[3,4]])\n self.failUnless(eq(m.diagonal(), m.data.diagonal()))\n self.failUnless(eq(a.sum(), a.data.sum()))\n self.failUnless(eq(a.take([1,2]), a.data.take([1,2])))\n self.failUnless(eq(m.transpose(), m.data.transpose()))\n\n def check_testArrayAttributes(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnlessEqual(a.ndim, 1)\n\n def check_testAPI(self):\n self.failIf([m for m in dir(numpy.ndarray)\n if m not in dir(array) and not m.startswith('_')])\n\n def check_testSingleElementSubscript(self):\n a = array([1,3,2])\n b = array([1,3,2], mask=[1,0,1])\n self.failUnlessEqual(a[0].shape, ())\n self.failUnlessEqual(b[0].shape, ())\n self.failUnlessEqual(b[1].shape, ())\n\nclass test_ufuncs(ScipyTestCase):\n def setUp(self):\n self.d = (array([1.0, 0, -1, pi/2]*2, mask=[0,1]+[0]*6),\n array([1.0, 0, -1, pi/2]*2, mask=[1,0]+[0]*6),)\n\n\n def check_testUfuncRegression(self):\n for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate',\n 'sin', 'cos', 'tan',\n 'arcsin', 'arccos', 'arctan',\n 'sinh', 'cosh', 'tanh',\n 'arcsinh',\n 'arccosh',\n 'arctanh',\n 'absolute', 'fabs', 'negative',\n # 'nonzero', 'around',\n 'floor', 'ceil',\n # 'sometrue', 'alltrue',\n 'logical_not',\n 'add', 'subtract', 'multiply',\n 'divide', 'true_divide', 'floor_divide',\n 'remainder', 'fmod', 'hypot', 'arctan2',\n 'equal', 'not_equal', 'less_equal', 'greater_equal',\n 'less', 'greater',\n 'logical_and', 'logical_or', 'logical_xor',\n ]:\n try:\n uf = getattr(umath, f)\n except AttributeError:\n uf = getattr(oldnumeric, f)\n mf = getattr(numpy.ma, f)\n args = self.d[:uf.nin]\n ur = uf(*args)\n mr = mf(*args)\n self.failUnless(eq(ur.filled(0), mr.filled(0), f))\n self.failUnless(eqmask(ur.mask, mr.mask))\n\n def test_reduce(self):\n a = self.d[0]\n self.failIf(alltrue(a))\n self.failUnless(sometrue(a))\n self.failUnlessEqual(sum(a[:3]), 0)\n self.failUnlessEqual(product(a), 0)\n\n def test_minmax(self):\n a = arange(1,13).reshape(3,4)\n amask = masked_where(a < 5,a)\n self.failUnlessEqual(amask.max(), a.max())\n self.failUnlessEqual(amask.min(), 5)\n self.failUnless((amask.max(0) == a.max(0)).all())\n self.failUnless((amask.min(0) == [5,6,7,8]).all())\n self.failUnless(amask.max(1)[0].mask)\n self.failUnless(amask.min(1)[0].mask)\n\n def test_nonzero(self):\n for t in \"?bhilqpBHILQPfdgFDGO\":\n x = array([1,0,2,0], mask=[0,0,1,1])\n self.failUnless(eq(nonzero(x), [0]))\n\n\nclass test_array_methods(ScipyTestCase):\n \n def setUp(self):\n x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928, \n 8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732, \n 3.012, 6.022, 5.095, 3.116, 5.238, 3.957, \n 6.04 , 9.63 , 7.712, 3.382, 4.489, 6.479,\n 7.189, 9.645, 5.395, 4.961, 9.894, 2.893, \n 7.357, 9.828, 6.272, 3.758, 6.693, 0.993])\n X = x.reshape(6,6)\n XX = x.reshape(3,2,2,3)\n \n m = numpy.array([0, 1, 0, 1, 0, 0, \n 1, 0, 1, 1, 0, 1, \n 0, 0, 0, 1, 0, 1, \n 0, 0, 0, 1, 1, 1, \n 1, 0, 0, 1, 0, 0, \n 0, 0, 1, 0, 1, 0])\n mx = array(data=x,mask=m)\n mX = array(data=X,mask=m.reshape(X.shape))\n mXX = array(data=XX,mask=m.reshape(XX.shape))\n \n m2 = numpy.array([1, 1, 0, 1, 0, 0, \n 1, 1, 1, 1, 0, 1, \n 0, 0, 1, 1, 0, 1, \n 0, 0, 0, 1, 1, 1, \n 1, 0, 0, 1, 1, 0, \n 0, 0, 1, 0, 1, 1])\n m2x = array(data=x,mask=m2)\n m2X = array(data=X,mask=m2.reshape(X.shape))\n m2XX = array(data=XX,mask=m2.reshape(XX.shape))\n self.d = (x,X,XX,m,mx,mX,mXX)\n\n #------------------------------------------------------\n def test_trace(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXdiag = mX.diagonal()\n self.assertEqual(mX.trace(), mX.diagonal().compressed().sum())\n self.failUnless(eq(mX.trace(),\n X.trace() - sum(mXdiag.mask*X.diagonal())))\n\n def test_clip(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n clipped = mx.clip(2,8)\n self.failUnless(eq(clipped.mask,mx.mask))\n self.failUnless(eq(clipped.data,x.clip(2,8)))\n self.failUnless(eq(clipped.data,mx.data.clip(2,8)))\n\n def test_ptp(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n (n,m) = X.shape\n self.assertEqual(mx.ptp(),mx.compressed().ptp())\n rows = numpy.zeros(n,numpy.float_)\n cols = numpy.zeros(m,numpy.float_)\n for k in range(m):\n cols[k] = mX[:,k].compressed().ptp()\n for k in range(n):\n rows[k] = mX[k].compressed().ptp()\n self.failUnless(eq(mX.ptp(0),cols))\n self.failUnless(eq(mX.ptp(1),rows))\n\n def test_swapaxes(self):\n (x,X,XX,m,mx,mX,mXX,) = self.d\n mXswapped = mX.swapaxes(0,1)\n self.failUnless(eq(mXswapped[-1],mX[:,-1]))\n mXXswapped = mXX.swapaxes(0,2)\n self.assertEqual(mXXswapped.shape,(2,2,3,3))\n\n\n\ndef eqmask(m1, m2):\n if m1 is nomask:\n return m2 is nomask\n if m2 is nomask:\n return m1 is nomask\n return (m1 == m2).all()\n\ndef timingTest():\n for f in [testf, testinplace]:\n for n in [1000,10000,50000]:\n t = testta(n, f)\n t1 = testtb(n, f)\n t2 = testtc(n, f)\n print f.test_name\n print \"\"\"\\\nn = %7d\nnumpy time (ms) %6.1f\nMA maskless ratio %6.1f\nMA masked ratio %6.1f\n\"\"\" % (n, t*1000.0, t1/t, t2/t)\n\ndef testta(n, f):\n x=numpy.arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtb(n, f):\n x=arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtc(n, f):\n x=arange(n) + 1.0\n x[0] = masked\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testf(x):\n for i in range(25):\n y = x **2 + 2.0 * x - 1.0\n w = x **2 + 1.0\n z = (y / w) ** 2\n return z\ntestf.test_name = 'Simple arithmetic'\n\ndef testinplace(x):\n for i in range(25):\n y = x**2\n y += 2.0*x\n y -= 1.0\n y /= x\n return y\ntestinplace.test_name = 'Inplace operations'\n\nif __name__ == \"__main__\":\n ScipyTest('numpy.core.ma').run()\n #timingTest()\n", + "methods": [ + { + "name": "eq", + "long_name": "eq( v , w , msg = '' )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 41, + "parameters": [ + "v", + "w", + "msg" + ], + "start_line": 7, + "end_line": 14, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , * args , ** kwds )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 17, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 276, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic1d", + "long_name": "check_testBasic1d( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic2d", + "long_name": "check_testBasic2d( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 2, + "token_count": 209, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_testArithmetic", + "long_name": "check_testArithmetic( self )", + "filename": "test_ma.py", + "nloc": 34, + "complexity": 2, + "token_count": 518, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_testMixedArithmetic", + "long_name": "check_testMixedArithmetic( self )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncs1", + "long_name": "check_testUfuncs1( self )", + "filename": "test_ma.py", + "nloc": 29, + "complexity": 1, + "token_count": 600, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "check_xtestCount", + "long_name": "check_xtestCount( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 143, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 157, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAddSumProd", + "long_name": "check_testAddSumProd( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 2, + "token_count": 361, + "parameters": [ + "self" + ], + "start_line": 165, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testCI", + "long_name": "check_testCI( self )", + "filename": "test_ma.py", + "nloc": 46, + "complexity": 1, + "token_count": 560, + "parameters": [ + "self" + ], + "start_line": 185, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 1 + }, + { + "name": "check_testCopySize", + "long_name": "check_testCopySize( self )", + "filename": "test_ma.py", + "nloc": 35, + "complexity": 1, + "token_count": 409, + "parameters": [ + "self" + ], + "start_line": 234, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "check_testPut", + "long_name": "check_testPut( self )", + "filename": "test_ma.py", + "nloc": 27, + "complexity": 1, + "token_count": 291, + "parameters": [ + "self" + ], + "start_line": 275, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_testMaPut", + "long_name": "check_testMaPut( self )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self" + ], + "start_line": 306, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_testOddFeatures", + "long_name": "check_testOddFeatures( self )", + "filename": "test_ma.py", + "nloc": 88, + "complexity": 1, + "token_count": 1188, + "parameters": [ + "self" + ], + "start_line": 315, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testTakeTransposeInnerOuter", + "long_name": "check_testTakeTransposeInnerOuter( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 1, + "token_count": 235, + "parameters": [ + "self" + ], + "start_line": 418, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "check_testInplace", + "long_name": "check_testInplace( self )", + "filename": "test_ma.py", + "nloc": 44, + "complexity": 1, + "token_count": 315, + "parameters": [ + "self" + ], + "start_line": 438, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testPickle", + "long_name": "check_testPickle( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 490, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_testMasked", + "long_name": "check_testMasked( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 500, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage1", + "long_name": "check_testAverage1( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 1, + "token_count": 289, + "parameters": [ + "self" + ], + "start_line": 513, + "end_line": 530, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage2", + "long_name": "check_testAverage2( self )", + "filename": "test_ma.py", + "nloc": 50, + "complexity": 1, + "token_count": 945, + "parameters": [ + "self" + ], + "start_line": 532, + "end_line": 582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testToPython", + "long_name": "check_testToPython( self )", + "filename": "test_ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 193, + "parameters": [ + "self" + ], + "start_line": 584, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_testScalarArithmetic", + "long_name": "check_testScalarArithmetic( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 146, + "parameters": [ + "self" + ], + "start_line": 596, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testArrayMethods", + "long_name": "check_testArrayMethods( self )", + "filename": "test_ma.py", + "nloc": 16, + "complexity": 1, + "token_count": 351, + "parameters": [ + "self" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_testArrayAttributes", + "long_name": "check_testArrayAttributes( self )", + "filename": "test_ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 626, + "end_line": 629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_testAPI", + "long_name": "check_testAPI( self )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 4, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 631, + "end_line": 633, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_testSingleElementSubscript", + "long_name": "check_testSingleElementSubscript( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 635, + "end_line": 640, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 643, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncRegression", + "long_name": "check_testUfuncRegression( self )", + "filename": "test_ma.py", + "nloc": 28, + "complexity": 3, + "token_count": 189, + "parameters": [ + "self" + ], + "start_line": 648, + "end_line": 677, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "test_reduce", + "long_name": "test_reduce( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 679, + "end_line": 684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_minmax", + "long_name": "test_minmax( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 141, + "parameters": [ + "self" + ], + "start_line": 686, + "end_line": 694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "test_nonzero", + "long_name": "test_nonzero( self )", + "filename": "test_ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 696, + "end_line": 699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 28, + "complexity": 1, + "token_count": 460, + "parameters": [ + "self" + ], + "start_line": 704, + "end_line": 733, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "test_trace", + "long_name": "test_trace( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 88, + "parameters": [ + "self" + ], + "start_line": 736, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_clip", + "long_name": "test_clip( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 92, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 748, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_ptp", + "long_name": "test_ptp( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 162, + "parameters": [ + "self" + ], + "start_line": 750, + "end_line": 761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "test_swapaxes", + "long_name": "test_swapaxes( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 84, + "parameters": [ + "self" + ], + "start_line": 763, + "end_line": 768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_cumprod", + "long_name": "test_cumprod( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_cumsum", + "long_name": "test_cumsum( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_varstd", + "long_name": "test_varstd( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 2, + "token_count": 246, + "parameters": [ + "self" + ], + "start_line": 785, + "end_line": 796, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "eqmask", + "long_name": "eqmask( m1 , m2 )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 35, + "parameters": [ + "m1", + "m2" + ], + "start_line": 799, + "end_line": 804, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "timingTest", + "long_name": "timingTest( )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [], + "start_line": 806, + "end_line": 818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "testta", + "long_name": "testta( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "n", + "f" + ], + "start_line": 820, + "end_line": 824, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtb", + "long_name": "testtb( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "n", + "f" + ], + "start_line": 826, + "end_line": 830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtc", + "long_name": "testtc( n , f )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "n", + "f" + ], + "start_line": 832, + "end_line": 837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testf", + "long_name": "testf( x )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 48, + "parameters": [ + "x" + ], + "start_line": 839, + "end_line": 844, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testinplace", + "long_name": "testinplace( x )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 847, + "end_line": 853, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "eq", + "long_name": "eq( v , w , msg = '' )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 41, + "parameters": [ + "v", + "w", + "msg" + ], + "start_line": 7, + "end_line": 14, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , * args , ** kwds )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 17, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 276, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic1d", + "long_name": "check_testBasic1d( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic2d", + "long_name": "check_testBasic2d( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 2, + "token_count": 209, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_testArithmetic", + "long_name": "check_testArithmetic( self )", + "filename": "test_ma.py", + "nloc": 34, + "complexity": 2, + "token_count": 518, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_testMixedArithmetic", + "long_name": "check_testMixedArithmetic( self )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncs1", + "long_name": "check_testUfuncs1( self )", + "filename": "test_ma.py", + "nloc": 29, + "complexity": 1, + "token_count": 600, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "check_xtestCount", + "long_name": "check_xtestCount( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 143, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 157, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAddSumProd", + "long_name": "check_testAddSumProd( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 2, + "token_count": 361, + "parameters": [ + "self" + ], + "start_line": 165, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testCI", + "long_name": "check_testCI( self )", + "filename": "test_ma.py", + "nloc": 46, + "complexity": 1, + "token_count": 560, + "parameters": [ + "self" + ], + "start_line": 185, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 1 + }, + { + "name": "check_testCopySize", + "long_name": "check_testCopySize( self )", + "filename": "test_ma.py", + "nloc": 35, + "complexity": 1, + "token_count": 409, + "parameters": [ + "self" + ], + "start_line": 234, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "check_testPut", + "long_name": "check_testPut( self )", + "filename": "test_ma.py", + "nloc": 27, + "complexity": 1, + "token_count": 291, + "parameters": [ + "self" + ], + "start_line": 275, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_testMaPut", + "long_name": "check_testMaPut( self )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self" + ], + "start_line": 306, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_testOddFeatures", + "long_name": "check_testOddFeatures( self )", + "filename": "test_ma.py", + "nloc": 88, + "complexity": 1, + "token_count": 1188, + "parameters": [ + "self" + ], + "start_line": 315, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testTakeTransposeInnerOuter", + "long_name": "check_testTakeTransposeInnerOuter( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 1, + "token_count": 235, + "parameters": [ + "self" + ], + "start_line": 418, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "check_testInplace", + "long_name": "check_testInplace( self )", + "filename": "test_ma.py", + "nloc": 44, + "complexity": 1, + "token_count": 315, + "parameters": [ + "self" + ], + "start_line": 438, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testPickle", + "long_name": "check_testPickle( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 490, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_testMasked", + "long_name": "check_testMasked( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 500, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage1", + "long_name": "check_testAverage1( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 1, + "token_count": 289, + "parameters": [ + "self" + ], + "start_line": 513, + "end_line": 530, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage2", + "long_name": "check_testAverage2( self )", + "filename": "test_ma.py", + "nloc": 50, + "complexity": 1, + "token_count": 945, + "parameters": [ + "self" + ], + "start_line": 532, + "end_line": 582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testToPython", + "long_name": "check_testToPython( self )", + "filename": "test_ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 193, + "parameters": [ + "self" + ], + "start_line": 584, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_testScalarArithmetic", + "long_name": "check_testScalarArithmetic( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 146, + "parameters": [ + "self" + ], + "start_line": 596, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testArrayMethods", + "long_name": "check_testArrayMethods( self )", + "filename": "test_ma.py", + "nloc": 16, + "complexity": 1, + "token_count": 351, + "parameters": [ + "self" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_testArrayAttributes", + "long_name": "check_testArrayAttributes( self )", + "filename": "test_ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 626, + "end_line": 629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_testAPI", + "long_name": "check_testAPI( self )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 4, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 631, + "end_line": 633, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_testSingleElementSubscript", + "long_name": "check_testSingleElementSubscript( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 635, + "end_line": 640, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 643, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncRegression", + "long_name": "check_testUfuncRegression( self )", + "filename": "test_ma.py", + "nloc": 28, + "complexity": 3, + "token_count": 189, + "parameters": [ + "self" + ], + "start_line": 648, + "end_line": 677, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "test_reduce", + "long_name": "test_reduce( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 679, + "end_line": 684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_minmax", + "long_name": "test_minmax( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 141, + "parameters": [ + "self" + ], + "start_line": 686, + "end_line": 694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "test_nonzero", + "long_name": "test_nonzero( self )", + "filename": "test_ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 696, + "end_line": 699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 28, + "complexity": 1, + "token_count": 460, + "parameters": [ + "self" + ], + "start_line": 704, + "end_line": 733, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "test_trace", + "long_name": "test_trace( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 88, + "parameters": [ + "self" + ], + "start_line": 736, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_clip", + "long_name": "test_clip( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 92, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 748, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_ptp", + "long_name": "test_ptp( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 162, + "parameters": [ + "self" + ], + "start_line": 750, + "end_line": 761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "test_swapaxes", + "long_name": "test_swapaxes( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 84, + "parameters": [ + "self" + ], + "start_line": 763, + "end_line": 768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "eqmask", + "long_name": "eqmask( m1 , m2 )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 35, + "parameters": [ + "m1", + "m2" + ], + "start_line": 772, + "end_line": 777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "timingTest", + "long_name": "timingTest( )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [], + "start_line": 779, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "testta", + "long_name": "testta( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "n", + "f" + ], + "start_line": 793, + "end_line": 797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtb", + "long_name": "testtb( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "n", + "f" + ], + "start_line": 799, + "end_line": 803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtc", + "long_name": "testtc( n , f )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "n", + "f" + ], + "start_line": 805, + "end_line": 810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testf", + "long_name": "testf( x )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 48, + "parameters": [ + "x" + ], + "start_line": 812, + "end_line": 817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testinplace", + "long_name": "testinplace( x )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 820, + "end_line": 826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "test_varstd", + "long_name": "test_varstd( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 2, + "token_count": 246, + "parameters": [ + "self" + ], + "start_line": 785, + "end_line": 796, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "test_cumsum", + "long_name": "test_cumsum( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_cumprod", + "long_name": "test_cumprod( self )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "nloc": 771, + "complexity": 68, + "token_count": 10231, + "diff_parsed": { + "added": [ + " def test_cumprod(self):", + " (x,X,XX,m,mx,mX,mXX,) = self.d", + " mXcp = mX.cumprod(0)", + " self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(0)))", + " mXcp = mX.cumprod(1)", + " self.failUnless(eq(mXcp.data,mX.filled(1).cumprod(1)))", + "", + " def test_cumsum(self):", + " (x,X,XX,m,mx,mX,mXX,) = self.d", + " mXcp = mX.cumsum(0)", + " self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(0)))", + " mXcp = mX.cumsum(1)", + " self.failUnless(eq(mXcp.data,mX.filled(0).cumsum(1)))", + "", + " def test_varstd(self):", + " (x,X,XX,m,mx,mX,mXX,) = self.d", + " self.failUnless(eq(mX.var(axis=None),mX.compressed().var()))", + " self.failUnless(eq(mX.std(axis=None),mX.compressed().std()))", + " self.failUnless(eq(mXX.var(axis=3).shape,XX.var(axis=3).shape))", + " self.failUnless(eq(mX.var().shape,X.var().shape))", + " (mXvar0,mXvar1) = (mX.var(axis=0), mX.var(axis=1))", + " for k in range(6):", + " self.failUnless(eq(mXvar1[k],mX[k].compressed().var()))", + " self.failUnless(eq(mXvar0[k],mX[:,k].compressed().var()))", + " self.failUnless(eq(numpy.sqrt(mXvar0[k]),", + " mX[:,k].compressed().std()))", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "18c2a959e5ef86a576cc13470ac845174b57a39c", + "msg": "fixed mask calculation in cum* methods", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-04-07T04:08:44+00:00", + "author_timezone": 0, + "committer_date": "2006-04-07T04:08:44+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b6427785d14ee282c6e4251771f8a48283a0ecaf" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 2, + "insertions": 2, + "lines": 4, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/ma.py", + "new_path": "numpy/core/ma.py", + "filename": "ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2155,14 +2155,14 @@ def _compress(self, cond, axis=None):\n def _cumprod(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n- m = umath.logical_and.accumulate(self.mask, axis)\n+ m = umath.logical_or.accumulate(self.mask, axis)\n return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)\n array.cumprod = _m(_cumprod)\n \n def _cumsum(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n- m = umath.logical_and.accumulate(self.mask, axis)\n+ m = umath.logical_or.accumulate(self.mask, axis)\n return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)\n array.cumsum = _m(_cumsum)\n \n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\"\"\"MA: a facility for dealing with missing observations\nMA is generally used as a numpy.array look-alike.\nby Paul F. Dubois.\n\nCopyright 1999, 2000, 2001 Regents of the University of California.\nReleased for unlimited redistribution.\nAdapted for numpy_core 2005 by Travis Oliphant and\n(mainly) Paul Dubois.\n\"\"\"\nimport types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import bool_\nimport numeric\nimport warnings\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType = bool_\nnomask = MaskType(0)\ndivide_tolerance = 1.e-35\n\nclass MAError (Exception):\n def __init__ (self, args=None):\n \"Create an exception\"\n self.args = args\n def __str__(self):\n \"Calculate the string representation\"\n return str(self.args)\n __repr__ = __str__\n\nclass _MaskedPrintOption:\n \"One instance of this class, masked_print_option, is created.\"\n def __init__ (self, display):\n \"Create the masked print option object.\"\n self.set_display(display)\n self._enabled = 1\n\n def display (self):\n \"Show what prints for masked values.\"\n return self._display\n\n def set_display (self, s):\n \"set_display(s) sets what prints for masked values.\"\n self._display = s\n\n def enabled (self):\n \"Is the use of the display value enabled?\"\n return self._enabled\n\n def enable(self, flag=1):\n \"Set the enabling flag to flag.\"\n self._enabled = flag\n\n def __str__ (self):\n return str(self._display)\n\n __repr__ = __str__\n\n#if you single index into a masked location you get this object.\nmasked_print_option = _MaskedPrintOption('--')\n\n# Use single element arrays or scalars.\ndefault_real_fill_value = 1.e20\ndefault_complex_fill_value = 1.e20 + 0.0j\ndefault_character_fill_value = '-'\ndefault_integer_fill_value = 999999\ndefault_object_fill_value = '?'\n\ndef default_fill_value (obj):\n \"Function to calculate default fill value for an object.\"\n if isinstance(obj, types.FloatType):\n return default_real_fill_value\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return default_integer_fill_value\n elif isinstance(obj, types.StringType):\n return default_character_fill_value\n elif isinstance(obj, types.ComplexType):\n return default_complex_fill_value\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return default_real_fill_value\n if x in typecodes['Integer']:\n return default_integer_fill_value\n if x in typecodes['Complex']:\n return default_complex_fill_value\n if x in typecodes['Character']:\n return default_character_fill_value\n if x in typecodes['UnsignedInteger']:\n return umath.absolute(default_integer_fill_value)\n return default_object_fill_value\n else:\n return default_object_fill_value\n\ndef minimum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking minima.\"\n if isinstance(obj, types.FloatType):\n return numeric.inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return numeric.inf\n if x in typecodes['Integer']:\n return sys.maxint\n if x in typecodes['UnsignedInteger']:\n return sys.maxint\n else:\n raise TypeError, 'Unsuitable type for calculating minimum.'\n\ndef maximum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking maxima.\"\n if isinstance(obj, types.FloatType):\n return -inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return -sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return -inf\n if x in typecodes['Integer']:\n return -sys.maxint\n if x in typecodes['UnsignedInteger']:\n return 0\n else:\n raise TypeError, 'Unsuitable type for calculating maximum.'\n\ndef set_fill_value (a, fill_value):\n \"Set fill value of a if it is a masked array.\"\n if isMaskedArray(a):\n a.set_fill_value (fill_value)\n\ndef getmask (a):\n \"\"\"Mask of values in a; could be nomask.\n Returns nomask if a is not a masked array.\n To get an array for sure use getmaskarray.\"\"\"\n if isinstance(a, MaskedArray):\n return a.raw_mask()\n else:\n return nomask\n\ndef getmaskarray (a):\n \"\"\"Mask of values in a; an array of zeros if mask is nomask\n or not a masked array, and is a byte-sized integer.\n Do not try to add up entries, for example.\n \"\"\"\n m = getmask(a)\n if m is nomask:\n return make_mask_none(shape(a))\n else:\n return m\n\ndef is_mask (m):\n \"\"\"Is m a legal mask? Does not check contents, only type.\n \"\"\"\n try:\n return m.dtype.type is MaskType\n except AttributeError:\n return False\n\ndef make_mask (m, copy=0, flag=0):\n \"\"\"make_mask(m, copy=0, flag=0)\n return m as a mask, creating a copy if necessary or requested.\n Can accept any sequence of integers or nomask. Does not check\n that contents must be 0s and 1s.\n if flag, return nomask if m contains no true elements.\n \"\"\"\n if m is nomask:\n return nomask\n elif isinstance(m, ndarray):\n if m.dtype.type is MaskType:\n if copy:\n result = numeric.array(m, dtype=MaskType, copy=copy)\n else:\n result = m\n else:\n result = m.astype(MaskType)\n else:\n result = filled(m, True).astype(MaskType)\n\n if flag and not oldnumeric.sometrue(oldnumeric.ravel(result)):\n return nomask\n else:\n return result\n\ndef make_mask_none (s):\n \"Return a mask of all zeros of shape s.\"\n result = numeric.zeros(s, dtype=MaskType)\n result.shape = s\n return result\n\ndef mask_or (m1, m2):\n \"\"\"Logical or of the mask candidates m1 and m2, treating nomask as false.\n Result may equal m1 or m2 if the other is nomask.\n \"\"\"\n if m1 is nomask: return make_mask(m2)\n if m2 is nomask: return make_mask(m1)\n if m1 is m2 and is_mask(m1): return m1\n return make_mask(umath.logical_or(m1, m2))\n\ndef filled (a, value = None):\n \"\"\"a as a contiguous numeric array with any masked areas replaced by value\n if value is None or the special element \"masked\", get_fill_value(a)\n is used instead.\n\n If a is already a contiguous numeric array, a itself is returned.\n\n filled(a) can be used to be sure that the result is numeric when\n passing an object a to other software ignorant of MA, in particular to\n numeric itself.\n \"\"\"\n if isinstance(a, MaskedArray):\n return a.filled(value)\n elif isinstance(a, ndarray) and a.flags['CONTIGUOUS']:\n return a\n elif isinstance(a, types.DictType):\n return numeric.array(a, 'O')\n else:\n return numeric.array(a)\n\ndef get_fill_value (a):\n \"\"\"\n The fill value of a, if it has one; otherwise, the default fill value\n for that type.\n \"\"\"\n if isMaskedArray(a):\n result = a.fill_value()\n else:\n result = default_fill_value(a)\n return result\n\ndef common_fill_value (a, b):\n \"The common fill_value of a and b, if there is one, or None\"\n t1 = get_fill_value(a)\n t2 = get_fill_value(b)\n if t1 == t2: return t1\n return None\n\n# Domain functions return 1 where the argument(s) are not in the domain.\nclass domain_check_interval:\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n def __init__(self, y1, y2):\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n self.y1 = y1\n self.y2 = y2\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.logical_or(umath.greater (x, self.y2),\n umath.less(x, self.y1)\n )\n\nclass domain_tan:\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n def __init__(self, eps):\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n self.eps = eps\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less(umath.absolute(umath.cos(x)), self.eps)\n\nclass domain_greater:\n \"domain_greater(v)(x) = true where x <= v\"\n def __init__(self, critical_value):\n \"domain_greater(v)(x) = true where x <= v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less_equal (x, self.critical_value)\n\nclass domain_greater_equal:\n \"domain_greater_equal(v)(x) = true where x < v\"\n def __init__(self, critical_value):\n \"domain_greater_equal(v)(x) = true where x < v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less (x, self.critical_value)\n\nclass masked_unary_operation:\n def __init__ (self, aufunc, fill=0, domain=None):\n \"\"\" masked_unary_operation(aufunc, fill=0, domain=None)\n aufunc(fill) must be defined\n self(x) returns aufunc(x)\n with masked values where domain(x) is true or getmask(x) is true.\n \"\"\"\n self.f = aufunc\n self.fill = fill\n self.domain = domain\n self.__doc__ = getattr(aufunc, \"__doc__\", str(aufunc))\n self.__name__ = getattr(aufunc, \"__name__\", str(aufunc))\n ufunc_domain[aufunc] = domain\n ufunc_fills[aufunc] = fill,\n\n def __call__ (self, a, *args, **kwargs):\n \"Execute the call behavior.\"\n# numeric tries to return scalars rather than arrays when given scalars.\n m = getmask(a)\n d1 = filled(a, self.fill)\n if self.domain is not None:\n m = mask_or(m, self.domain(d1))\n result = self.f(d1, *args, **kwargs)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\n\nclass domain_safe_divide:\n def __init__ (self, tolerance=divide_tolerance):\n self.tolerance = tolerance\n def __call__ (self, a, b):\n return umath.absolute(a) * self.tolerance >= umath.absolute(b)\n\nclass domained_binary_operation:\n \"\"\"Binary operations that have a domain, like divide. These are complicated\n so they are a separate class. They have no reduce, outer or accumulate.\n \"\"\"\n def __init__ (self, abfunc, domain, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.domain = domain\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n self.__name__ = getattr(abfunc, \"__name__\", str(abfunc))\n ufunc_domain[abfunc] = domain\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__(self, a, b):\n \"Execute the call behavior.\"\n ma = getmask(a)\n mb = getmask(b)\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n t = self.domain(d1, d2)\n\n if oldnumeric.sometrue(t, None):\n d2 = where(t, self.filly, d2)\n mb = mask_or(mb, t)\n m = mask_or(ma, mb)\n result = self.f(d1, d2)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nclass masked_binary_operation:\n def __init__ (self, abfunc, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n ufunc_domain[abfunc] = None\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__ (self, a, b, *args, **kwargs):\n \"Execute the call behavior.\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n result = self.f(d1, d2, *args, **kwargs)\n return masked_array(result, m)\n\n def reduce (self, target, axis=0, dtype=None):\n \"\"\"Reduce target along the given axis with this function.\"\"\"\n m = getmask(target)\n t = filled(target, self.filly)\n if t.shape == ():\n t = t.reshape(1)\n if m is not nomask:\n m = make_mask(m, copy=1)\n m.shape = (1,)\n if m is nomask:\n return masked_array (self.f.reduce (t, axis))\n else:\n t = masked_array (t, m)\n # XXX: \"or t.dtype\" below is a workaround for what appears\n # XXX: to be a bug in reduce.\n t = self.f.reduce(filled(t, self.filly), axis, dtype=dtype or t.dtype)\n m = umath.logical_and.reduce(m, axis)\n if isinstance(t, ndarray):\n return masked_array(t, m, get_fill_value(target))\n elif m:\n return masked\n else:\n return t\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = self.f.outer(filled(a, self.fillx), filled(b, self.filly))\n return masked_array(d, m)\n\n def accumulate (self, target, axis=0):\n \"\"\"Accumulate target along axis after filling with y fill value.\"\"\"\n t = filled(target, self.filly)\n return masked_array (self.f.accumulate (t, axis))\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nsqrt = masked_unary_operation(umath.sqrt, 0.0, domain_greater_equal(0.0))\nlog = masked_unary_operation(umath.log, 1.0, domain_greater(0.0))\nlog10 = masked_unary_operation(umath.log10, 1.0, domain_greater(0.0))\nexp = masked_unary_operation(umath.exp)\nconjugate = masked_unary_operation(umath.conjugate)\nsin = masked_unary_operation(umath.sin)\ncos = masked_unary_operation(umath.cos)\ntan = masked_unary_operation(umath.tan, 0.0, domain_tan(1.e-35))\narcsin = masked_unary_operation(umath.arcsin, 0.0, domain_check_interval(-1.0, 1.0))\narccos = masked_unary_operation(umath.arccos, 0.0, domain_check_interval(-1.0, 1.0))\narctan = masked_unary_operation(umath.arctan)\n# Missing from numeric\narcsinh = masked_unary_operation(umath.arcsinh)\narccosh = masked_unary_operation(umath.arccosh, 1.0, domain_greater_equal(1.0))\narctanh = masked_unary_operation(umath.arctanh, 0.0, domain_check_interval(-1.0+1e-15, 1.0-1e-15))\nsinh = masked_unary_operation(umath.sinh)\ncosh = masked_unary_operation(umath.cosh)\ntanh = masked_unary_operation(umath.tanh)\nabsolute = masked_unary_operation(umath.absolute)\nfabs = masked_unary_operation(umath.fabs)\nnegative = masked_unary_operation(umath.negative)\n\ndef nonzero(a):\n \"\"\"returns the indices of the elements of a which are not zero and not masked\n\n a must be 1d\n \"\"\"\n return asarray(filled(a, 0).nonzero())\n\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nlogical_not = masked_unary_operation(umath.logical_not)\n\nadd = masked_binary_operation(umath.add)\nsubtract = masked_binary_operation(umath.subtract)\nsubtract.reduce = None\nmultiply = masked_binary_operation(umath.multiply, 1, 1)\ndivide = domained_binary_operation(umath.divide, domain_safe_divide(), 0, 1)\ntrue_divide = domained_binary_operation(umath.true_divide, domain_safe_divide(), 0, 1)\nfloor_divide = domained_binary_operation(umath.floor_divide, domain_safe_divide(), 0, 1)\nremainder = domained_binary_operation(umath.remainder, domain_safe_divide(), 0, 1)\nfmod = domained_binary_operation(umath.fmod, domain_safe_divide(), 0, 1)\nhypot = masked_binary_operation(umath.hypot)\narctan2 = masked_binary_operation(umath.arctan2, 0.0, 1.0)\narctan2.reduce = None\nequal = masked_binary_operation(umath.equal)\nequal.reduce = None\nnot_equal = masked_binary_operation(umath.not_equal)\nnot_equal.reduce = None\nless_equal = masked_binary_operation(umath.less_equal)\nless_equal.reduce = None\ngreater_equal = masked_binary_operation(umath.greater_equal)\ngreater_equal.reduce = None\nless = masked_binary_operation(umath.less)\nless.reduce = None\ngreater = masked_binary_operation(umath.greater)\ngreater.reduce = None\nlogical_and = masked_binary_operation(umath.logical_and)\nalltrue = masked_binary_operation(umath.logical_and, 1, 1).reduce\nlogical_or = masked_binary_operation(umath.logical_or)\nsometrue = logical_or.reduce\nlogical_xor = masked_binary_operation(umath.logical_xor)\nbitwise_and = masked_binary_operation(umath.bitwise_and)\nbitwise_or = masked_binary_operation(umath.bitwise_or)\nbitwise_xor = masked_binary_operation(umath.bitwise_xor)\n\ndef rank (object):\n return oldnumeric.rank(filled(object))\n\ndef shape (object):\n return oldnumeric.shape(filled(object))\n\ndef size (object, axis=None):\n return oldnumeric.size(filled(object), axis)\n\nclass MaskedArray (object):\n \"\"\"Arrays with possibly masked values.\n Masked values of 1 exclude the corresponding element from\n any computation.\n\n Construction:\n x = array(data, dtype=None, copy=True, order=False,\n mask = nomask, fill_value=None)\n\n If copy=False, every effort is made not to copy the data:\n If data is a MaskedArray, and argument mask=nomask,\n then the candidate data is data.data and the\n mask used is data.mask. If data is a numeric array,\n it is used as the candidate raw data.\n If dtype.char is not None and\n is != data.dtype.char then a data copy is required.\n Otherwise, the candidate is used.\n\n If a data copy is required, raw data stored is the result of:\n numeric.array(data, dtype=dtype.char, copy=copy)\n\n If mask is nomask there are no masked values. Otherwise mask must\n be convertible to an array of booleans with the same shape as x.\n\n fill_value is used to fill in masked values when necessary,\n such as when printing and in method/function filled().\n The fill_value is not used for computation within this module.\n \"\"\"\n __array_priority__ = 10.1\n def __init__(self, data, dtype=None, copy=True, order=False,\n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None)\n If data already a numeric array, its dtype becomes the default value of dtype.\n \"\"\"\n if dtype is None:\n tc = None\n else:\n tc = numeric.dtype(dtype)\n need_data_copied = copy\n if isinstance(data, MaskedArray):\n c = data.data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n if mask is nomask:\n mask = data.mask\n elif mask is not nomask: #attempting to change the mask\n need_data_copied = True\n\n elif isinstance(data, ndarray):\n c = data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n else:\n need_data_copied = False #because I'll do it now\n c = numeric.array(data, dtype=tc, copy=True, order=order)\n tc = c.dtype\n\n if need_data_copied:\n if tc == c.dtype:\n self._data = numeric.array(c, dtype=tc, copy=True, order=order)\n else:\n self._data = c.astype(tc)\n else:\n self._data = c\n\n if mask is nomask:\n self._mask = nomask\n self._shared_mask = 0\n else:\n self._mask = make_mask (mask)\n if self._mask is nomask:\n self._shared_mask = 0\n else:\n self._shared_mask = (self._mask is mask)\n nm = size(self._mask)\n nd = size(self._data)\n if nm != nd:\n if nm == 1:\n self._mask = oldnumeric.resize(self._mask, self._data.shape)\n self._shared_mask = 0\n elif nd == 1:\n self._data = oldnumeric.resize(self._data, self._mask.shape)\n self._data.shape = self._mask.shape\n else:\n raise MAError, \"Mask and data not compatible.\"\n elif nm == 1 and shape(self._mask) != shape(self._data):\n self.unshare_mask()\n self._mask.shape = self._data.shape\n\n self.set_fill_value(fill_value)\n\n def __array__ (self, t=None, context=None):\n \"Special hook for numeric. Converts to numeric if possible.\"\n if self._mask is not nomask:\n if oldnumeric.ravel(self._mask).any():\n if context is None:\n warnings.warn(\"Cannot automatically convert masked array to \"\\\n \"numeric because data\\n is masked in one or \"\\\n \"more locations.\");\n return self._data\n #raise MAError, \\\n # \"\"\"Cannot automatically convert masked array to numeric because data\n # is masked in one or more locations.\n # \"\"\"\n else:\n func, args, i = context\n fills = ufunc_fills.get(func)\n if fills is None:\n raise MAError, \"%s not known to ma\" % func\n return self.filled(fills[i])\n else: # Mask is all false\n # Optimize to avoid future invocations of this section.\n self._mask = nomask\n self._shared_mask = 0\n if t:\n return self._data.astype(t)\n else:\n return self._data\n\n def __array_wrap__ (self, array, context):\n \"\"\"Special hook for ufuncs.\n\n Wraps the numpy array and sets the mask according to\n context.\n \"\"\"\n func, args = context[:2]\n domain = ufunc_domain[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[getattr(a, '_data', a)\n for a in args]))\n if m is not nomask:\n try:\n shape = array.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = reduce(mask_or, [getmaskarray(a) for a in args])\n\n return MaskedArray(array, copy=False, mask=m)\n\n def _get_shape(self):\n \"Return the current shape.\"\n return self._data.shape\n\n def _set_shape (self, newshape):\n \"Set the array's shape.\"\n self._data.shape = newshape\n if self._mask is not nomask:\n self._mask = self._mask.copy()\n self._mask.shape = newshape\n\n def _get_flat(self):\n \"\"\"Calculate the flat value.\n \"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel(), mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.ravel(),\n mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_flat (self, value):\n \"x.flat = value\"\n y = self.ravel()\n y[:] = value\n\n def _get_real(self):\n \"Get the real part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.real, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.real, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_real (self, value):\n \"x.real = value\"\n y = self.real\n y[...] = value\n\n def _get_imaginary(self):\n \"Get the imaginary part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.imag, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.imag, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_imaginary (self, value):\n \"x.imaginary = value\"\n y = self.imaginary\n y[...] = value\n\n def __str__(self):\n \"\"\"Calculate the str representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n if masked_print_option.enabled():\n f = masked_print_option\n # XXX: Without the following special case masked\n # XXX: would print as \"[--]\", not \"--\". Can we avoid\n # XXX: checks for masked by choosing a different value\n # XXX: for the masked singleton? 2005-01-05 -- sasha\n if self is masked:\n return str(f)\n m = self._mask\n if m is not nomask and m.shape == () and m:\n return str(f)\n # convert to object array to make filled work\n self = self.astype(object)\n else:\n f = self.fill_value()\n res = self.filled(f)\n return str(res)\n\n def __repr__(self):\n \"\"\"Calculate the repr representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n with_mask = \"\"\"\\\narray(data =\n %(data)s,\n mask =\n %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n with_mask1 = \"\"\"\\\narray(data = %(data)s,\n mask = %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n without_mask = \"\"\"array(\n %(data)s)\"\"\"\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n\n n = len(self.shape)\n if self._mask is nomask:\n if n <= 1:\n return without_mask1 % {'data':str(self.filled())}\n return without_mask % {'data':str(self.filled())}\n else:\n if n <= 1:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n if self._mask is nomask:\n return without_mask % {'data':str(self.filled())}\n else:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n\n def __float__(self):\n \"Convert self to float.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python float.'\n return float(self.data.item())\n\n def __int__(self):\n \"Convert self to int.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python int.'\n return int(self.data.item())\n\n def __getitem__(self, i):\n \"Get item described by i. Not a copy as in previous versions.\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i]\n if m is nomask:\n return dout\n mi = m[i]\n if mi.size == 1:\n if mi:\n return masked\n else:\n return dout\n else:\n return masked_array(dout, mi, fill_value=self._fill_value)\n\n def __getslice__(self, i, j):\n \"Get slice described by i, j\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i:j]\n if m is nomask:\n return masked_array(dout, fill_value=self._fill_value)\n else:\n return masked_array(dout, mask = m[i:j], fill_value=self._fill_value)\n\n# --------\n# setitem and setslice notes\n# note that if value is masked, it means to mask those locations.\n# setting a value changes the mask to match the value in those locations.\n\n def __setitem__(self, index, value):\n \"Set item described by index. If value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, 'Cannot alter the masked element.'\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n else:\n self.unshare_mask()\n self._mask[index] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[index] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[index] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = True\n else:\n self.unshare_mask()\n self._mask[index] = m\n\n def __setslice__(self, i, j, value):\n \"Set slice i:j; if value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, \"Cannot alter the 'masked' object.\"\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n self._mask[i:j] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[i:j] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[i:j] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(self._data.shape)\n self._shared_mask = False\n self._mask[i:j] = m\n\n def __nonzero__(self):\n \"\"\"returns true if any element is non-zero or masked\n\n \"\"\"\n # XXX: This changes bool conversion logic from MA.\n # XXX: In MA bool(a) == len(a) != 0, but in numpy\n # XXX: scalars do not have len\n m = self._mask\n d = self._data\n return bool(m is not nomask and m.any()\n or d is not nomask and d.any())\n\n def __len__ (self):\n \"\"\"Return length of first dimension. This is weird but Python's\n slicing behavior depends on it.\"\"\"\n return len(self._data)\n\n def __and__(self, other):\n \"Return bitwise_and\"\n return bitwise_and(self, other)\n\n def __or__(self, other):\n \"Return bitwise_or\"\n return bitwise_or(self, other)\n\n def __xor__(self, other):\n \"Return bitwise_xor\"\n return bitwise_xor(self, other)\n\n __rand__ = __and__\n __ror__ = __or__\n __rxor__ = __xor__\n\n def __abs__(self):\n \"Return absolute(self)\"\n return absolute(self)\n\n def __neg__(self):\n \"Return negative(self)\"\n return negative(self)\n\n def __pos__(self):\n \"Return array(self)\"\n return array(self)\n\n def __add__(self, other):\n \"Return add(self, other)\"\n return add(self, other)\n\n __radd__ = __add__\n\n def __mod__ (self, other):\n \"Return remainder(self, other)\"\n return remainder(self, other)\n\n def __rmod__ (self, other):\n \"Return remainder(other, self)\"\n return remainder(other, self)\n\n def __lshift__ (self, n):\n return left_shift(self, n)\n\n def __rshift__ (self, n):\n return right_shift(self, n)\n\n def __sub__(self, other):\n \"Return subtract(self, other)\"\n return subtract(self, other)\n\n def __rsub__(self, other):\n \"Return subtract(other, self)\"\n return subtract(other, self)\n\n def __mul__(self, other):\n \"Return multiply(self, other)\"\n return multiply(self, other)\n\n __rmul__ = __mul__\n\n def __div__(self, other):\n \"Return divide(self, other)\"\n return divide(self, other)\n\n def __rdiv__(self, other):\n \"Return divide(other, self)\"\n return divide(other, self)\n\n def __truediv__(self, other):\n \"Return divide(self, other)\"\n return true_divide(self, other)\n\n def __rtruediv__(self, other):\n \"Return divide(other, self)\"\n return true_divide(other, self)\n\n def __floordiv__(self, other):\n \"Return divide(self, other)\"\n return floor_divide(self, other)\n\n def __rfloordiv__(self, other):\n \"Return divide(other, self)\"\n return floor_divide(other, self)\n\n def __pow__(self, other, third=None):\n \"Return power(self, other, third)\"\n return power(self, other, third)\n\n def __sqrt__(self):\n \"Return sqrt(self)\"\n return sqrt(self)\n\n def __iadd__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data += f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = add(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __imul__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data *= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = multiply(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __isub__(self, other):\n \"Subtract other from self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data -= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = subtract(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n\n\n def __idiv__(self, other):\n \"Divide self by other in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n mo = getmask(other)\n result = divide(self, masked_array(f, mask=mo))\n self._data = result.data\n dm = result.raw_mask()\n if dm is not self._mask:\n self._mask = dm\n self._shared_mask = 1\n return self\n\n def __eq__(self, other):\n return equal(self,other)\n\n def __ne__(self, other):\n return not_equal(self,other)\n\n def __lt__(self, other):\n return less(self,other)\n\n def __le__(self, other):\n return less_equal(self,other)\n\n def __gt__(self, other):\n return greater(self,other)\n\n def __ge__(self, other):\n return greater_equal(self,other)\n\n def astype (self, tc):\n \"return self as array of given type.\"\n d = self._data.astype(tc)\n return array(d, mask=self._mask)\n\n def byte_swapped(self):\n \"\"\"Returns the raw data field, byte_swapped. Included for consistency\n with numeric but doesn't make sense in this context.\n \"\"\"\n return self._data.byte_swapped()\n\n def compressed (self):\n \"A 1-D array of all the non-masked data.\"\n d = oldnumeric.ravel(self._data)\n if self._mask is nomask:\n return array(d)\n else:\n m = 1 - oldnumeric.ravel(self._mask)\n c = oldnumeric.compress(m, d)\n return array(c, copy=0)\n\n def count (self, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n m = self._mask\n s = self._data.shape\n ls = len(s)\n if m is nomask:\n if ls == 0:\n return 1\n if ls == 1:\n return s[0]\n if axis is None:\n return reduce(lambda x, y:x*y, s)\n else:\n n = s[axis]\n t = list(s)\n del t[axis]\n return ones(t) * n\n if axis is None:\n w = oldnumeric.ravel(m).astype(int)\n n1 = size(w)\n if n1 == 1:\n n2 = w[0]\n else:\n n2 = umath.add.reduce(w)\n return n1 - n2\n else:\n n1 = size(m, axis)\n n2 = sum(m.astype(int), axis)\n return n1 - n2\n\n def dot (self, other):\n \"s.dot(other) = innerproduct(s, other)\"\n return innerproduct(self, other)\n\n def fill_value(self):\n \"Get the current fill value.\"\n return self._fill_value\n\n def filled (self, fill_value=None):\n \"\"\"A numeric array with masked values filled. If fill_value is None,\n use self.fill_value().\n\n If mask is nomask, copy data only if not contiguous.\n Result is always a contiguous, numeric array.\n# Is contiguous really necessary now?\n \"\"\"\n d = self._data\n m = self._mask\n if m is nomask:\n if d.flags['CONTIGUOUS']:\n return d\n else:\n return d.copy()\n else:\n if fill_value is None:\n value = self._fill_value\n else:\n value = fill_value\n\n if self is masked:\n result = numeric.array(value)\n else:\n try:\n result = numeric.array(d, dtype=d.dtype, copy=1)\n result[m] = value\n except (TypeError, AttributeError):\n #ok, can't put that value in here\n value = numeric.array(value, dtype=object)\n d = d.astype(object)\n result = oldnumeric.choose(m, (d, value))\n except IndexError:\n #ok, if scalar\n if d.shape:\n raise\n elif m:\n result = numeric.array(value, dtype=d.dtype)\n else:\n result = d\n return result\n\n def ids (self):\n \"\"\"Return the ids of the data and mask areas\"\"\"\n return (id(self._data), id(self._mask))\n\n def iscontiguous (self):\n \"Is the data contiguous?\"\n return self._data.flags['CONTIGUOUS']\n\n def itemsize(self):\n \"Item size of each data item.\"\n return self._data.itemsize\n\n\n def outer(self, other):\n \"s.outer(other) = outerproduct(s, other)\"\n return outerproduct(self, other)\n\n def put (self, values):\n \"\"\"Set the non-masked entries of self to filled(values).\n No change to mask\n \"\"\"\n iota = numeric.arange(self.size)\n d = self._data\n if self._mask is nomask:\n ind = iota\n else:\n ind = oldnumeric.compress(1 - self._mask, iota)\n d[ind] = filled(values).astype(d.dtype)\n\n def putmask (self, values):\n \"\"\"Set the masked entries of self to filled(values).\n Mask changed to nomask.\n \"\"\"\n d = self._data\n if self._mask is not nomask:\n d[self._mask] = filled(values).astype(d.dtype)\n self._shared_mask = 0\n self._mask = nomask\n\n def ravel (self):\n \"\"\"Return a 1-D view of self.\"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel())\n else:\n return masked_array(self._data.ravel(), self._mask.ravel())\n\n def raw_data (self):\n \"\"\" Obsolete; use data property instead.\n The raw data; portions may be meaningless.\n May be noncontiguous. Expert use only.\"\"\"\n return self._data\n data = property(fget=raw_data,\n doc=\"The data, but values at masked locations are meaningless.\")\n\n def raw_mask (self):\n \"\"\" Obsolete; use mask property instead.\n May be noncontiguous. Expert use only.\n \"\"\"\n return self._mask\n mask = property(fget=raw_mask,\n doc=\"The mask, may be nomask. Values where mask true are meaningless.\")\n\n def reshape (self, *s):\n \"\"\"This array reshaped to shape s\"\"\"\n d = self._data.reshape(*s)\n if self._mask is nomask:\n return masked_array(d)\n else:\n m = self._mask.reshape(*s)\n return masked_array(d, m)\n\n def set_fill_value (self, v=None):\n \"Set the fill value to v. Omit v to restore default.\"\n if v is None:\n v = default_fill_value (self.raw_data())\n self._fill_value = v\n\n def _get_ndim(self):\n return self._data.ndim\n ndim = property(_get_ndim, doc=numeric.ndarray.ndim.__doc__)\n\n def _get_size (self):\n return self._data.size\n size = property(fget=_get_size, doc=\"Number of elements in the array.\")\n## CHECK THIS: signature of numeric.array.size?\n\n def _get_dtype(self):\n return self._data.dtype\n dtype = property(fget=_get_dtype, doc=\"type of the array elements.\")\n\n def item(self):\n \"Return Python scalar if possible.\"\n if self._mask is not nomask:\n m = oldnumeric.ravel(self._mask)\n try:\n if m[0]:\n return masked\n except IndexError:\n return masked\n return self._data.item()\n\n def tolist(self, fill_value=None):\n \"Convert to list\"\n return self.filled(fill_value).tolist()\n\n def tostring(self, fill_value=None):\n \"Convert to string\"\n return self.filled(fill_value).tostring()\n\n def unmask (self):\n \"Replace the mask by nomask if possible.\"\n if self._mask is nomask: return\n m = make_mask(self._mask, flag=1)\n if m is nomask:\n self._mask = nomask\n self._shared_mask = 0\n\n def unshare_mask (self):\n \"If currently sharing mask, make a copy.\"\n if self._shared_mask:\n self._mask = make_mask (self._mask, copy=1, flag=0)\n self._shared_mask = 0\n\n shape = property(_get_shape, _set_shape,\n doc = 'tuple giving the shape of the array')\n\n flat = property(_get_flat, _set_flat,\n doc = 'Access array in flat form.')\n\n real = property(_get_real, _set_real,\n doc = 'Access the real part of the array')\n\n imaginary = property(_get_imaginary, _set_imaginary,\n doc = 'Access the imaginary part of the array')\n\n imag = imaginary\n\n#end class MaskedArray\n\narray = MaskedArray\n\ndef isMaskedArray (x):\n \"Is x a masked array, that is, an instance of MaskedArray?\"\n return isinstance(x, MaskedArray)\n\nisarray = isMaskedArray\nisMA = isMaskedArray #backward compatibility\n\ndef allclose (a, b, fill_value=1, rtol=1.e-5, atol=1.e-8):\n \"\"\" Returns true if all components of a and b are equal\n subject to given tolerances.\n If fill_value is 1, masked values considered equal.\n If fill_value is 0, masked values considered unequal.\n The relative error rtol should be positive and << 1.0\n The absolute error atol comes into play for those elements\n of b that are very small or zero; it says how small a must be also.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a)\n d2 = filled(b)\n x = filled(array(d1, copy=0, mask=m), fill_value).astype(float)\n y = filled(array(d2, copy=0, mask=m), 1).astype(float)\n d = umath.less_equal(umath.absolute(x-y), atol + rtol * umath.absolute(y))\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n\ndef allequal (a, b, fill_value=1):\n \"\"\"\n True if all entries of a and b are equal, using\n fill_value as a truth value where either or both are masked.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n if m is nomask:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n elif fill_value:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n dm = array(d, mask=m, copy=0)\n return oldnumeric.alltrue(oldnumeric.ravel(filled(dm, 1)))\n else:\n return 0\n\ndef masked_values (data, value, rtol=1.e-5, atol=1.e-8, copy=1):\n \"\"\"\n masked_values(data, value, rtol=1.e-5, atol=1.e-8)\n Create a masked array; mask is nomask if possible.\n If copy==0, and otherwise possible, result\n may share data values with original array.\n Let d = filled(data, value). Returns d\n masked where abs(data-value)<= atol + rtol * abs(value)\n if d is of a floating point type. Otherwise returns\n masked_object(d, value, copy)\n \"\"\"\n abs = umath.absolute\n d = filled(data, value)\n if issubclass(d.dtype.type, numeric.floating):\n m = umath.less_equal(abs(d-value), atol+rtol*abs(value))\n m = make_mask(m, flag=1)\n return array(d, mask = m, copy=copy,\n fill_value=value)\n else:\n return masked_object(d, value, copy=copy)\n\ndef masked_object (data, value, copy=1):\n \"Create array masked where exactly data equal to value\"\n d = filled(data, value)\n dm = make_mask(umath.equal(d, value), flag=1)\n return array(d, mask=dm, copy=copy, fill_value=value)\n\ndef arrayrange(start, stop=None, step=1, dtype=None):\n \"\"\"Just like range() except it returns a array whose type can be specified\n by the keyword argument dtype.\n \"\"\"\n return array(numeric.arrayrange(start, stop, step, dtype))\n\narange = arrayrange\n\ndef fromstring (s, t):\n \"Construct a masked array from a string. Result will have no mask.\"\n return masked_array(numeric.fromstring(s, t))\n\ndef left_shift (a, n):\n \"Left shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.left_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.left_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef right_shift (a, n):\n \"Right shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.right_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.right_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef resize (a, new_shape):\n \"\"\"resize(a, new_shape) returns a new array with the specified shape.\n The original array's total size can be any size.\"\"\"\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.resize(m, new_shape)\n result = array(oldnumeric.resize(filled(a), new_shape), mask=m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n \"\"\"\n af = filled(a)\n if isinstance(repeats, types.IntType):\n repeats = tuple([repeats]*(shape(af)[axis]))\n\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.repeat(m, repeats, axis)\n d = oldnumeric.repeat(af, repeats, axis)\n result = masked_array(d, m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef identity(n):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n return array(numeric.identity(n))\n\ndef indices (dimensions, dtype=None):\n \"\"\"indices(dimensions,dtype=None) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n return array(numeric.indices(dimensions, dtype))\n\ndef zeros (shape, dtype=int):\n \"\"\"zeros(n, dtype=int) =\n an array of all zeros of the given length or shape.\"\"\"\n return array(numeric.zeros(shape, dtype))\n\ndef ones (shape, dtype=int):\n \"\"\"ones(n, dtype=int) =\n an array of all ones of the given length or shape.\"\"\"\n return array(numeric.ones(shape, dtype))\n\n\ndef count (a, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n a = masked_array(a)\n return a.count(axis)\n\ndef power (a, b, third=None):\n \"a**b\"\n if third is not None:\n raise MAError, \"3-argument power not supported.\"\n ma = getmask(a)\n mb = getmask(b)\n m = mask_or(ma, mb)\n fa = filled(a, 1)\n fb = filled(b, 1)\n if fb.dtype.char in typecodes[\"Integer\"]:\n return masked_array(umath.power(fa, fb), m)\n md = make_mask(umath.less_equal (fa, 0), flag=1)\n m = mask_or(m, md)\n if m is nomask:\n return masked_array(umath.power(fa, fb))\n else:\n fa = numeric.where(m, 1, fa)\n return masked_array(umath.power(fa, fb), m)\n\ndef masked_array (a, mask=nomask, fill_value=None):\n \"\"\"masked_array(a, mask=nomask) =\n array(a, mask=mask, copy=0, fill_value=fill_value)\n \"\"\"\n return array(a, mask=mask, copy=0, fill_value=fill_value)\n\nsum = add.reduce\nproduct = multiply.reduce\n\ndef average (a, axis=0, weights=None, returned = 0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis.\n If axis is None, average over the entire array\n Inputs can be integer or floating types; result is of type float.\n\n If weights are given, result is sum(a*weights)/(sum(weights)*1.0)\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis.\n\n If returned, return a tuple: the result and the sum of the weights\n or count of values. Results will have the same shape.\n\n masked values in the weights will be set to 0.0\n \"\"\"\n a = masked_array(a)\n mask = a.mask\n ash = a.shape\n if ash == ():\n ash = (1,)\n if axis is None:\n if mask is nomask:\n if weights is None:\n n = add.reduce(a.raw_data().ravel())\n d = reduce(lambda x, y: x * y, ash, 1.0)\n else:\n w = filled(weights, 0.0).ravel()\n n = umath.add.reduce(a.raw_data().ravel() * w)\n d = umath.add.reduce(w)\n del w\n else:\n if weights is None:\n n = add.reduce(a.ravel())\n w = oldnumeric.choose(mask, (1.0, 0.0)).ravel()\n d = umath.add.reduce(w)\n del w\n else:\n w = array(filled(weights, 0.0), float, mask=mask).ravel()\n n = add.reduce(a.ravel() * w)\n d = add.reduce(w)\n del w\n else:\n if mask is nomask:\n if weights is None:\n d = ash[axis] * 1.0\n n = umath.add.reduce(a.raw_data(), axis)\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = numeric.array(w, float, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * ones(ash, float)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w, r\n else:\n raise ValueError, 'average: weights wrong shape.'\n else:\n if weights is None:\n n = add.reduce(a, axis)\n w = numeric.choose(mask, (1.0, 0.0))\n d = umath.add.reduce(w, axis)\n del w\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = array(w, float, mask=mask, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * masked_array(ones(ash, float), mask)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n del w\n #print n, d, repr(mask), repr(weights)\n if n is masked or d is masked: return masked\n result = divide (n, d)\n del n\n\n if isinstance(result, MaskedArray):\n result.unmask()\n if returned:\n if not isinstance(d, MaskedArray):\n d = masked_array(d)\n if not d.shape == result.shape:\n d = ones(result.shape, float) * d\n d.unmask()\n if returned:\n return result, d\n else:\n return result\n\ndef where (condition, x, y):\n \"\"\"where(condition, x, y) is x where condition is nonzero, y otherwise.\n condition must be convertible to an integer array.\n Answer is always the shape of condition.\n The type depends on x and y. It is integer if both x and y are\n the value masked.\n \"\"\"\n fc = filled(not_equal(condition, 0), 0)\n xv = filled(x)\n xm = getmask(x)\n yv = filled(y)\n ym = getmask(y)\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n m = make_mask(mask_or(m, md), copy=0, flag=1)\n return masked_array(d, m)\n\ndef choose (indices, t):\n \"Returns array shaped like indices with elements chosen from t\"\n def fmask (x):\n if x is masked: return 1\n return filled(x)\n def nmask (x):\n if x is masked: return 1\n m = getmask(x)\n if m is nomask: return 0\n return m\n c = filled(indices, 0)\n masks = [nmask(x) for x in t]\n a = [fmask(x) for x in t]\n d = numeric.choose(c, a)\n m = numeric.choose(c, masks)\n m = make_mask(mask_or(m, getmask(indices)), copy=0, flag=1)\n return masked_array(d, m)\n\ndef masked_where(condition, x, copy=1):\n \"\"\"Return x as an array masked where condition is true.\n Also masked where x or condition masked.\n \"\"\"\n cm = filled(condition,1)\n m = mask_or(getmask(x), cm)\n return array(filled(x), copy=copy, mask=m)\n\ndef masked_greater(x, value, copy=1):\n \"masked_greater(x, value) = x masked where x > value\"\n return masked_where(greater(x, value), x, copy)\n\ndef masked_greater_equal(x, value, copy=1):\n \"masked_greater_equal(x, value) = x masked where x >= value\"\n return masked_where(greater_equal(x, value), x, copy)\n\ndef masked_less(x, value, copy=1):\n \"masked_less(x, value) = x masked where x < value\"\n return masked_where(less(x, value), x, copy)\n\ndef masked_less_equal(x, value, copy=1):\n \"masked_less_equal(x, value) = x masked where x <= value\"\n return masked_where(less_equal(x, value), x, copy)\n\ndef masked_not_equal(x, value, copy=1):\n \"masked_not_equal(x, value) = x masked where x != value\"\n d = filled(x, 0)\n c = umath.not_equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_equal(x, value, copy=1):\n \"\"\"masked_equal(x, value) = x masked where x == value\n For floating point consider masked_values(x, value) instead.\n \"\"\"\n d = filled(x, 0)\n c = umath.equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_inside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are inside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_and(umath.less_equal(d, v2), umath.greater_equal(d, v1))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef masked_outside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are outside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_or(umath.less(d, v1), umath.greater(d, v2))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef reshape (a, *newshape):\n \"Copy of a with a new shape.\"\n m = getmask(a)\n d = filled(a).reshape(*newshape)\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.reshape(m, *newshape))\n\ndef ravel (a):\n \"a as one-dimensional, may share data and mask\"\n m = getmask(a)\n d = oldnumeric.ravel(filled(a))\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.ravel(m))\n\ndef concatenate (arrays, axis=0):\n \"Concatenate the arrays along the given axis\"\n d = []\n for x in arrays:\n d.append(filled(x))\n d = numeric.concatenate(d, axis)\n for x in arrays:\n if getmask(x) is not nomask: break\n else:\n return masked_array(d)\n dm = []\n for x in arrays:\n dm.append(getmaskarray(x))\n dm = numeric.concatenate(dm, axis)\n return masked_array(d, mask=dm)\n\ndef swapaxes (a, axis1, axis2):\n m = getmask(a)\n d = masked_array(a).data\n if m is nomask:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2))\n else:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2),\n mask=numeric.swapaxes(m, axis1, axis2),)\n\n\ndef take (a, indices, axis=0):\n \"take(a, indices, axis=0) returns selection of items from a.\"\n m = getmask(a)\n # d = masked_array(a).raw_data()\n d = masked_array(a).data\n if m is nomask:\n return masked_array(numeric.take(d, indices, axis))\n else:\n return masked_array(numeric.take(d, indices, axis),\n mask = numeric.take(m, indices, axis))\n\ndef transpose(a, axes=None):\n \"transpose(a, axes=None) reorder dimensions per tuple axes\"\n m = getmask(a)\n d = filled(a)\n if m is nomask:\n return masked_array(numeric.transpose(d, axes))\n else:\n return masked_array(numeric.transpose(d, axes),\n mask = numeric.transpose(m, axes))\n\n\ndef put(a, indices, values):\n \"\"\"put(a, indices, values) sets storage-indexed locations to corresponding values.\n\n Values and indices are filled if necessary.\n\n \"\"\"\n d = a.raw_data()\n ind = filled(indices)\n v = filled(values)\n numeric.put (d, ind, v)\n m = getmask(a)\n if m is not nomask:\n a.unshare_mask()\n numeric.put(a.raw_mask(), ind, 0)\n\ndef putmask(a, mask, values):\n \"putmask(a, mask, values) sets a where mask is true.\"\n if mask is nomask:\n return\n numeric.putmask(a.raw_data(), mask, values)\n m = getmask(a)\n if m is nomask: return\n a.unshare_mask()\n numeric.putmask(a.raw_mask(), mask, 0)\n\ndef innerproduct(a, b):\n \"\"\"innerproduct(a,b) returns the dot product of two arrays, which has\n shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the\n product of the elements from the last dimensions of a and b.\n Masked elements are replace by zeros.\n \"\"\"\n fa = filled(a, 0)\n fb = filled(b, 0)\n if len(fa.shape) == 0: fa.shape = (1,)\n if len(fb.shape) == 0: fb.shape = (1,)\n return masked_array(numeric.innerproduct(fa, fb))\n\ndef outerproduct(a, b):\n \"\"\"outerproduct(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))\"\"\"\n fa = filled(a, 0).ravel()\n fb = filled(b, 0).ravel()\n d = numeric.outerproduct(fa, fb)\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n return masked_array(d)\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = make_mask(1-numeric.outerproduct(1-ma, 1-mb), copy=0)\n return masked_array(d, m)\n\ndef dot(a, b):\n \"\"\"dot(a,b) returns matrix-multiplication between a and b. The product-sum\n is over the last dimension of a and the second-to-last dimension of b.\n Masked values are replaced by zeros. See also innerproduct.\n \"\"\"\n return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))\n\ndef compress(condition, x, dimension=-1):\n \"\"\"Select those parts of x for which condition is true.\n Masked values in condition are considered false.\n \"\"\"\n c = filled(condition, 0)\n m = getmask(x)\n if m is not nomask:\n m = numeric.compress(c, m, dimension)\n d = numeric.compress(c, filled(x), dimension)\n return masked_array(d, m)\n\nclass _minimum_operation:\n \"Object to calculate minima\"\n def __init__ (self):\n \"\"\"minimum(a, b) or minimum(a)\n In one argument case returns the scalar minimum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amin(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amin(ac.raw_data())\n else:\n return where(less(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.minimum.reduce (t, axis))\n else:\n t = umath.minimum.reduce(filled(target, minimum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.minimum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nminimum = _minimum_operation ()\n\nclass _maximum_operation:\n \"Object to calculate maxima\"\n def __init__ (self):\n \"\"\"maximum(a, b) or maximum(a)\n In one argument case returns the scalar maximum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amax(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amax(ac.raw_data())\n else:\n return where(greater(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.maximum.reduce (t, axis))\n else:\n t = umath.maximum.reduce(filled(target, maximum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.maximum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nmaximum = _maximum_operation ()\n\ndef sort (x, axis = -1, fill_value=None):\n \"\"\"If x does not have a mask, return a masked array formed from the\n result of numeric.sort(x, axis).\n Otherwise, fill x with fill_value. Sort it.\n Set a mask where the result is equal to fill_value.\n Note that this may have unintended consequences if the data contains the\n fill value at a non-masked site.\n\n If fill_value is not given the default fill value for x's type will be\n used.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n d = filled(x, fill_value)\n s = oldnumeric.sort(d, axis)\n if getmask(x) is nomask:\n return masked_array(s)\n return masked_values(s, fill_value, copy=0)\n\ndef diagonal(a, k = 0, axis1=0, axis2=1):\n \"\"\"diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a\"\"\"\n d = oldnumeric.diagonal(filled(a), k, axis1, axis2)\n m = getmask(a)\n if m is nomask:\n return masked_array(d, m)\n else:\n return masked_array(d, oldnumeric.diagonal(m, k, axis1, axis2))\n \ndef trace (a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return diagonal(a, offset, axis1, axis2).sum(dtype=dtype)\n\ndef argsort (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for sorting along given axis.\n if fill_value is None, use get_fill_value(x)\n Returns a numpy array.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argsort(d, axis)\n\ndef argmin (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return indices for minimum values along given axis.\n if fill_value is None, use get_fill_value(x).\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argmin(d, axis)\n\ndef argmax (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for maximum along given axis.\n if fill_value is None, use -get_fill_value(x) if it exists.\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n try:\n fill_value = - fill_value\n except:\n pass\n d = filled(x, fill_value)\n return oldnumeric.argmax(d, axis)\n\ndef fromfunction (f, s):\n \"\"\"apply f to s to create array as in umath.\"\"\"\n return masked_array(numeric.fromfunction(f, s))\n\ndef asarray(data, dtype=None):\n \"\"\"asarray(data, dtype) = array(data, dtype, copy=0)\n \"\"\"\n if isinstance(data, MaskedArray) and \\\n (dtype is None or dtype == data.dtype):\n return data\n return array(data, dtype=dtype, copy=0)\n\n# Add methods to support ndarray interface\n# XXX: I is better to to change the masked_*_operation adaptors\n# XXX: to wrap ndarray methods directly to create ma.array methods.\nfrom types import MethodType\ndef _m(f):\n return MethodType(f, None, array)\ndef not_implemented(*args, **kwds):\n raise NotImplementedError, \"not yet implemented for numpy.ma arrays\"\narray.all = _m(alltrue)\narray.any = _m(sometrue)\narray.argmax = _m(argmax)\narray.argmin = _m(argmin)\narray.argsort = _m(argsort)\narray.base = property(_m(not_implemented))\narray.byteswap = _m(not_implemented)\n\ndef _choose(self, *args):\n return choose(self, args)\narray.choose = _m(_choose)\ndel _choose\n\ndef _clip(self,a_min,a_max):\n return MaskedArray(data = self.data.clip(asarray(a_min).data, \n asarray(a_max).data),\n mask = mask_or(self.mask,\n mask_or(getmask(a_min),getmask(a_max))))\narray.clip = _m(_clip)\n\ndef _compress(self, cond, axis=None):\n return compress(cond, self, axis)\narray.compress = _m(_compress)\ndel _compress\n\narray.conj = array.conjugate = _m(conjugate)\narray.copy = _m(not_implemented)\n\ndef _cumprod(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_or.accumulate(self.mask, axis)\n return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)\narray.cumprod = _m(_cumprod)\n\ndef _cumsum(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_or.accumulate(self.mask, axis)\n return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)\narray.cumsum = _m(_cumsum)\n\narray.diagonal = _m(diagonal)\narray.dump = _m(not_implemented)\narray.dumps = _m(not_implemented)\narray.fill = _m(not_implemented)\narray.flags = property(_m(not_implemented))\narray.flatten = _m(ravel)\narray.getfield = _m(not_implemented)\n\ndef _max(a, axis=None):\n if axis is None:\n return maximum(a)\n else:\n return maximum.reduce(a, axis)\narray.max = _m(_max)\ndel _max\ndef _min(a, axis=None):\n if axis is None:\n return minimum(a)\n else:\n return minimum.reduce(a, axis)\narray.min = _m(_min)\ndel _min\narray.mean = _m(average)\narray.nbytes = property(_m(not_implemented))\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\n\ndef _ptp(a,axis=0):\n return a.max(axis)-a.min(axis)\narray.ptp = _m(_ptp)\narray.repeat = _m(repeat)\narray.resize = _m(resize)\narray.searchsorted = _m(not_implemented)\narray.setfield = _m(not_implemented)\narray.setflags = _m(not_implemented)\narray.sort = _m(not_implemented) # NB: ndarray.sort is inplace\n\ndef _squeeze(self):\n try:\n result = MaskedArray(data = self.data.squeeze(),\n mask = self.mask.squeeze())\n except AttributeError:\n result = _wrapit(self, 'squeeze')\n return result\narray.squeeze = _m(_squeeze) \n\narray.strides = property(_m(not_implemented))\narray.sum = _m(sum)\ndef _swapaxes(self,axis1,axis2):\n return MaskedArray(data = self.data.swapaxes(axis1, axis2),\n mask = self.mask.swapaxes(axis1, axis2))\narray.swapaxes = _m(_swapaxes)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(trace)\narray.transpose = _m(transpose)\n\ndef _var(self,axis=0,dtype=None):\n if axis is None:\n return asarray(self.compressed()).var()\n a = self.swapaxes(axis,0)\n a = a - a.mean(axis=0)\n a *= a\n a /= (a.count(axis=0)-1)\n return a.swapaxes(0,axis).sum(axis)\ndef _std(self,axis=0,dtype=None):\n return (self.var(axis,dtype))**0.5\narray.var = _m(_var)\narray.std = _m(_std)\n\narray.view = _m(not_implemented)\narray.round = _m(around)\ndel _m, MethodType, not_implemented\n\n\nmasked = MaskedArray(0, int, mask=1)\n", + "source_code_before": "\"\"\"MA: a facility for dealing with missing observations\nMA is generally used as a numpy.array look-alike.\nby Paul F. Dubois.\n\nCopyright 1999, 2000, 2001 Regents of the University of California.\nReleased for unlimited redistribution.\nAdapted for numpy_core 2005 by Travis Oliphant and\n(mainly) Paul Dubois.\n\"\"\"\nimport types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import bool_\nimport numeric\nimport warnings\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType = bool_\nnomask = MaskType(0)\ndivide_tolerance = 1.e-35\n\nclass MAError (Exception):\n def __init__ (self, args=None):\n \"Create an exception\"\n self.args = args\n def __str__(self):\n \"Calculate the string representation\"\n return str(self.args)\n __repr__ = __str__\n\nclass _MaskedPrintOption:\n \"One instance of this class, masked_print_option, is created.\"\n def __init__ (self, display):\n \"Create the masked print option object.\"\n self.set_display(display)\n self._enabled = 1\n\n def display (self):\n \"Show what prints for masked values.\"\n return self._display\n\n def set_display (self, s):\n \"set_display(s) sets what prints for masked values.\"\n self._display = s\n\n def enabled (self):\n \"Is the use of the display value enabled?\"\n return self._enabled\n\n def enable(self, flag=1):\n \"Set the enabling flag to flag.\"\n self._enabled = flag\n\n def __str__ (self):\n return str(self._display)\n\n __repr__ = __str__\n\n#if you single index into a masked location you get this object.\nmasked_print_option = _MaskedPrintOption('--')\n\n# Use single element arrays or scalars.\ndefault_real_fill_value = 1.e20\ndefault_complex_fill_value = 1.e20 + 0.0j\ndefault_character_fill_value = '-'\ndefault_integer_fill_value = 999999\ndefault_object_fill_value = '?'\n\ndef default_fill_value (obj):\n \"Function to calculate default fill value for an object.\"\n if isinstance(obj, types.FloatType):\n return default_real_fill_value\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return default_integer_fill_value\n elif isinstance(obj, types.StringType):\n return default_character_fill_value\n elif isinstance(obj, types.ComplexType):\n return default_complex_fill_value\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return default_real_fill_value\n if x in typecodes['Integer']:\n return default_integer_fill_value\n if x in typecodes['Complex']:\n return default_complex_fill_value\n if x in typecodes['Character']:\n return default_character_fill_value\n if x in typecodes['UnsignedInteger']:\n return umath.absolute(default_integer_fill_value)\n return default_object_fill_value\n else:\n return default_object_fill_value\n\ndef minimum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking minima.\"\n if isinstance(obj, types.FloatType):\n return numeric.inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return numeric.inf\n if x in typecodes['Integer']:\n return sys.maxint\n if x in typecodes['UnsignedInteger']:\n return sys.maxint\n else:\n raise TypeError, 'Unsuitable type for calculating minimum.'\n\ndef maximum_fill_value (obj):\n \"Function to calculate default fill value suitable for taking maxima.\"\n if isinstance(obj, types.FloatType):\n return -inf\n elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):\n return -sys.maxint\n elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):\n x = obj.dtype.char\n if x in typecodes['Float']:\n return -inf\n if x in typecodes['Integer']:\n return -sys.maxint\n if x in typecodes['UnsignedInteger']:\n return 0\n else:\n raise TypeError, 'Unsuitable type for calculating maximum.'\n\ndef set_fill_value (a, fill_value):\n \"Set fill value of a if it is a masked array.\"\n if isMaskedArray(a):\n a.set_fill_value (fill_value)\n\ndef getmask (a):\n \"\"\"Mask of values in a; could be nomask.\n Returns nomask if a is not a masked array.\n To get an array for sure use getmaskarray.\"\"\"\n if isinstance(a, MaskedArray):\n return a.raw_mask()\n else:\n return nomask\n\ndef getmaskarray (a):\n \"\"\"Mask of values in a; an array of zeros if mask is nomask\n or not a masked array, and is a byte-sized integer.\n Do not try to add up entries, for example.\n \"\"\"\n m = getmask(a)\n if m is nomask:\n return make_mask_none(shape(a))\n else:\n return m\n\ndef is_mask (m):\n \"\"\"Is m a legal mask? Does not check contents, only type.\n \"\"\"\n try:\n return m.dtype.type is MaskType\n except AttributeError:\n return False\n\ndef make_mask (m, copy=0, flag=0):\n \"\"\"make_mask(m, copy=0, flag=0)\n return m as a mask, creating a copy if necessary or requested.\n Can accept any sequence of integers or nomask. Does not check\n that contents must be 0s and 1s.\n if flag, return nomask if m contains no true elements.\n \"\"\"\n if m is nomask:\n return nomask\n elif isinstance(m, ndarray):\n if m.dtype.type is MaskType:\n if copy:\n result = numeric.array(m, dtype=MaskType, copy=copy)\n else:\n result = m\n else:\n result = m.astype(MaskType)\n else:\n result = filled(m, True).astype(MaskType)\n\n if flag and not oldnumeric.sometrue(oldnumeric.ravel(result)):\n return nomask\n else:\n return result\n\ndef make_mask_none (s):\n \"Return a mask of all zeros of shape s.\"\n result = numeric.zeros(s, dtype=MaskType)\n result.shape = s\n return result\n\ndef mask_or (m1, m2):\n \"\"\"Logical or of the mask candidates m1 and m2, treating nomask as false.\n Result may equal m1 or m2 if the other is nomask.\n \"\"\"\n if m1 is nomask: return make_mask(m2)\n if m2 is nomask: return make_mask(m1)\n if m1 is m2 and is_mask(m1): return m1\n return make_mask(umath.logical_or(m1, m2))\n\ndef filled (a, value = None):\n \"\"\"a as a contiguous numeric array with any masked areas replaced by value\n if value is None or the special element \"masked\", get_fill_value(a)\n is used instead.\n\n If a is already a contiguous numeric array, a itself is returned.\n\n filled(a) can be used to be sure that the result is numeric when\n passing an object a to other software ignorant of MA, in particular to\n numeric itself.\n \"\"\"\n if isinstance(a, MaskedArray):\n return a.filled(value)\n elif isinstance(a, ndarray) and a.flags['CONTIGUOUS']:\n return a\n elif isinstance(a, types.DictType):\n return numeric.array(a, 'O')\n else:\n return numeric.array(a)\n\ndef get_fill_value (a):\n \"\"\"\n The fill value of a, if it has one; otherwise, the default fill value\n for that type.\n \"\"\"\n if isMaskedArray(a):\n result = a.fill_value()\n else:\n result = default_fill_value(a)\n return result\n\ndef common_fill_value (a, b):\n \"The common fill_value of a and b, if there is one, or None\"\n t1 = get_fill_value(a)\n t2 = get_fill_value(b)\n if t1 == t2: return t1\n return None\n\n# Domain functions return 1 where the argument(s) are not in the domain.\nclass domain_check_interval:\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n def __init__(self, y1, y2):\n \"domain_check_interval(a,b)(x) = true where x < a or y > b\"\n self.y1 = y1\n self.y2 = y2\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.logical_or(umath.greater (x, self.y2),\n umath.less(x, self.y1)\n )\n\nclass domain_tan:\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n def __init__(self, eps):\n \"domain_tan(eps) = true where abs(cos(x)) < eps)\"\n self.eps = eps\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less(umath.absolute(umath.cos(x)), self.eps)\n\nclass domain_greater:\n \"domain_greater(v)(x) = true where x <= v\"\n def __init__(self, critical_value):\n \"domain_greater(v)(x) = true where x <= v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less_equal (x, self.critical_value)\n\nclass domain_greater_equal:\n \"domain_greater_equal(v)(x) = true where x < v\"\n def __init__(self, critical_value):\n \"domain_greater_equal(v)(x) = true where x < v\"\n self.critical_value = critical_value\n\n def __call__ (self, x):\n \"Execute the call behavior.\"\n return umath.less (x, self.critical_value)\n\nclass masked_unary_operation:\n def __init__ (self, aufunc, fill=0, domain=None):\n \"\"\" masked_unary_operation(aufunc, fill=0, domain=None)\n aufunc(fill) must be defined\n self(x) returns aufunc(x)\n with masked values where domain(x) is true or getmask(x) is true.\n \"\"\"\n self.f = aufunc\n self.fill = fill\n self.domain = domain\n self.__doc__ = getattr(aufunc, \"__doc__\", str(aufunc))\n self.__name__ = getattr(aufunc, \"__name__\", str(aufunc))\n ufunc_domain[aufunc] = domain\n ufunc_fills[aufunc] = fill,\n\n def __call__ (self, a, *args, **kwargs):\n \"Execute the call behavior.\"\n# numeric tries to return scalars rather than arrays when given scalars.\n m = getmask(a)\n d1 = filled(a, self.fill)\n if self.domain is not None:\n m = mask_or(m, self.domain(d1))\n result = self.f(d1, *args, **kwargs)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\n\nclass domain_safe_divide:\n def __init__ (self, tolerance=divide_tolerance):\n self.tolerance = tolerance\n def __call__ (self, a, b):\n return umath.absolute(a) * self.tolerance >= umath.absolute(b)\n\nclass domained_binary_operation:\n \"\"\"Binary operations that have a domain, like divide. These are complicated\n so they are a separate class. They have no reduce, outer or accumulate.\n \"\"\"\n def __init__ (self, abfunc, domain, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.domain = domain\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n self.__name__ = getattr(abfunc, \"__name__\", str(abfunc))\n ufunc_domain[abfunc] = domain\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__(self, a, b):\n \"Execute the call behavior.\"\n ma = getmask(a)\n mb = getmask(b)\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n t = self.domain(d1, d2)\n\n if oldnumeric.sometrue(t, None):\n d2 = where(t, self.filly, d2)\n mb = mask_or(mb, t)\n m = mask_or(ma, mb)\n result = self.f(d1, d2)\n return masked_array(result, m)\n\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nclass masked_binary_operation:\n def __init__ (self, abfunc, fillx=0, filly=0):\n \"\"\"abfunc(fillx, filly) must be defined.\n abfunc(x, filly) = x for all x to enable reduce.\n \"\"\"\n self.f = abfunc\n self.fillx = fillx\n self.filly = filly\n self.__doc__ = getattr(abfunc, \"__doc__\", str(abfunc))\n ufunc_domain[abfunc] = None\n ufunc_fills[abfunc] = fillx, filly\n\n def __call__ (self, a, b, *args, **kwargs):\n \"Execute the call behavior.\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a, self.fillx)\n d2 = filled(b, self.filly)\n result = self.f(d1, d2, *args, **kwargs)\n return masked_array(result, m)\n\n def reduce (self, target, axis=0, dtype=None):\n \"\"\"Reduce target along the given axis with this function.\"\"\"\n m = getmask(target)\n t = filled(target, self.filly)\n if t.shape == ():\n t = t.reshape(1)\n if m is not nomask:\n m = make_mask(m, copy=1)\n m.shape = (1,)\n if m is nomask:\n return masked_array (self.f.reduce (t, axis))\n else:\n t = masked_array (t, m)\n # XXX: \"or t.dtype\" below is a workaround for what appears\n # XXX: to be a bug in reduce.\n t = self.f.reduce(filled(t, self.filly), axis, dtype=dtype or t.dtype)\n m = umath.logical_and.reduce(m, axis)\n if isinstance(t, ndarray):\n return masked_array(t, m, get_fill_value(target))\n elif m:\n return masked\n else:\n return t\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = self.f.outer(filled(a, self.fillx), filled(b, self.filly))\n return masked_array(d, m)\n\n def accumulate (self, target, axis=0):\n \"\"\"Accumulate target along axis after filling with y fill value.\"\"\"\n t = filled(target, self.filly)\n return masked_array (self.f.accumulate (t, axis))\n def __str__ (self):\n return \"Masked version of \" + str(self.f)\n\nsqrt = masked_unary_operation(umath.sqrt, 0.0, domain_greater_equal(0.0))\nlog = masked_unary_operation(umath.log, 1.0, domain_greater(0.0))\nlog10 = masked_unary_operation(umath.log10, 1.0, domain_greater(0.0))\nexp = masked_unary_operation(umath.exp)\nconjugate = masked_unary_operation(umath.conjugate)\nsin = masked_unary_operation(umath.sin)\ncos = masked_unary_operation(umath.cos)\ntan = masked_unary_operation(umath.tan, 0.0, domain_tan(1.e-35))\narcsin = masked_unary_operation(umath.arcsin, 0.0, domain_check_interval(-1.0, 1.0))\narccos = masked_unary_operation(umath.arccos, 0.0, domain_check_interval(-1.0, 1.0))\narctan = masked_unary_operation(umath.arctan)\n# Missing from numeric\narcsinh = masked_unary_operation(umath.arcsinh)\narccosh = masked_unary_operation(umath.arccosh, 1.0, domain_greater_equal(1.0))\narctanh = masked_unary_operation(umath.arctanh, 0.0, domain_check_interval(-1.0+1e-15, 1.0-1e-15))\nsinh = masked_unary_operation(umath.sinh)\ncosh = masked_unary_operation(umath.cosh)\ntanh = masked_unary_operation(umath.tanh)\nabsolute = masked_unary_operation(umath.absolute)\nfabs = masked_unary_operation(umath.fabs)\nnegative = masked_unary_operation(umath.negative)\n\ndef nonzero(a):\n \"\"\"returns the indices of the elements of a which are not zero and not masked\n\n a must be 1d\n \"\"\"\n return asarray(filled(a, 0).nonzero())\n\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nlogical_not = masked_unary_operation(umath.logical_not)\n\nadd = masked_binary_operation(umath.add)\nsubtract = masked_binary_operation(umath.subtract)\nsubtract.reduce = None\nmultiply = masked_binary_operation(umath.multiply, 1, 1)\ndivide = domained_binary_operation(umath.divide, domain_safe_divide(), 0, 1)\ntrue_divide = domained_binary_operation(umath.true_divide, domain_safe_divide(), 0, 1)\nfloor_divide = domained_binary_operation(umath.floor_divide, domain_safe_divide(), 0, 1)\nremainder = domained_binary_operation(umath.remainder, domain_safe_divide(), 0, 1)\nfmod = domained_binary_operation(umath.fmod, domain_safe_divide(), 0, 1)\nhypot = masked_binary_operation(umath.hypot)\narctan2 = masked_binary_operation(umath.arctan2, 0.0, 1.0)\narctan2.reduce = None\nequal = masked_binary_operation(umath.equal)\nequal.reduce = None\nnot_equal = masked_binary_operation(umath.not_equal)\nnot_equal.reduce = None\nless_equal = masked_binary_operation(umath.less_equal)\nless_equal.reduce = None\ngreater_equal = masked_binary_operation(umath.greater_equal)\ngreater_equal.reduce = None\nless = masked_binary_operation(umath.less)\nless.reduce = None\ngreater = masked_binary_operation(umath.greater)\ngreater.reduce = None\nlogical_and = masked_binary_operation(umath.logical_and)\nalltrue = masked_binary_operation(umath.logical_and, 1, 1).reduce\nlogical_or = masked_binary_operation(umath.logical_or)\nsometrue = logical_or.reduce\nlogical_xor = masked_binary_operation(umath.logical_xor)\nbitwise_and = masked_binary_operation(umath.bitwise_and)\nbitwise_or = masked_binary_operation(umath.bitwise_or)\nbitwise_xor = masked_binary_operation(umath.bitwise_xor)\n\ndef rank (object):\n return oldnumeric.rank(filled(object))\n\ndef shape (object):\n return oldnumeric.shape(filled(object))\n\ndef size (object, axis=None):\n return oldnumeric.size(filled(object), axis)\n\nclass MaskedArray (object):\n \"\"\"Arrays with possibly masked values.\n Masked values of 1 exclude the corresponding element from\n any computation.\n\n Construction:\n x = array(data, dtype=None, copy=True, order=False,\n mask = nomask, fill_value=None)\n\n If copy=False, every effort is made not to copy the data:\n If data is a MaskedArray, and argument mask=nomask,\n then the candidate data is data.data and the\n mask used is data.mask. If data is a numeric array,\n it is used as the candidate raw data.\n If dtype.char is not None and\n is != data.dtype.char then a data copy is required.\n Otherwise, the candidate is used.\n\n If a data copy is required, raw data stored is the result of:\n numeric.array(data, dtype=dtype.char, copy=copy)\n\n If mask is nomask there are no masked values. Otherwise mask must\n be convertible to an array of booleans with the same shape as x.\n\n fill_value is used to fill in masked values when necessary,\n such as when printing and in method/function filled().\n The fill_value is not used for computation within this module.\n \"\"\"\n __array_priority__ = 10.1\n def __init__(self, data, dtype=None, copy=True, order=False,\n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None)\n If data already a numeric array, its dtype becomes the default value of dtype.\n \"\"\"\n if dtype is None:\n tc = None\n else:\n tc = numeric.dtype(dtype)\n need_data_copied = copy\n if isinstance(data, MaskedArray):\n c = data.data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n if mask is nomask:\n mask = data.mask\n elif mask is not nomask: #attempting to change the mask\n need_data_copied = True\n\n elif isinstance(data, ndarray):\n c = data\n if tc is None:\n tc = c.dtype\n elif tc != c.dtype:\n need_data_copied = True\n else:\n need_data_copied = False #because I'll do it now\n c = numeric.array(data, dtype=tc, copy=True, order=order)\n tc = c.dtype\n\n if need_data_copied:\n if tc == c.dtype:\n self._data = numeric.array(c, dtype=tc, copy=True, order=order)\n else:\n self._data = c.astype(tc)\n else:\n self._data = c\n\n if mask is nomask:\n self._mask = nomask\n self._shared_mask = 0\n else:\n self._mask = make_mask (mask)\n if self._mask is nomask:\n self._shared_mask = 0\n else:\n self._shared_mask = (self._mask is mask)\n nm = size(self._mask)\n nd = size(self._data)\n if nm != nd:\n if nm == 1:\n self._mask = oldnumeric.resize(self._mask, self._data.shape)\n self._shared_mask = 0\n elif nd == 1:\n self._data = oldnumeric.resize(self._data, self._mask.shape)\n self._data.shape = self._mask.shape\n else:\n raise MAError, \"Mask and data not compatible.\"\n elif nm == 1 and shape(self._mask) != shape(self._data):\n self.unshare_mask()\n self._mask.shape = self._data.shape\n\n self.set_fill_value(fill_value)\n\n def __array__ (self, t=None, context=None):\n \"Special hook for numeric. Converts to numeric if possible.\"\n if self._mask is not nomask:\n if oldnumeric.ravel(self._mask).any():\n if context is None:\n warnings.warn(\"Cannot automatically convert masked array to \"\\\n \"numeric because data\\n is masked in one or \"\\\n \"more locations.\");\n return self._data\n #raise MAError, \\\n # \"\"\"Cannot automatically convert masked array to numeric because data\n # is masked in one or more locations.\n # \"\"\"\n else:\n func, args, i = context\n fills = ufunc_fills.get(func)\n if fills is None:\n raise MAError, \"%s not known to ma\" % func\n return self.filled(fills[i])\n else: # Mask is all false\n # Optimize to avoid future invocations of this section.\n self._mask = nomask\n self._shared_mask = 0\n if t:\n return self._data.astype(t)\n else:\n return self._data\n\n def __array_wrap__ (self, array, context):\n \"\"\"Special hook for ufuncs.\n\n Wraps the numpy array and sets the mask according to\n context.\n \"\"\"\n func, args = context[:2]\n domain = ufunc_domain[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[getattr(a, '_data', a)\n for a in args]))\n if m is not nomask:\n try:\n shape = array.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = reduce(mask_or, [getmaskarray(a) for a in args])\n\n return MaskedArray(array, copy=False, mask=m)\n\n def _get_shape(self):\n \"Return the current shape.\"\n return self._data.shape\n\n def _set_shape (self, newshape):\n \"Set the array's shape.\"\n self._data.shape = newshape\n if self._mask is not nomask:\n self._mask = self._mask.copy()\n self._mask.shape = newshape\n\n def _get_flat(self):\n \"\"\"Calculate the flat value.\n \"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel(), mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.ravel(),\n mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_flat (self, value):\n \"x.flat = value\"\n y = self.ravel()\n y[:] = value\n\n def _get_real(self):\n \"Get the real part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.real, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.real, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_real (self, value):\n \"x.real = value\"\n y = self.real\n y[...] = value\n\n def _get_imaginary(self):\n \"Get the imaginary part of a complex array.\"\n if self._mask is nomask:\n return masked_array(self._data.imag, mask=nomask,\n fill_value = self.fill_value())\n else:\n return masked_array(self._data.imag, mask=self._mask.ravel(),\n fill_value = self.fill_value())\n\n def _set_imaginary (self, value):\n \"x.imaginary = value\"\n y = self.imaginary\n y[...] = value\n\n def __str__(self):\n \"\"\"Calculate the str representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n if masked_print_option.enabled():\n f = masked_print_option\n # XXX: Without the following special case masked\n # XXX: would print as \"[--]\", not \"--\". Can we avoid\n # XXX: checks for masked by choosing a different value\n # XXX: for the masked singleton? 2005-01-05 -- sasha\n if self is masked:\n return str(f)\n m = self._mask\n if m is not nomask and m.shape == () and m:\n return str(f)\n # convert to object array to make filled work\n self = self.astype(object)\n else:\n f = self.fill_value()\n res = self.filled(f)\n return str(res)\n\n def __repr__(self):\n \"\"\"Calculate the repr representation, using masked for fill if\n it is enabled. Otherwise fill with fill value.\n \"\"\"\n with_mask = \"\"\"\\\narray(data =\n %(data)s,\n mask =\n %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n with_mask1 = \"\"\"\\\narray(data = %(data)s,\n mask = %(mask)s,\n fill_value=%(fill)s)\n\"\"\"\n without_mask = \"\"\"array(\n %(data)s)\"\"\"\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n\n n = len(self.shape)\n if self._mask is nomask:\n if n <= 1:\n return without_mask1 % {'data':str(self.filled())}\n return without_mask % {'data':str(self.filled())}\n else:\n if n <= 1:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n without_mask1 = \"\"\"array(%(data)s)\"\"\"\n if self._mask is nomask:\n return without_mask % {'data':str(self.filled())}\n else:\n return with_mask % {\n 'data': str(self.filled()),\n 'mask': str(self._mask),\n 'fill': str(self.fill_value())\n }\n\n def __float__(self):\n \"Convert self to float.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python float.'\n return float(self.data.item())\n\n def __int__(self):\n \"Convert self to int.\"\n self.unmask()\n if self._mask is not nomask:\n raise MAError, 'Cannot convert masked element to a Python int.'\n return int(self.data.item())\n\n def __getitem__(self, i):\n \"Get item described by i. Not a copy as in previous versions.\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i]\n if m is nomask:\n return dout\n mi = m[i]\n if mi.size == 1:\n if mi:\n return masked\n else:\n return dout\n else:\n return masked_array(dout, mi, fill_value=self._fill_value)\n\n def __getslice__(self, i, j):\n \"Get slice described by i, j\"\n self.unshare_mask()\n m = self._mask\n dout = self._data[i:j]\n if m is nomask:\n return masked_array(dout, fill_value=self._fill_value)\n else:\n return masked_array(dout, mask = m[i:j], fill_value=self._fill_value)\n\n# --------\n# setitem and setslice notes\n# note that if value is masked, it means to mask those locations.\n# setting a value changes the mask to match the value in those locations.\n\n def __setitem__(self, index, value):\n \"Set item described by index. If value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, 'Cannot alter the masked element.'\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n else:\n self.unshare_mask()\n self._mask[index] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[index] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[index] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = True\n else:\n self.unshare_mask()\n self._mask[index] = m\n\n def __setslice__(self, i, j, value):\n \"Set slice i:j; if value is masked, mask those locations.\"\n d = self._data\n if self is masked:\n raise MAError, \"Cannot alter the 'masked' object.\"\n if value is masked:\n if self._mask is nomask:\n self._mask = make_mask_none(d.shape)\n self._shared_mask = False\n self._mask[i:j] = True\n return\n m = getmask(value)\n value = filled(value).astype(d.dtype)\n d[i:j] = value\n if m is nomask:\n if self._mask is not nomask:\n self.unshare_mask()\n self._mask[i:j] = False\n else:\n if self._mask is nomask:\n self._mask = make_mask_none(self._data.shape)\n self._shared_mask = False\n self._mask[i:j] = m\n\n def __nonzero__(self):\n \"\"\"returns true if any element is non-zero or masked\n\n \"\"\"\n # XXX: This changes bool conversion logic from MA.\n # XXX: In MA bool(a) == len(a) != 0, but in numpy\n # XXX: scalars do not have len\n m = self._mask\n d = self._data\n return bool(m is not nomask and m.any()\n or d is not nomask and d.any())\n\n def __len__ (self):\n \"\"\"Return length of first dimension. This is weird but Python's\n slicing behavior depends on it.\"\"\"\n return len(self._data)\n\n def __and__(self, other):\n \"Return bitwise_and\"\n return bitwise_and(self, other)\n\n def __or__(self, other):\n \"Return bitwise_or\"\n return bitwise_or(self, other)\n\n def __xor__(self, other):\n \"Return bitwise_xor\"\n return bitwise_xor(self, other)\n\n __rand__ = __and__\n __ror__ = __or__\n __rxor__ = __xor__\n\n def __abs__(self):\n \"Return absolute(self)\"\n return absolute(self)\n\n def __neg__(self):\n \"Return negative(self)\"\n return negative(self)\n\n def __pos__(self):\n \"Return array(self)\"\n return array(self)\n\n def __add__(self, other):\n \"Return add(self, other)\"\n return add(self, other)\n\n __radd__ = __add__\n\n def __mod__ (self, other):\n \"Return remainder(self, other)\"\n return remainder(self, other)\n\n def __rmod__ (self, other):\n \"Return remainder(other, self)\"\n return remainder(other, self)\n\n def __lshift__ (self, n):\n return left_shift(self, n)\n\n def __rshift__ (self, n):\n return right_shift(self, n)\n\n def __sub__(self, other):\n \"Return subtract(self, other)\"\n return subtract(self, other)\n\n def __rsub__(self, other):\n \"Return subtract(other, self)\"\n return subtract(other, self)\n\n def __mul__(self, other):\n \"Return multiply(self, other)\"\n return multiply(self, other)\n\n __rmul__ = __mul__\n\n def __div__(self, other):\n \"Return divide(self, other)\"\n return divide(self, other)\n\n def __rdiv__(self, other):\n \"Return divide(other, self)\"\n return divide(other, self)\n\n def __truediv__(self, other):\n \"Return divide(self, other)\"\n return true_divide(self, other)\n\n def __rtruediv__(self, other):\n \"Return divide(other, self)\"\n return true_divide(other, self)\n\n def __floordiv__(self, other):\n \"Return divide(self, other)\"\n return floor_divide(self, other)\n\n def __rfloordiv__(self, other):\n \"Return divide(other, self)\"\n return floor_divide(other, self)\n\n def __pow__(self, other, third=None):\n \"Return power(self, other, third)\"\n return power(self, other, third)\n\n def __sqrt__(self):\n \"Return sqrt(self)\"\n return sqrt(self)\n\n def __iadd__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data += f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = add(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __imul__(self, other):\n \"Add other to self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data *= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = multiply(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n def __isub__(self, other):\n \"Subtract other from self in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n\n if self._mask is nomask:\n self._data -= f\n m = getmask(other)\n self._mask = m\n self._shared_mask = m is not nomask\n else:\n result = subtract(self, masked_array(f, mask=getmask(other)))\n self._data = result.data\n self._mask = result.mask\n self._shared_mask = 1\n return self\n\n\n\n def __idiv__(self, other):\n \"Divide self by other in place.\"\n t = self._data.dtype.char\n f = filled(other, 0)\n t1 = f.dtype.char\n if t == t1:\n pass\n elif t in typecodes['Integer']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Float']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n elif t in typecodes['Complex']:\n if t1 in typecodes['Integer']:\n f = f.astype(t)\n elif t1 in typecodes['Float']:\n f = f.astype(t)\n elif t1 in typecodes['Complex']:\n f = f.astype(t)\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n else:\n raise TypeError, 'Incorrect type for in-place operation.'\n mo = getmask(other)\n result = divide(self, masked_array(f, mask=mo))\n self._data = result.data\n dm = result.raw_mask()\n if dm is not self._mask:\n self._mask = dm\n self._shared_mask = 1\n return self\n\n def __eq__(self, other):\n return equal(self,other)\n\n def __ne__(self, other):\n return not_equal(self,other)\n\n def __lt__(self, other):\n return less(self,other)\n\n def __le__(self, other):\n return less_equal(self,other)\n\n def __gt__(self, other):\n return greater(self,other)\n\n def __ge__(self, other):\n return greater_equal(self,other)\n\n def astype (self, tc):\n \"return self as array of given type.\"\n d = self._data.astype(tc)\n return array(d, mask=self._mask)\n\n def byte_swapped(self):\n \"\"\"Returns the raw data field, byte_swapped. Included for consistency\n with numeric but doesn't make sense in this context.\n \"\"\"\n return self._data.byte_swapped()\n\n def compressed (self):\n \"A 1-D array of all the non-masked data.\"\n d = oldnumeric.ravel(self._data)\n if self._mask is nomask:\n return array(d)\n else:\n m = 1 - oldnumeric.ravel(self._mask)\n c = oldnumeric.compress(m, d)\n return array(c, copy=0)\n\n def count (self, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n m = self._mask\n s = self._data.shape\n ls = len(s)\n if m is nomask:\n if ls == 0:\n return 1\n if ls == 1:\n return s[0]\n if axis is None:\n return reduce(lambda x, y:x*y, s)\n else:\n n = s[axis]\n t = list(s)\n del t[axis]\n return ones(t) * n\n if axis is None:\n w = oldnumeric.ravel(m).astype(int)\n n1 = size(w)\n if n1 == 1:\n n2 = w[0]\n else:\n n2 = umath.add.reduce(w)\n return n1 - n2\n else:\n n1 = size(m, axis)\n n2 = sum(m.astype(int), axis)\n return n1 - n2\n\n def dot (self, other):\n \"s.dot(other) = innerproduct(s, other)\"\n return innerproduct(self, other)\n\n def fill_value(self):\n \"Get the current fill value.\"\n return self._fill_value\n\n def filled (self, fill_value=None):\n \"\"\"A numeric array with masked values filled. If fill_value is None,\n use self.fill_value().\n\n If mask is nomask, copy data only if not contiguous.\n Result is always a contiguous, numeric array.\n# Is contiguous really necessary now?\n \"\"\"\n d = self._data\n m = self._mask\n if m is nomask:\n if d.flags['CONTIGUOUS']:\n return d\n else:\n return d.copy()\n else:\n if fill_value is None:\n value = self._fill_value\n else:\n value = fill_value\n\n if self is masked:\n result = numeric.array(value)\n else:\n try:\n result = numeric.array(d, dtype=d.dtype, copy=1)\n result[m] = value\n except (TypeError, AttributeError):\n #ok, can't put that value in here\n value = numeric.array(value, dtype=object)\n d = d.astype(object)\n result = oldnumeric.choose(m, (d, value))\n except IndexError:\n #ok, if scalar\n if d.shape:\n raise\n elif m:\n result = numeric.array(value, dtype=d.dtype)\n else:\n result = d\n return result\n\n def ids (self):\n \"\"\"Return the ids of the data and mask areas\"\"\"\n return (id(self._data), id(self._mask))\n\n def iscontiguous (self):\n \"Is the data contiguous?\"\n return self._data.flags['CONTIGUOUS']\n\n def itemsize(self):\n \"Item size of each data item.\"\n return self._data.itemsize\n\n\n def outer(self, other):\n \"s.outer(other) = outerproduct(s, other)\"\n return outerproduct(self, other)\n\n def put (self, values):\n \"\"\"Set the non-masked entries of self to filled(values).\n No change to mask\n \"\"\"\n iota = numeric.arange(self.size)\n d = self._data\n if self._mask is nomask:\n ind = iota\n else:\n ind = oldnumeric.compress(1 - self._mask, iota)\n d[ind] = filled(values).astype(d.dtype)\n\n def putmask (self, values):\n \"\"\"Set the masked entries of self to filled(values).\n Mask changed to nomask.\n \"\"\"\n d = self._data\n if self._mask is not nomask:\n d[self._mask] = filled(values).astype(d.dtype)\n self._shared_mask = 0\n self._mask = nomask\n\n def ravel (self):\n \"\"\"Return a 1-D view of self.\"\"\"\n if self._mask is nomask:\n return masked_array(self._data.ravel())\n else:\n return masked_array(self._data.ravel(), self._mask.ravel())\n\n def raw_data (self):\n \"\"\" Obsolete; use data property instead.\n The raw data; portions may be meaningless.\n May be noncontiguous. Expert use only.\"\"\"\n return self._data\n data = property(fget=raw_data,\n doc=\"The data, but values at masked locations are meaningless.\")\n\n def raw_mask (self):\n \"\"\" Obsolete; use mask property instead.\n May be noncontiguous. Expert use only.\n \"\"\"\n return self._mask\n mask = property(fget=raw_mask,\n doc=\"The mask, may be nomask. Values where mask true are meaningless.\")\n\n def reshape (self, *s):\n \"\"\"This array reshaped to shape s\"\"\"\n d = self._data.reshape(*s)\n if self._mask is nomask:\n return masked_array(d)\n else:\n m = self._mask.reshape(*s)\n return masked_array(d, m)\n\n def set_fill_value (self, v=None):\n \"Set the fill value to v. Omit v to restore default.\"\n if v is None:\n v = default_fill_value (self.raw_data())\n self._fill_value = v\n\n def _get_ndim(self):\n return self._data.ndim\n ndim = property(_get_ndim, doc=numeric.ndarray.ndim.__doc__)\n\n def _get_size (self):\n return self._data.size\n size = property(fget=_get_size, doc=\"Number of elements in the array.\")\n## CHECK THIS: signature of numeric.array.size?\n\n def _get_dtype(self):\n return self._data.dtype\n dtype = property(fget=_get_dtype, doc=\"type of the array elements.\")\n\n def item(self):\n \"Return Python scalar if possible.\"\n if self._mask is not nomask:\n m = oldnumeric.ravel(self._mask)\n try:\n if m[0]:\n return masked\n except IndexError:\n return masked\n return self._data.item()\n\n def tolist(self, fill_value=None):\n \"Convert to list\"\n return self.filled(fill_value).tolist()\n\n def tostring(self, fill_value=None):\n \"Convert to string\"\n return self.filled(fill_value).tostring()\n\n def unmask (self):\n \"Replace the mask by nomask if possible.\"\n if self._mask is nomask: return\n m = make_mask(self._mask, flag=1)\n if m is nomask:\n self._mask = nomask\n self._shared_mask = 0\n\n def unshare_mask (self):\n \"If currently sharing mask, make a copy.\"\n if self._shared_mask:\n self._mask = make_mask (self._mask, copy=1, flag=0)\n self._shared_mask = 0\n\n shape = property(_get_shape, _set_shape,\n doc = 'tuple giving the shape of the array')\n\n flat = property(_get_flat, _set_flat,\n doc = 'Access array in flat form.')\n\n real = property(_get_real, _set_real,\n doc = 'Access the real part of the array')\n\n imaginary = property(_get_imaginary, _set_imaginary,\n doc = 'Access the imaginary part of the array')\n\n imag = imaginary\n\n#end class MaskedArray\n\narray = MaskedArray\n\ndef isMaskedArray (x):\n \"Is x a masked array, that is, an instance of MaskedArray?\"\n return isinstance(x, MaskedArray)\n\nisarray = isMaskedArray\nisMA = isMaskedArray #backward compatibility\n\ndef allclose (a, b, fill_value=1, rtol=1.e-5, atol=1.e-8):\n \"\"\" Returns true if all components of a and b are equal\n subject to given tolerances.\n If fill_value is 1, masked values considered equal.\n If fill_value is 0, masked values considered unequal.\n The relative error rtol should be positive and << 1.0\n The absolute error atol comes into play for those elements\n of b that are very small or zero; it says how small a must be also.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n d1 = filled(a)\n d2 = filled(b)\n x = filled(array(d1, copy=0, mask=m), fill_value).astype(float)\n y = filled(array(d2, copy=0, mask=m), 1).astype(float)\n d = umath.less_equal(umath.absolute(x-y), atol + rtol * umath.absolute(y))\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n\ndef allequal (a, b, fill_value=1):\n \"\"\"\n True if all entries of a and b are equal, using\n fill_value as a truth value where either or both are masked.\n \"\"\"\n m = mask_or(getmask(a), getmask(b))\n if m is nomask:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n return oldnumeric.alltrue(oldnumeric.ravel(d))\n elif fill_value:\n x = filled(a)\n y = filled(b)\n d = umath.equal(x, y)\n dm = array(d, mask=m, copy=0)\n return oldnumeric.alltrue(oldnumeric.ravel(filled(dm, 1)))\n else:\n return 0\n\ndef masked_values (data, value, rtol=1.e-5, atol=1.e-8, copy=1):\n \"\"\"\n masked_values(data, value, rtol=1.e-5, atol=1.e-8)\n Create a masked array; mask is nomask if possible.\n If copy==0, and otherwise possible, result\n may share data values with original array.\n Let d = filled(data, value). Returns d\n masked where abs(data-value)<= atol + rtol * abs(value)\n if d is of a floating point type. Otherwise returns\n masked_object(d, value, copy)\n \"\"\"\n abs = umath.absolute\n d = filled(data, value)\n if issubclass(d.dtype.type, numeric.floating):\n m = umath.less_equal(abs(d-value), atol+rtol*abs(value))\n m = make_mask(m, flag=1)\n return array(d, mask = m, copy=copy,\n fill_value=value)\n else:\n return masked_object(d, value, copy=copy)\n\ndef masked_object (data, value, copy=1):\n \"Create array masked where exactly data equal to value\"\n d = filled(data, value)\n dm = make_mask(umath.equal(d, value), flag=1)\n return array(d, mask=dm, copy=copy, fill_value=value)\n\ndef arrayrange(start, stop=None, step=1, dtype=None):\n \"\"\"Just like range() except it returns a array whose type can be specified\n by the keyword argument dtype.\n \"\"\"\n return array(numeric.arrayrange(start, stop, step, dtype))\n\narange = arrayrange\n\ndef fromstring (s, t):\n \"Construct a masked array from a string. Result will have no mask.\"\n return masked_array(numeric.fromstring(s, t))\n\ndef left_shift (a, n):\n \"Left shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.left_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.left_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef right_shift (a, n):\n \"Right shift n bits\"\n m = getmask(a)\n if m is nomask:\n d = umath.right_shift(filled(a), n)\n return masked_array(d)\n else:\n d = umath.right_shift(filled(a, 0), n)\n return masked_array(d, m)\n\ndef resize (a, new_shape):\n \"\"\"resize(a, new_shape) returns a new array with the specified shape.\n The original array's total size can be any size.\"\"\"\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.resize(m, new_shape)\n result = array(oldnumeric.resize(filled(a), new_shape), mask=m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n \"\"\"\n af = filled(a)\n if isinstance(repeats, types.IntType):\n repeats = tuple([repeats]*(shape(af)[axis]))\n\n m = getmask(a)\n if m is not nomask:\n m = oldnumeric.repeat(m, repeats, axis)\n d = oldnumeric.repeat(af, repeats, axis)\n result = masked_array(d, m)\n result.set_fill_value(get_fill_value(a))\n return result\n\ndef identity(n):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n return array(numeric.identity(n))\n\ndef indices (dimensions, dtype=None):\n \"\"\"indices(dimensions,dtype=None) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n return array(numeric.indices(dimensions, dtype))\n\ndef zeros (shape, dtype=int):\n \"\"\"zeros(n, dtype=int) =\n an array of all zeros of the given length or shape.\"\"\"\n return array(numeric.zeros(shape, dtype))\n\ndef ones (shape, dtype=int):\n \"\"\"ones(n, dtype=int) =\n an array of all ones of the given length or shape.\"\"\"\n return array(numeric.ones(shape, dtype))\n\n\ndef count (a, axis = None):\n \"Count of the non-masked elements in a, or along a certain axis.\"\n a = masked_array(a)\n return a.count(axis)\n\ndef power (a, b, third=None):\n \"a**b\"\n if third is not None:\n raise MAError, \"3-argument power not supported.\"\n ma = getmask(a)\n mb = getmask(b)\n m = mask_or(ma, mb)\n fa = filled(a, 1)\n fb = filled(b, 1)\n if fb.dtype.char in typecodes[\"Integer\"]:\n return masked_array(umath.power(fa, fb), m)\n md = make_mask(umath.less_equal (fa, 0), flag=1)\n m = mask_or(m, md)\n if m is nomask:\n return masked_array(umath.power(fa, fb))\n else:\n fa = numeric.where(m, 1, fa)\n return masked_array(umath.power(fa, fb), m)\n\ndef masked_array (a, mask=nomask, fill_value=None):\n \"\"\"masked_array(a, mask=nomask) =\n array(a, mask=mask, copy=0, fill_value=fill_value)\n \"\"\"\n return array(a, mask=mask, copy=0, fill_value=fill_value)\n\nsum = add.reduce\nproduct = multiply.reduce\n\ndef average (a, axis=0, weights=None, returned = 0):\n \"\"\"average(a, axis=0, weights=None)\n Computes average along indicated axis.\n If axis is None, average over the entire array\n Inputs can be integer or floating types; result is of type float.\n\n If weights are given, result is sum(a*weights)/(sum(weights)*1.0)\n weights must have a's shape or be the 1-d with length the size\n of a in the given axis.\n\n If returned, return a tuple: the result and the sum of the weights\n or count of values. Results will have the same shape.\n\n masked values in the weights will be set to 0.0\n \"\"\"\n a = masked_array(a)\n mask = a.mask\n ash = a.shape\n if ash == ():\n ash = (1,)\n if axis is None:\n if mask is nomask:\n if weights is None:\n n = add.reduce(a.raw_data().ravel())\n d = reduce(lambda x, y: x * y, ash, 1.0)\n else:\n w = filled(weights, 0.0).ravel()\n n = umath.add.reduce(a.raw_data().ravel() * w)\n d = umath.add.reduce(w)\n del w\n else:\n if weights is None:\n n = add.reduce(a.ravel())\n w = oldnumeric.choose(mask, (1.0, 0.0)).ravel()\n d = umath.add.reduce(w)\n del w\n else:\n w = array(filled(weights, 0.0), float, mask=mask).ravel()\n n = add.reduce(a.ravel() * w)\n d = add.reduce(w)\n del w\n else:\n if mask is nomask:\n if weights is None:\n d = ash[axis] * 1.0\n n = umath.add.reduce(a.raw_data(), axis)\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = numeric.array(w, float, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * ones(ash, float)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n del w, r\n else:\n raise ValueError, 'average: weights wrong shape.'\n else:\n if weights is None:\n n = add.reduce(a, axis)\n w = numeric.choose(mask, (1.0, 0.0))\n d = umath.add.reduce(w, axis)\n del w\n else:\n w = filled(weights, 0.0)\n wsh = w.shape\n if wsh == ():\n wsh = (1,)\n if wsh == ash:\n w = array(w, float, mask=mask, copy=0)\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n elif wsh == (ash[axis],):\n ni = ash[axis]\n r = [newaxis]*len(ash)\n r[axis] = slice(None, None, 1)\n w = eval (\"w[\"+ repr(tuple(r)) + \"] * masked_array(ones(ash, float), mask)\")\n n = add.reduce(a*w, axis)\n d = add.reduce(w, axis)\n else:\n raise ValueError, 'average: weights wrong shape.'\n del w\n #print n, d, repr(mask), repr(weights)\n if n is masked or d is masked: return masked\n result = divide (n, d)\n del n\n\n if isinstance(result, MaskedArray):\n result.unmask()\n if returned:\n if not isinstance(d, MaskedArray):\n d = masked_array(d)\n if not d.shape == result.shape:\n d = ones(result.shape, float) * d\n d.unmask()\n if returned:\n return result, d\n else:\n return result\n\ndef where (condition, x, y):\n \"\"\"where(condition, x, y) is x where condition is nonzero, y otherwise.\n condition must be convertible to an integer array.\n Answer is always the shape of condition.\n The type depends on x and y. It is integer if both x and y are\n the value masked.\n \"\"\"\n fc = filled(not_equal(condition, 0), 0)\n xv = filled(x)\n xm = getmask(x)\n yv = filled(y)\n ym = getmask(y)\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n m = make_mask(mask_or(m, md), copy=0, flag=1)\n return masked_array(d, m)\n\ndef choose (indices, t):\n \"Returns array shaped like indices with elements chosen from t\"\n def fmask (x):\n if x is masked: return 1\n return filled(x)\n def nmask (x):\n if x is masked: return 1\n m = getmask(x)\n if m is nomask: return 0\n return m\n c = filled(indices, 0)\n masks = [nmask(x) for x in t]\n a = [fmask(x) for x in t]\n d = numeric.choose(c, a)\n m = numeric.choose(c, masks)\n m = make_mask(mask_or(m, getmask(indices)), copy=0, flag=1)\n return masked_array(d, m)\n\ndef masked_where(condition, x, copy=1):\n \"\"\"Return x as an array masked where condition is true.\n Also masked where x or condition masked.\n \"\"\"\n cm = filled(condition,1)\n m = mask_or(getmask(x), cm)\n return array(filled(x), copy=copy, mask=m)\n\ndef masked_greater(x, value, copy=1):\n \"masked_greater(x, value) = x masked where x > value\"\n return masked_where(greater(x, value), x, copy)\n\ndef masked_greater_equal(x, value, copy=1):\n \"masked_greater_equal(x, value) = x masked where x >= value\"\n return masked_where(greater_equal(x, value), x, copy)\n\ndef masked_less(x, value, copy=1):\n \"masked_less(x, value) = x masked where x < value\"\n return masked_where(less(x, value), x, copy)\n\ndef masked_less_equal(x, value, copy=1):\n \"masked_less_equal(x, value) = x masked where x <= value\"\n return masked_where(less_equal(x, value), x, copy)\n\ndef masked_not_equal(x, value, copy=1):\n \"masked_not_equal(x, value) = x masked where x != value\"\n d = filled(x, 0)\n c = umath.not_equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_equal(x, value, copy=1):\n \"\"\"masked_equal(x, value) = x masked where x == value\n For floating point consider masked_values(x, value) instead.\n \"\"\"\n d = filled(x, 0)\n c = umath.equal(d, value)\n m = mask_or(c, getmask(x))\n return array(d, mask=m, copy=copy)\n\ndef masked_inside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are inside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_and(umath.less_equal(d, v2), umath.greater_equal(d, v1))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef masked_outside(x, v1, v2, copy=1):\n \"\"\"x with mask of all values of x that are outside [v1,v2]\n v1 and v2 can be given in either order.\n \"\"\"\n if v2 < v1:\n t = v2\n v2 = v1\n v1 = t\n d = filled(x, 0)\n c = umath.logical_or(umath.less(d, v1), umath.greater(d, v2))\n m = mask_or(c, getmask(x))\n return array(d, mask = m, copy=copy)\n\ndef reshape (a, *newshape):\n \"Copy of a with a new shape.\"\n m = getmask(a)\n d = filled(a).reshape(*newshape)\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.reshape(m, *newshape))\n\ndef ravel (a):\n \"a as one-dimensional, may share data and mask\"\n m = getmask(a)\n d = oldnumeric.ravel(filled(a))\n if m is nomask:\n return masked_array(d)\n else:\n return masked_array(d, mask=numeric.ravel(m))\n\ndef concatenate (arrays, axis=0):\n \"Concatenate the arrays along the given axis\"\n d = []\n for x in arrays:\n d.append(filled(x))\n d = numeric.concatenate(d, axis)\n for x in arrays:\n if getmask(x) is not nomask: break\n else:\n return masked_array(d)\n dm = []\n for x in arrays:\n dm.append(getmaskarray(x))\n dm = numeric.concatenate(dm, axis)\n return masked_array(d, mask=dm)\n\ndef swapaxes (a, axis1, axis2):\n m = getmask(a)\n d = masked_array(a).data\n if m is nomask:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2))\n else:\n return masked_array(data=numeric.swapaxes(d, axis1, axis2),\n mask=numeric.swapaxes(m, axis1, axis2),)\n\n\ndef take (a, indices, axis=0):\n \"take(a, indices, axis=0) returns selection of items from a.\"\n m = getmask(a)\n # d = masked_array(a).raw_data()\n d = masked_array(a).data\n if m is nomask:\n return masked_array(numeric.take(d, indices, axis))\n else:\n return masked_array(numeric.take(d, indices, axis),\n mask = numeric.take(m, indices, axis))\n\ndef transpose(a, axes=None):\n \"transpose(a, axes=None) reorder dimensions per tuple axes\"\n m = getmask(a)\n d = filled(a)\n if m is nomask:\n return masked_array(numeric.transpose(d, axes))\n else:\n return masked_array(numeric.transpose(d, axes),\n mask = numeric.transpose(m, axes))\n\n\ndef put(a, indices, values):\n \"\"\"put(a, indices, values) sets storage-indexed locations to corresponding values.\n\n Values and indices are filled if necessary.\n\n \"\"\"\n d = a.raw_data()\n ind = filled(indices)\n v = filled(values)\n numeric.put (d, ind, v)\n m = getmask(a)\n if m is not nomask:\n a.unshare_mask()\n numeric.put(a.raw_mask(), ind, 0)\n\ndef putmask(a, mask, values):\n \"putmask(a, mask, values) sets a where mask is true.\"\n if mask is nomask:\n return\n numeric.putmask(a.raw_data(), mask, values)\n m = getmask(a)\n if m is nomask: return\n a.unshare_mask()\n numeric.putmask(a.raw_mask(), mask, 0)\n\ndef innerproduct(a, b):\n \"\"\"innerproduct(a,b) returns the dot product of two arrays, which has\n shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the\n product of the elements from the last dimensions of a and b.\n Masked elements are replace by zeros.\n \"\"\"\n fa = filled(a, 0)\n fb = filled(b, 0)\n if len(fa.shape) == 0: fa.shape = (1,)\n if len(fb.shape) == 0: fb.shape = (1,)\n return masked_array(numeric.innerproduct(fa, fb))\n\ndef outerproduct(a, b):\n \"\"\"outerproduct(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))\"\"\"\n fa = filled(a, 0).ravel()\n fb = filled(b, 0).ravel()\n d = numeric.outerproduct(fa, fb)\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n return masked_array(d)\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = make_mask(1-numeric.outerproduct(1-ma, 1-mb), copy=0)\n return masked_array(d, m)\n\ndef dot(a, b):\n \"\"\"dot(a,b) returns matrix-multiplication between a and b. The product-sum\n is over the last dimension of a and the second-to-last dimension of b.\n Masked values are replaced by zeros. See also innerproduct.\n \"\"\"\n return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))\n\ndef compress(condition, x, dimension=-1):\n \"\"\"Select those parts of x for which condition is true.\n Masked values in condition are considered false.\n \"\"\"\n c = filled(condition, 0)\n m = getmask(x)\n if m is not nomask:\n m = numeric.compress(c, m, dimension)\n d = numeric.compress(c, filled(x), dimension)\n return masked_array(d, m)\n\nclass _minimum_operation:\n \"Object to calculate minima\"\n def __init__ (self):\n \"\"\"minimum(a, b) or minimum(a)\n In one argument case returns the scalar minimum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amin(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amin(ac.raw_data())\n else:\n return where(less(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.minimum.reduce (t, axis))\n else:\n t = umath.minimum.reduce(filled(target, minimum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.minimum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nminimum = _minimum_operation ()\n\nclass _maximum_operation:\n \"Object to calculate maxima\"\n def __init__ (self):\n \"\"\"maximum(a, b) or maximum(a)\n In one argument case returns the scalar maximum.\n \"\"\"\n pass\n\n def __call__ (self, a, b=None):\n \"Execute the call behavior.\"\n if b is None:\n m = getmask(a)\n if m is nomask:\n d = amax(filled(a).ravel())\n return d\n ac = a.compressed()\n if len(ac) == 0:\n return masked\n else:\n return amax(ac.raw_data())\n else:\n return where(greater(a, b), a, b)\n\n def reduce (self, target, axis=0):\n \"\"\"Reduce target along the given axis.\"\"\"\n m = getmask(target)\n if m is nomask:\n t = filled(target)\n return masked_array (umath.maximum.reduce (t, axis))\n else:\n t = umath.maximum.reduce(filled(target, maximum_fill_value(target)), axis)\n m = umath.logical_and.reduce(m, axis)\n return masked_array(t, m, get_fill_value(target))\n\n def outer (self, a, b):\n \"Return the function applied to the outer product of a and b.\"\n ma = getmask(a)\n mb = getmask(b)\n if ma is nomask and mb is nomask:\n m = nomask\n else:\n ma = getmaskarray(a)\n mb = getmaskarray(b)\n m = logical_or.outer(ma, mb)\n d = umath.maximum.outer(filled(a), filled(b))\n return masked_array(d, m)\n\nmaximum = _maximum_operation ()\n\ndef sort (x, axis = -1, fill_value=None):\n \"\"\"If x does not have a mask, return a masked array formed from the\n result of numeric.sort(x, axis).\n Otherwise, fill x with fill_value. Sort it.\n Set a mask where the result is equal to fill_value.\n Note that this may have unintended consequences if the data contains the\n fill value at a non-masked site.\n\n If fill_value is not given the default fill value for x's type will be\n used.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n d = filled(x, fill_value)\n s = oldnumeric.sort(d, axis)\n if getmask(x) is nomask:\n return masked_array(s)\n return masked_values(s, fill_value, copy=0)\n\ndef diagonal(a, k = 0, axis1=0, axis2=1):\n \"\"\"diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a\"\"\"\n d = oldnumeric.diagonal(filled(a), k, axis1, axis2)\n m = getmask(a)\n if m is nomask:\n return masked_array(d, m)\n else:\n return masked_array(d, oldnumeric.diagonal(m, k, axis1, axis2))\n \ndef trace (a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return diagonal(a, offset, axis1, axis2).sum(dtype=dtype)\n\ndef argsort (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for sorting along given axis.\n if fill_value is None, use get_fill_value(x)\n Returns a numpy array.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argsort(d, axis)\n\ndef argmin (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return indices for minimum values along given axis.\n if fill_value is None, use get_fill_value(x).\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n d = filled(x, fill_value)\n return oldnumeric.argmin(d, axis)\n\ndef argmax (x, axis = -1, fill_value=None):\n \"\"\"Treating masked values as if they have the value fill_value,\n return sort indices for maximum along given axis.\n if fill_value is None, use -get_fill_value(x) if it exists.\n Returns a numpy array if x has more than one dimension.\n Otherwise, returns a scalar index.\n \"\"\"\n if fill_value is None:\n fill_value = default_fill_value (x)\n try:\n fill_value = - fill_value\n except:\n pass\n d = filled(x, fill_value)\n return oldnumeric.argmax(d, axis)\n\ndef fromfunction (f, s):\n \"\"\"apply f to s to create array as in umath.\"\"\"\n return masked_array(numeric.fromfunction(f, s))\n\ndef asarray(data, dtype=None):\n \"\"\"asarray(data, dtype) = array(data, dtype, copy=0)\n \"\"\"\n if isinstance(data, MaskedArray) and \\\n (dtype is None or dtype == data.dtype):\n return data\n return array(data, dtype=dtype, copy=0)\n\n# Add methods to support ndarray interface\n# XXX: I is better to to change the masked_*_operation adaptors\n# XXX: to wrap ndarray methods directly to create ma.array methods.\nfrom types import MethodType\ndef _m(f):\n return MethodType(f, None, array)\ndef not_implemented(*args, **kwds):\n raise NotImplementedError, \"not yet implemented for numpy.ma arrays\"\narray.all = _m(alltrue)\narray.any = _m(sometrue)\narray.argmax = _m(argmax)\narray.argmin = _m(argmin)\narray.argsort = _m(argsort)\narray.base = property(_m(not_implemented))\narray.byteswap = _m(not_implemented)\n\ndef _choose(self, *args):\n return choose(self, args)\narray.choose = _m(_choose)\ndel _choose\n\ndef _clip(self,a_min,a_max):\n return MaskedArray(data = self.data.clip(asarray(a_min).data, \n asarray(a_max).data),\n mask = mask_or(self.mask,\n mask_or(getmask(a_min),getmask(a_max))))\narray.clip = _m(_clip)\n\ndef _compress(self, cond, axis=None):\n return compress(cond, self, axis)\narray.compress = _m(_compress)\ndel _compress\n\narray.conj = array.conjugate = _m(conjugate)\narray.copy = _m(not_implemented)\n\ndef _cumprod(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_and.accumulate(self.mask, axis)\n return MaskedArray(data = self.filled(1).cumprod(axis, dtype), mask=m)\narray.cumprod = _m(_cumprod)\n\ndef _cumsum(self, axis=0, dtype=None):\n m = self.mask\n if m is not nomask:\n m = umath.logical_and.accumulate(self.mask, axis)\n return MaskedArray(data=self.filled(0).cumsum(axis, dtype), mask=m)\narray.cumsum = _m(_cumsum)\n\narray.diagonal = _m(diagonal)\narray.dump = _m(not_implemented)\narray.dumps = _m(not_implemented)\narray.fill = _m(not_implemented)\narray.flags = property(_m(not_implemented))\narray.flatten = _m(ravel)\narray.getfield = _m(not_implemented)\n\ndef _max(a, axis=None):\n if axis is None:\n return maximum(a)\n else:\n return maximum.reduce(a, axis)\narray.max = _m(_max)\ndel _max\ndef _min(a, axis=None):\n if axis is None:\n return minimum(a)\n else:\n return minimum.reduce(a, axis)\narray.min = _m(_min)\ndel _min\narray.mean = _m(average)\narray.nbytes = property(_m(not_implemented))\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\n\ndef _ptp(a,axis=0):\n return a.max(axis)-a.min(axis)\narray.ptp = _m(_ptp)\narray.repeat = _m(repeat)\narray.resize = _m(resize)\narray.searchsorted = _m(not_implemented)\narray.setfield = _m(not_implemented)\narray.setflags = _m(not_implemented)\narray.sort = _m(not_implemented) # NB: ndarray.sort is inplace\n\ndef _squeeze(self):\n try:\n result = MaskedArray(data = self.data.squeeze(),\n mask = self.mask.squeeze())\n except AttributeError:\n result = _wrapit(self, 'squeeze')\n return result\narray.squeeze = _m(_squeeze) \n\narray.strides = property(_m(not_implemented))\narray.sum = _m(sum)\ndef _swapaxes(self,axis1,axis2):\n return MaskedArray(data = self.data.swapaxes(axis1, axis2),\n mask = self.mask.swapaxes(axis1, axis2))\narray.swapaxes = _m(_swapaxes)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(trace)\narray.transpose = _m(transpose)\n\ndef _var(self,axis=0,dtype=None):\n if axis is None:\n return asarray(self.compressed()).var()\n a = self.swapaxes(axis,0)\n a = a - a.mean(axis=0)\n a *= a\n a /= (a.count(axis=0)-1)\n return a.swapaxes(0,axis).sum(axis)\ndef _std(self,axis=0,dtype=None):\n return (self.var(axis,dtype))**0.5\narray.var = _m(_var)\narray.std = _m(_std)\n\narray.view = _m(not_implemented)\narray.round = _m(around)\ndel _m, MethodType, not_implemented\n\n\nmasked = MaskedArray(0, int, mask=1)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self , args = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 30, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , display )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "display" + ], + "start_line": 40, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "display", + "long_name": "display( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "set_display", + "long_name": "set_display( self , s )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "s" + ], + "start_line": 49, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enabled", + "long_name": "enabled( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enable", + "long_name": "enable( self , flag = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "flag" + ], + "start_line": 57, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "default_fill_value", + "long_name": "default_fill_value( obj )", + "filename": "ma.py", + "nloc": 25, + "complexity": 13, + "token_count": 146, + "parameters": [ + "obj" + ], + "start_line": 76, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "minimum_fill_value", + "long_name": "minimum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 107, + "parameters": [ + "obj" + ], + "start_line": 102, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "maximum_fill_value", + "long_name": "maximum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 105, + "parameters": [ + "obj" + ], + "start_line": 119, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( a , fill_value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 20, + "parameters": [ + "a", + "fill_value" + ], + "start_line": 136, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getmask", + "long_name": "getmask( a )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "a" + ], + "start_line": 141, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getmaskarray", + "long_name": "getmaskarray( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 150, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "is_mask", + "long_name": "is_mask( m )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "m" + ], + "start_line": 161, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "make_mask", + "long_name": "make_mask( m , copy = 0 , flag = 0 )", + "filename": "ma.py", + "nloc": 17, + "complexity": 7, + "token_count": 109, + "parameters": [ + "m", + "copy", + "flag" + ], + "start_line": 169, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "make_mask_none", + "long_name": "make_mask_none( s )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "mask_or", + "long_name": "mask_or( m1 , m2 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 5, + "token_count": 52, + "parameters": [ + "m1", + "m2" + ], + "start_line": 200, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "filled", + "long_name": "filled( a , value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 5, + "token_count": 70, + "parameters": [ + "a", + "value" + ], + "start_line": 209, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "get_fill_value", + "long_name": "get_fill_value( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 229, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "common_fill_value", + "long_name": "common_fill_value( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a", + "b" + ], + "start_line": 240, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , y1 , y2 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "y1", + "y2" + ], + "start_line": 250, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "x" + ], + "start_line": 255, + "end_line": 259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , eps )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "eps" + ], + "start_line": 263, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "x" + ], + "start_line": 267, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 273, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 277, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 283, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 287, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , aufunc , fill = 0 , domain = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 306, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "__init__", + "long_name": "__init__( self , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 321, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 323, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , domain , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 330, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 13, + "complexity": 2, + "token_count": 107, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 343, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "abfunc", + "fillx", + "filly" + ], + "start_line": 362, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 373, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 20, + "complexity": 7, + "token_count": 169, + "parameters": [ + "self", + "target", + "axis", + "dtype" + ], + "start_line": 381, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "accumulate", + "long_name": "accumulate( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 418, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "nonzero", + "long_name": "nonzero( a )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 447, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 492, + "end_line": 493, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 495, + "end_line": 496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( object , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "object", + "axis" + ], + "start_line": 498, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , data , dtype = None , copy = True , order = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "order", + "mask", + "fill_value" + ], + "start_line": 530, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None , context = None )", + "filename": "ma.py", + "nloc": 22, + "complexity": 6, + "token_count": 124, + "parameters": [ + "self", + "t", + "context" + ], + "start_line": 596, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 16, + "complexity": 8, + "token_count": 129, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 624, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_shape", + "long_name": "_get_shape( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 647, + "end_line": 649, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_set_shape", + "long_name": "_set_shape( self , newshape )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "newshape" + ], + "start_line": 651, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_get_flat", + "long_name": "_get_flat( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 658, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "_set_flat", + "long_name": "_set_flat( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "value" + ], + "start_line": 669, + "end_line": 672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_real", + "long_name": "_get_real( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 674, + "end_line": 681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_real", + "long_name": "_set_real( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 683, + "end_line": 686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_imaginary", + "long_name": "_get_imaginary( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 688, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_imaginary", + "long_name": "_set_imaginary( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 697, + "end_line": 700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 13, + "complexity": 6, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 702, + "end_line": 722, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "ma.py", + "nloc": 42, + "complexity": 5, + "token_count": 207, + "parameters": [ + "self" + ], + "start_line": 724, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "__float__", + "long_name": "__float__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__int__", + "long_name": "__int__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , i )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 70, + "parameters": [ + "self", + "i" + ], + "start_line": 785, + "end_line": 799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 801, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , index , value )", + "filename": "ma.py", + "nloc": 27, + "complexity": 7, + "token_count": 157, + "parameters": [ + "self", + "index", + "value" + ], + "start_line": 816, + "end_line": 842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__setslice__", + "long_name": "__setslice__( self , i , j , value )", + "filename": "ma.py", + "nloc": 23, + "complexity": 7, + "token_count": 155, + "parameters": [ + "self", + "i", + "j", + "value" + ], + "start_line": 844, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "__nonzero__", + "long_name": "__nonzero__( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 868, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 880, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__and__", + "long_name": "__and__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 885, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__or__", + "long_name": "__or__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 889, + "end_line": 891, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__xor__", + "long_name": "__xor__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 893, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__abs__", + "long_name": "__abs__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 901, + "end_line": 903, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__neg__", + "long_name": "__neg__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 905, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pos__", + "long_name": "__pos__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 909, + "end_line": 911, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 913, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 919, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 923, + "end_line": 925, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__lshift__", + "long_name": "__lshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 927, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__rshift__", + "long_name": "__rshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 933, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 937, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 941, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 947, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 951, + "end_line": 953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__truediv__", + "long_name": "__truediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 955, + "end_line": 957, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rtruediv__", + "long_name": "__rtruediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 959, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__floordiv__", + "long_name": "__floordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 963, + "end_line": 965, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rfloordiv__", + "long_name": "__rfloordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 967, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other , third = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "other", + "third" + ], + "start_line": 971, + "end_line": 973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__sqrt__", + "long_name": "__sqrt__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 975, + "end_line": 977, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__iadd__", + "long_name": "__iadd__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 979, + "end_line": 1020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 255, + "parameters": [ + "self", + "other" + ], + "start_line": 1022, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__isub__", + "long_name": "__isub__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 1065, + "end_line": 1106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__idiv__", + "long_name": "__idiv__( self , other )", + "filename": "ma.py", + "nloc": 38, + "complexity": 12, + "token_count": 237, + "parameters": [ + "self", + "other" + ], + "start_line": 1110, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1149, + "end_line": 1150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1152, + "end_line": 1153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1155, + "end_line": 1156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1158, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1161, + "end_line": 1162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1164, + "end_line": 1165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "astype", + "long_name": "astype( self , tc )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "tc" + ], + "start_line": 1167, + "end_line": 1170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "byte_swapped", + "long_name": "byte_swapped( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "compressed", + "long_name": "compressed( self )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "count", + "long_name": "count( self , axis = None )", + "filename": "ma.py", + "nloc": 29, + "complexity": 7, + "token_count": 173, + "parameters": [ + "self", + "axis" + ], + "start_line": 1188, + "end_line": 1216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dot", + "long_name": "dot( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1218, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "fill_value", + "long_name": "fill_value( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1222, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "filled", + "long_name": "filled( self , fill_value = None )", + "filename": "ma.py", + "nloc": 31, + "complexity": 9, + "token_count": 175, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1226, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 1 + }, + { + "name": "ids", + "long_name": "ids( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 1268, + "end_line": 1270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "iscontiguous", + "long_name": "iscontiguous( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 1272, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "itemsize", + "long_name": "itemsize( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 1276, + "end_line": 1278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1281, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "put", + "long_name": "put( self , values )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "values" + ], + "start_line": 1285, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "putmask", + "long_name": "putmask( self , values )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "values" + ], + "start_line": 1297, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "ravel", + "long_name": "ravel( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 1307, + "end_line": 1312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "raw_data", + "long_name": "raw_data( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1314, + "end_line": 1318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "raw_mask", + "long_name": "raw_mask( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1322, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "reshape", + "long_name": "reshape( self , * s )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self", + "s" + ], + "start_line": 1330, + "end_line": 1337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( self , v = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "v" + ], + "start_line": 1339, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_ndim", + "long_name": "_get_ndim( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1345, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_size", + "long_name": "_get_size( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1349, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_dtype", + "long_name": "_get_dtype( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1354, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "item", + "long_name": "item( self )", + "filename": "ma.py", + "nloc": 10, + "complexity": 4, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 1358, + "end_line": 1367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1369, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "tostring", + "long_name": "tostring( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1373, + "end_line": 1375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unmask", + "long_name": "unmask( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 3, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1377, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "unshare_mask", + "long_name": "unshare_mask( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 1385, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "isMaskedArray", + "long_name": "isMaskedArray( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "x" + ], + "start_line": 1409, + "end_line": 1411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , fill_value = 1 , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 140, + "parameters": [ + "a", + "b", + "fill_value", + "rtol", + "atol" + ], + "start_line": 1416, + "end_line": 1431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "allequal", + "long_name": "allequal( a , b , fill_value = 1 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 3, + "token_count": 125, + "parameters": [ + "a", + "b", + "fill_value" + ], + "start_line": 1433, + "end_line": 1451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "masked_values", + "long_name": "masked_values( data , value , rtol = 1 . e - 5 , atol = 1 . e - 8 , copy = 1 )", + "filename": "ma.py", + "nloc": 10, + "complexity": 2, + "token_count": 117, + "parameters": [ + "data", + "value", + "rtol", + "atol", + "copy" + ], + "start_line": 1453, + "end_line": 1472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "masked_object", + "long_name": "masked_object( data , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "data", + "value", + "copy" + ], + "start_line": 1474, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayrange", + "long_name": "arrayrange( start , stop = None , step = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 1480, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( s , t )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "s", + "t" + ], + "start_line": 1488, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "left_shift", + "long_name": "left_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1492, + "end_line": 1500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "right_shift", + "long_name": "right_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1502, + "end_line": 1510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 1512, + "end_line": 1520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 101, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 1522, + "end_line": 1537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "n" + ], + "start_line": 1539, + "end_line": 1542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 1544, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "zeros", + "long_name": "zeros( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1550, + "end_line": 1553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1555, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "count", + "long_name": "count( a , axis = None )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 1561, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( a , b , third = None )", + "filename": "ma.py", + "nloc": 18, + "complexity": 4, + "token_count": 154, + "parameters": [ + "a", + "b", + "third" + ], + "start_line": 1566, + "end_line": 1583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "masked_array", + "long_name": "masked_array( a , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "mask", + "fill_value" + ], + "start_line": 1585, + "end_line": 1589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "average", + "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", + "filename": "ma.py", + "nloc": 92, + "complexity": 22, + "token_count": 741, + "parameters": [ + "a", + "axis", + "weights", + "returned" + ], + "start_line": 1594, + "end_line": 1701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 107, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1703, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "choose.fmask", + "long_name": "choose.fmask( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "x" + ], + "start_line": 1723, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "choose.nmask", + "long_name": "choose.nmask( x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 3, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 1726, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "choose", + "long_name": "choose( indices , t )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 93, + "parameters": [ + "indices", + "t" + ], + "start_line": 1721, + "end_line": 1737, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "masked_where", + "long_name": "masked_where( condition , x , copy = 1 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "condition", + "x", + "copy" + ], + "start_line": 1739, + "end_line": 1745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "masked_greater", + "long_name": "masked_greater( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1747, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_greater_equal", + "long_name": "masked_greater_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1751, + "end_line": 1753, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less", + "long_name": "masked_less( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1755, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less_equal", + "long_name": "masked_less_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1759, + "end_line": 1761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_not_equal", + "long_name": "masked_not_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1763, + "end_line": 1768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "masked_equal", + "long_name": "masked_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1770, + "end_line": 1777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "masked_inside", + "long_name": "masked_inside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1779, + "end_line": 1790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "masked_outside", + "long_name": "masked_outside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1792, + "end_line": 1803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , * newshape )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 56, + "parameters": [ + "a", + "newshape" + ], + "start_line": 1805, + "end_line": 1812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( a )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "a" + ], + "start_line": 1814, + "end_line": 1821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "concatenate", + "long_name": "concatenate( arrays , axis = 0 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 5, + "token_count": 97, + "parameters": [ + "arrays", + "axis" + ], + "start_line": 1823, + "end_line": 1837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 1839, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1849, + "end_line": 1858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1860, + "end_line": 1868, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , indices , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 70, + "parameters": [ + "a", + "indices", + "values" + ], + "start_line": 1871, + "end_line": 1884, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 61, + "parameters": [ + "a", + "mask", + "values" + ], + "start_line": 1886, + "end_line": 1894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "innerproduct", + "long_name": "innerproduct( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 72, + "parameters": [ + "a", + "b" + ], + "start_line": 1896, + "end_line": 1906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "outerproduct", + "long_name": "outerproduct( a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 110, + "parameters": [ + "a", + "b" + ], + "start_line": 1908, + "end_line": 1920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dot", + "long_name": "dot( a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 36, + "parameters": [ + "a", + "b" + ], + "start_line": 1922, + "end_line": 1927, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , x , dimension = - 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 67, + "parameters": [ + "condition", + "x", + "dimension" + ], + "start_line": 1929, + "end_line": 1938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1942, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1948, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 1963, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1974, + "end_line": 1985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1991, + "end_line": 1995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1997, + "end_line": 2010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 2012, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 2023, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "sort", + "long_name": "sort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 3, + "token_count": 68, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2038, + "end_line": 2055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , k = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 73, + "parameters": [ + "a", + "k", + "axis1", + "axis2" + ], + "start_line": 2057, + "end_line": 2064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 2066, + "end_line": 2070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2072, + "end_line": 2079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2081, + "end_line": 2089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2091, + "end_line": 2105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( f , s )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "f", + "s" + ], + "start_line": 2107, + "end_line": 2109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( data , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 46, + "parameters": [ + "data", + "dtype" + ], + "start_line": 2111, + "end_line": 2117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_m", + "long_name": "_m( f )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "f" + ], + "start_line": 2123, + "end_line": 2124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( * args , ** kwds )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "args", + "kwds" + ], + "start_line": 2125, + "end_line": 2126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_choose", + "long_name": "_choose( self , * args )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 2135, + "end_line": 2136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_clip", + "long_name": "_clip( self , a_min , a_max )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "a_min", + "a_max" + ], + "start_line": 2140, + "end_line": 2144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_compress", + "long_name": "_compress( self , cond , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "cond", + "axis" + ], + "start_line": 2147, + "end_line": 2148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_cumprod", + "long_name": "_cumprod( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2155, + "end_line": 2159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_cumsum", + "long_name": "_cumsum( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2162, + "end_line": 2166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_max", + "long_name": "_max( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2177, + "end_line": 2181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_min", + "long_name": "_min( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2184, + "end_line": 2188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_ptp", + "long_name": "_ptp( a , axis = 0 )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 2197, + "end_line": 2198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_squeeze", + "long_name": "_squeeze( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 2207, + "end_line": 2213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_swapaxes", + "long_name": "_swapaxes( self , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "axis1", + "axis2" + ], + "start_line": 2218, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_var", + "long_name": "_var( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 86, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2227, + "end_line": 2234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_std", + "long_name": "_std( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2235, + "end_line": 2236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self , args = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 30, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , display )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "display" + ], + "start_line": 40, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "display", + "long_name": "display( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "set_display", + "long_name": "set_display( self , s )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "s" + ], + "start_line": 49, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enabled", + "long_name": "enabled( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "enable", + "long_name": "enable( self , flag = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "flag" + ], + "start_line": 57, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "default_fill_value", + "long_name": "default_fill_value( obj )", + "filename": "ma.py", + "nloc": 25, + "complexity": 13, + "token_count": 146, + "parameters": [ + "obj" + ], + "start_line": 76, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "minimum_fill_value", + "long_name": "minimum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 107, + "parameters": [ + "obj" + ], + "start_line": 102, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "maximum_fill_value", + "long_name": "maximum_fill_value( obj )", + "filename": "ma.py", + "nloc": 16, + "complexity": 9, + "token_count": 105, + "parameters": [ + "obj" + ], + "start_line": 119, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( a , fill_value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 2, + "token_count": 20, + "parameters": [ + "a", + "fill_value" + ], + "start_line": 136, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getmask", + "long_name": "getmask( a )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "a" + ], + "start_line": 141, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getmaskarray", + "long_name": "getmaskarray( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 150, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "is_mask", + "long_name": "is_mask( m )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "m" + ], + "start_line": 161, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "make_mask", + "long_name": "make_mask( m , copy = 0 , flag = 0 )", + "filename": "ma.py", + "nloc": 17, + "complexity": 7, + "token_count": 109, + "parameters": [ + "m", + "copy", + "flag" + ], + "start_line": 169, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "make_mask_none", + "long_name": "make_mask_none( s )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "mask_or", + "long_name": "mask_or( m1 , m2 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 5, + "token_count": 52, + "parameters": [ + "m1", + "m2" + ], + "start_line": 200, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "filled", + "long_name": "filled( a , value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 5, + "token_count": 70, + "parameters": [ + "a", + "value" + ], + "start_line": 209, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "get_fill_value", + "long_name": "get_fill_value( a )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a" + ], + "start_line": 229, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "common_fill_value", + "long_name": "common_fill_value( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "a", + "b" + ], + "start_line": 240, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , y1 , y2 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "y1", + "y2" + ], + "start_line": 250, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "x" + ], + "start_line": 255, + "end_line": 259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , eps )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "eps" + ], + "start_line": 263, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "x" + ], + "start_line": 267, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 273, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 277, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , critical_value )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "critical_value" + ], + "start_line": 283, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "x" + ], + "start_line": 287, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , aufunc , fill = 0 , domain = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 306, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "__init__", + "long_name": "__init__( self , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 321, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 323, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , domain , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 330, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 13, + "complexity": 2, + "token_count": 107, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 343, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , abfunc , fillx = 0 , filly = 0 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "abfunc", + "fillx", + "filly" + ], + "start_line": 362, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 373, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 20, + "complexity": 7, + "token_count": 169, + "parameters": [ + "self", + "target", + "axis", + "dtype" + ], + "start_line": 381, + "end_line": 403, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 405, + "end_line": 416, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "accumulate", + "long_name": "accumulate( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 418, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "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": "nonzero", + "long_name": "nonzero( a )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 447, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 492, + "end_line": 493, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 495, + "end_line": 496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( object , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "object", + "axis" + ], + "start_line": 498, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , data , dtype = None , copy = True , order = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "order", + "mask", + "fill_value" + ], + "start_line": 530, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None , context = None )", + "filename": "ma.py", + "nloc": 22, + "complexity": 6, + "token_count": 124, + "parameters": [ + "self", + "t", + "context" + ], + "start_line": 596, + "end_line": 622, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 16, + "complexity": 8, + "token_count": 129, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 624, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_shape", + "long_name": "_get_shape( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 647, + "end_line": 649, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_set_shape", + "long_name": "_set_shape( self , newshape )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "newshape" + ], + "start_line": 651, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_get_flat", + "long_name": "_get_flat( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 658, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "_set_flat", + "long_name": "_set_flat( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "value" + ], + "start_line": 669, + "end_line": 672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_real", + "long_name": "_get_real( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 674, + "end_line": 681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_real", + "long_name": "_set_real( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 683, + "end_line": 686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "_get_imaginary", + "long_name": "_get_imaginary( self )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 688, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "_set_imaginary", + "long_name": "_set_imaginary( self , value )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "value" + ], + "start_line": 697, + "end_line": 700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 13, + "complexity": 6, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 702, + "end_line": 722, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "ma.py", + "nloc": 42, + "complexity": 5, + "token_count": 207, + "parameters": [ + "self" + ], + "start_line": 724, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "__float__", + "long_name": "__float__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 771, + "end_line": 776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__int__", + "long_name": "__int__( self )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 778, + "end_line": 783, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , i )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 70, + "parameters": [ + "self", + "i" + ], + "start_line": 785, + "end_line": 799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 801, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , index , value )", + "filename": "ma.py", + "nloc": 27, + "complexity": 7, + "token_count": 157, + "parameters": [ + "self", + "index", + "value" + ], + "start_line": 816, + "end_line": 842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__setslice__", + "long_name": "__setslice__( self , i , j , value )", + "filename": "ma.py", + "nloc": 23, + "complexity": 7, + "token_count": 155, + "parameters": [ + "self", + "i", + "j", + "value" + ], + "start_line": 844, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "__nonzero__", + "long_name": "__nonzero__( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 868, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 880, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__and__", + "long_name": "__and__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 885, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__or__", + "long_name": "__or__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 889, + "end_line": 891, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__xor__", + "long_name": "__xor__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 893, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__abs__", + "long_name": "__abs__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 901, + "end_line": 903, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__neg__", + "long_name": "__neg__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 905, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pos__", + "long_name": "__pos__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 909, + "end_line": 911, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 913, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 919, + "end_line": 921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 923, + "end_line": 925, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__lshift__", + "long_name": "__lshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 927, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__rshift__", + "long_name": "__rshift__( self , n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "n" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 933, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 937, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 941, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 947, + "end_line": 949, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 951, + "end_line": 953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__truediv__", + "long_name": "__truediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 955, + "end_line": 957, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rtruediv__", + "long_name": "__rtruediv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 959, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__floordiv__", + "long_name": "__floordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 963, + "end_line": 965, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rfloordiv__", + "long_name": "__rfloordiv__( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 967, + "end_line": 969, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other , third = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "other", + "third" + ], + "start_line": 971, + "end_line": 973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__sqrt__", + "long_name": "__sqrt__( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 975, + "end_line": 977, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__iadd__", + "long_name": "__iadd__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 979, + "end_line": 1020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 255, + "parameters": [ + "self", + "other" + ], + "start_line": 1022, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__isub__", + "long_name": "__isub__( self , other )", + "filename": "ma.py", + "nloc": 41, + "complexity": 12, + "token_count": 254, + "parameters": [ + "self", + "other" + ], + "start_line": 1065, + "end_line": 1106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__idiv__", + "long_name": "__idiv__( self , other )", + "filename": "ma.py", + "nloc": 38, + "complexity": 12, + "token_count": 237, + "parameters": [ + "self", + "other" + ], + "start_line": 1110, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1149, + "end_line": 1150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1152, + "end_line": 1153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1155, + "end_line": 1156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1158, + "end_line": 1159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1161, + "end_line": 1162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "other" + ], + "start_line": 1164, + "end_line": 1165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "astype", + "long_name": "astype( self , tc )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "tc" + ], + "start_line": 1167, + "end_line": 1170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "byte_swapped", + "long_name": "byte_swapped( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "compressed", + "long_name": "compressed( self )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "count", + "long_name": "count( self , axis = None )", + "filename": "ma.py", + "nloc": 29, + "complexity": 7, + "token_count": 173, + "parameters": [ + "self", + "axis" + ], + "start_line": 1188, + "end_line": 1216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dot", + "long_name": "dot( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1218, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "fill_value", + "long_name": "fill_value( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1222, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "filled", + "long_name": "filled( self , fill_value = None )", + "filename": "ma.py", + "nloc": 31, + "complexity": 9, + "token_count": 175, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1226, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 1 + }, + { + "name": "ids", + "long_name": "ids( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 1268, + "end_line": 1270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "iscontiguous", + "long_name": "iscontiguous( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 1272, + "end_line": 1274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "itemsize", + "long_name": "itemsize( self )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 1276, + "end_line": 1278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , other )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "other" + ], + "start_line": 1281, + "end_line": 1283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "put", + "long_name": "put( self , values )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self", + "values" + ], + "start_line": 1285, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "putmask", + "long_name": "putmask( self , values )", + "filename": "ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self", + "values" + ], + "start_line": 1297, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "ravel", + "long_name": "ravel( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 1307, + "end_line": 1312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "raw_data", + "long_name": "raw_data( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1314, + "end_line": 1318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "raw_mask", + "long_name": "raw_mask( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 1322, + "end_line": 1326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "reshape", + "long_name": "reshape( self , * s )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 52, + "parameters": [ + "self", + "s" + ], + "start_line": 1330, + "end_line": 1337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "set_fill_value", + "long_name": "set_fill_value( self , v = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "v" + ], + "start_line": 1339, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_ndim", + "long_name": "_get_ndim( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1345, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_size", + "long_name": "_get_size( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1349, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_dtype", + "long_name": "_get_dtype( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 1354, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "item", + "long_name": "item( self )", + "filename": "ma.py", + "nloc": 10, + "complexity": 4, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 1358, + "end_line": 1367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1369, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "tostring", + "long_name": "tostring( self , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "fill_value" + ], + "start_line": 1373, + "end_line": 1375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unmask", + "long_name": "unmask( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 3, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 1377, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "unshare_mask", + "long_name": "unshare_mask( self )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 1385, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "isMaskedArray", + "long_name": "isMaskedArray( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [ + "x" + ], + "start_line": 1409, + "end_line": 1411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , fill_value = 1 , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 1, + "token_count": 140, + "parameters": [ + "a", + "b", + "fill_value", + "rtol", + "atol" + ], + "start_line": 1416, + "end_line": 1431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "allequal", + "long_name": "allequal( a , b , fill_value = 1 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 3, + "token_count": 125, + "parameters": [ + "a", + "b", + "fill_value" + ], + "start_line": 1433, + "end_line": 1451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "masked_values", + "long_name": "masked_values( data , value , rtol = 1 . e - 5 , atol = 1 . e - 8 , copy = 1 )", + "filename": "ma.py", + "nloc": 10, + "complexity": 2, + "token_count": 117, + "parameters": [ + "data", + "value", + "rtol", + "atol", + "copy" + ], + "start_line": 1453, + "end_line": 1472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "masked_object", + "long_name": "masked_object( data , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "data", + "value", + "copy" + ], + "start_line": 1474, + "end_line": 1478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arrayrange", + "long_name": "arrayrange( start , stop = None , step = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 1480, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fromstring", + "long_name": "fromstring( s , t )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "s", + "t" + ], + "start_line": 1488, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "left_shift", + "long_name": "left_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1492, + "end_line": 1500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "right_shift", + "long_name": "right_shift( a , n )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n" + ], + "start_line": 1502, + "end_line": 1510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 1512, + "end_line": 1520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 101, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 1522, + "end_line": 1537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "n" + ], + "start_line": 1539, + "end_line": 1542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 1544, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "zeros", + "long_name": "zeros( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1550, + "end_line": 1553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "shape", + "dtype" + ], + "start_line": 1555, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "count", + "long_name": "count( a , axis = None )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 1561, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( a , b , third = None )", + "filename": "ma.py", + "nloc": 18, + "complexity": 4, + "token_count": 154, + "parameters": [ + "a", + "b", + "third" + ], + "start_line": 1566, + "end_line": 1583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "masked_array", + "long_name": "masked_array( a , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "mask", + "fill_value" + ], + "start_line": 1585, + "end_line": 1589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "average", + "long_name": "average( a , axis = 0 , weights = None , returned = 0 )", + "filename": "ma.py", + "nloc": 92, + "complexity": 22, + "token_count": 741, + "parameters": [ + "a", + "axis", + "weights", + "returned" + ], + "start_line": 1594, + "end_line": 1701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 11, + "complexity": 1, + "token_count": 107, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1703, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "choose.fmask", + "long_name": "choose.fmask( x )", + "filename": "ma.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "x" + ], + "start_line": 1723, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "choose.nmask", + "long_name": "choose.nmask( x )", + "filename": "ma.py", + "nloc": 5, + "complexity": 3, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 1726, + "end_line": 1730, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "choose", + "long_name": "choose( indices , t )", + "filename": "ma.py", + "nloc": 11, + "complexity": 3, + "token_count": 93, + "parameters": [ + "indices", + "t" + ], + "start_line": 1721, + "end_line": 1737, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "masked_where", + "long_name": "masked_where( condition , x , copy = 1 )", + "filename": "ma.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "condition", + "x", + "copy" + ], + "start_line": 1739, + "end_line": 1745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "masked_greater", + "long_name": "masked_greater( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1747, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_greater_equal", + "long_name": "masked_greater_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1751, + "end_line": 1753, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less", + "long_name": "masked_less( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1755, + "end_line": 1757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_less_equal", + "long_name": "masked_less_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1759, + "end_line": 1761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "masked_not_equal", + "long_name": "masked_not_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1763, + "end_line": 1768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "masked_equal", + "long_name": "masked_equal( x , value , copy = 1 )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "x", + "value", + "copy" + ], + "start_line": 1770, + "end_line": 1777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "masked_inside", + "long_name": "masked_inside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1779, + "end_line": 1790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "masked_outside", + "long_name": "masked_outside( x , v1 , v2 , copy = 1 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "x", + "v1", + "v2", + "copy" + ], + "start_line": 1792, + "end_line": 1803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , * newshape )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 56, + "parameters": [ + "a", + "newshape" + ], + "start_line": 1805, + "end_line": 1812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( a )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "a" + ], + "start_line": 1814, + "end_line": 1821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "concatenate", + "long_name": "concatenate( arrays , axis = 0 )", + "filename": "ma.py", + "nloc": 15, + "complexity": 5, + "token_count": 97, + "parameters": [ + "arrays", + "axis" + ], + "start_line": 1823, + "end_line": 1837, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 1839, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1849, + "end_line": 1858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1860, + "end_line": 1868, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , indices , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 70, + "parameters": [ + "a", + "indices", + "values" + ], + "start_line": 1871, + "end_line": 1884, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , values )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 61, + "parameters": [ + "a", + "mask", + "values" + ], + "start_line": 1886, + "end_line": 1894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "innerproduct", + "long_name": "innerproduct( a , b )", + "filename": "ma.py", + "nloc": 6, + "complexity": 3, + "token_count": 72, + "parameters": [ + "a", + "b" + ], + "start_line": 1896, + "end_line": 1906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "outerproduct", + "long_name": "outerproduct( a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 110, + "parameters": [ + "a", + "b" + ], + "start_line": 1908, + "end_line": 1920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dot", + "long_name": "dot( a , b )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 36, + "parameters": [ + "a", + "b" + ], + "start_line": 1922, + "end_line": 1927, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , x , dimension = - 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 67, + "parameters": [ + "condition", + "x", + "dimension" + ], + "start_line": 1929, + "end_line": 1938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1942, + "end_line": 1946, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1948, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 1963, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1974, + "end_line": 1985, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1991, + "end_line": 1995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b = None )", + "filename": "ma.py", + "nloc": 14, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 1997, + "end_line": 2010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 2012, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "outer", + "long_name": "outer( self , a , b )", + "filename": "ma.py", + "nloc": 12, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 2023, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "sort", + "long_name": "sort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 3, + "token_count": 68, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2038, + "end_line": 2055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , k = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 73, + "parameters": [ + "a", + "k", + "axis1", + "axis2" + ], + "start_line": 2057, + "end_line": 2064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 2066, + "end_line": 2070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2072, + "end_line": 2079, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2081, + "end_line": 2089, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( x , axis = - 1 , fill_value = None )", + "filename": "ma.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "x", + "axis", + "fill_value" + ], + "start_line": 2091, + "end_line": 2105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( f , s )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "f", + "s" + ], + "start_line": 2107, + "end_line": 2109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( data , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 4, + "token_count": 46, + "parameters": [ + "data", + "dtype" + ], + "start_line": 2111, + "end_line": 2117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_m", + "long_name": "_m( f )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "f" + ], + "start_line": 2123, + "end_line": 2124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( * args , ** kwds )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "args", + "kwds" + ], + "start_line": 2125, + "end_line": 2126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_choose", + "long_name": "_choose( self , * args )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "args" + ], + "start_line": 2135, + "end_line": 2136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_clip", + "long_name": "_clip( self , a_min , a_max )", + "filename": "ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "a_min", + "a_max" + ], + "start_line": 2140, + "end_line": 2144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_compress", + "long_name": "_compress( self , cond , axis = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "cond", + "axis" + ], + "start_line": 2147, + "end_line": 2148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_cumprod", + "long_name": "_cumprod( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2155, + "end_line": 2159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_cumsum", + "long_name": "_cumsum( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2162, + "end_line": 2166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_max", + "long_name": "_max( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2177, + "end_line": 2181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_min", + "long_name": "_min( a , axis = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "a", + "axis" + ], + "start_line": 2184, + "end_line": 2188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_ptp", + "long_name": "_ptp( a , axis = 0 )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "a", + "axis" + ], + "start_line": 2197, + "end_line": 2198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_squeeze", + "long_name": "_squeeze( self )", + "filename": "ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 2207, + "end_line": 2213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_swapaxes", + "long_name": "_swapaxes( self , axis1 , axis2 )", + "filename": "ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "axis1", + "axis2" + ], + "start_line": 2218, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_var", + "long_name": "_var( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 86, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2227, + "end_line": 2234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_std", + "long_name": "_std( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2235, + "end_line": 2236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_cumprod", + "long_name": "_cumprod( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2155, + "end_line": 2159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_cumsum", + "long_name": "_cumsum( self , axis = 0 , dtype = None )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self", + "axis", + "dtype" + ], + "start_line": 2162, + "end_line": 2166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 1737, + "complexity": 474, + "token_count": 12423, + "diff_parsed": { + "added": [ + " m = umath.logical_or.accumulate(self.mask, axis)", + " m = umath.logical_or.accumulate(self.mask, axis)" + ], + "deleted": [ + " m = umath.logical_and.accumulate(self.mask, axis)", + " m = umath.logical_and.accumulate(self.mask, axis)" + ] + } + } + ] + }, + { + "hash": "1bca125a3f0c1e86b7777adebcdde5671b713f92", + "msg": "Fix ticket 48.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-08T08:13:56+00:00", + "author_timezone": 0, + "committer_date": "2006-04-08T08:13:56+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "18c2a959e5ef86a576cc13470ac845174b57a39c" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 7, + "insertions": 18, + "lines": 25, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/command/config_compiler.py", + "new_path": "numpy/distutils/command/config_compiler.py", + "filename": "config_compiler.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -5,6 +5,17 @@\n #XXX: Implement confic_cc for enhancing C/C++ compiler options.\n #XXX: Linker flags\n \n+def show_fortran_compilers(_cache=[]):\n+ # Using cache to prevent infinite recursion\n+ if _cache: return\n+ _cache.append(1)\n+ \n+ from numpy.distutils.fcompiler import show_fcompilers\n+ import distutils.core\n+ dist = distutils.core._setup_distribution\n+ show_fcompilers(dist)\n+ return\n+\n class config_fc(Command):\n \"\"\" Distutils command to hold user specified options\n to Fortran compilers.\n@@ -23,10 +34,14 @@ class config_fc(Command):\n ('debug','g',\"compile with debugging information\"),\n ('noopt',None,\"compile without optimization\"),\n ('noarch',None,\"compile without arch-dependent optimization\"),\n- ('help-fcompiler',None,\"list available Fortran compilers\"),\n ]\n \n- boolean_options = ['debug','noopt','noarch','help-fcompiler']\n+ help_options = [\n+ ('help-fcompiler',None, \"list available Fortran compilers\",\n+ show_fortran_compilers),\n+ ]\n+\n+ boolean_options = ['debug','noopt','noarch']\n \n def initialize_options(self):\n self.fcompiler = None\n@@ -39,14 +54,10 @@ def initialize_options(self):\n self.debug = None\n self.noopt = None\n self.noarch = None\n- self.help_fcompiler = None\n return\n \n def finalize_options(self):\n- if self.help_fcompiler:\n- from numpy.distutils.fcompiler import show_fcompilers\n- show_fcompilers(self.distribution)\n- sys.exit()\n+ # Do nothing.\n return\n \n def run(self):\n", + "added_lines": 18, + "deleted_lines": 7, + "source_code": "\nimport sys\nfrom distutils.core import Command\n\n#XXX: Implement confic_cc for enhancing C/C++ compiler options.\n#XXX: Linker flags\n\ndef show_fortran_compilers(_cache=[]):\n # Using cache to prevent infinite recursion\n if _cache: return\n _cache.append(1)\n \n from numpy.distutils.fcompiler import show_fcompilers\n import distutils.core\n dist = distutils.core._setup_distribution\n show_fcompilers(dist)\n return\n\nclass config_fc(Command):\n \"\"\" Distutils command to hold user specified options\n to Fortran compilers.\n\n config_fc command is used by the FCompiler.customize() method.\n \"\"\"\n\n user_options = [\n ('fcompiler=',None,\"specify Fortran compiler type\"),\n ('f77exec=', None, \"specify F77 compiler command\"),\n ('f90exec=', None, \"specify F90 compiler command\"),\n ('f77flags=',None,\"specify F77 compiler flags\"),\n ('f90flags=',None,\"specify F90 compiler flags\"),\n ('opt=',None,\"specify optimization flags\"),\n ('arch=',None,\"specify architecture specific optimization flags\"),\n ('debug','g',\"compile with debugging information\"),\n ('noopt',None,\"compile without optimization\"),\n ('noarch',None,\"compile without arch-dependent optimization\"),\n ]\n\n help_options = [\n ('help-fcompiler',None, \"list available Fortran compilers\",\n show_fortran_compilers),\n ]\n\n boolean_options = ['debug','noopt','noarch']\n\n def initialize_options(self):\n self.fcompiler = None\n self.f77exec = None\n self.f90exec = None\n self.f77flags = None\n self.f90flags = None\n self.opt = None\n self.arch = None\n self.debug = None\n self.noopt = None\n self.noarch = None\n return\n\n def finalize_options(self):\n # Do nothing.\n return\n\n def run(self):\n # Do nothing.\n return\n", + "source_code_before": "\nimport sys\nfrom distutils.core import Command\n\n#XXX: Implement confic_cc for enhancing C/C++ compiler options.\n#XXX: Linker flags\n\nclass config_fc(Command):\n \"\"\" Distutils command to hold user specified options\n to Fortran compilers.\n\n config_fc command is used by the FCompiler.customize() method.\n \"\"\"\n\n user_options = [\n ('fcompiler=',None,\"specify Fortran compiler type\"),\n ('f77exec=', None, \"specify F77 compiler command\"),\n ('f90exec=', None, \"specify F90 compiler command\"),\n ('f77flags=',None,\"specify F77 compiler flags\"),\n ('f90flags=',None,\"specify F90 compiler flags\"),\n ('opt=',None,\"specify optimization flags\"),\n ('arch=',None,\"specify architecture specific optimization flags\"),\n ('debug','g',\"compile with debugging information\"),\n ('noopt',None,\"compile without optimization\"),\n ('noarch',None,\"compile without arch-dependent optimization\"),\n ('help-fcompiler',None,\"list available Fortran compilers\"),\n ]\n\n boolean_options = ['debug','noopt','noarch','help-fcompiler']\n\n def initialize_options(self):\n self.fcompiler = None\n self.f77exec = None\n self.f90exec = None\n self.f77flags = None\n self.f90flags = None\n self.opt = None\n self.arch = None\n self.debug = None\n self.noopt = None\n self.noarch = None\n self.help_fcompiler = None\n return\n\n def finalize_options(self):\n if self.help_fcompiler:\n from numpy.distutils.fcompiler import show_fcompilers\n show_fcompilers(self.distribution)\n sys.exit()\n return\n\n def run(self):\n # Do nothing.\n return\n", + "methods": [ + { + "name": "show_fortran_compilers", + "long_name": "show_fortran_compilers( _cache = [ ] )", + "filename": "config_compiler.py", + "nloc": 8, + "complexity": 2, + "token_count": 42, + "parameters": [ + "_cache" + ], + "start_line": 8, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "config_compiler.py", + "nloc": 12, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "config_compiler.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [ + "self" + ], + "start_line": 59, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "config_compiler.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [ + "self" + ], + "start_line": 63, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "config_compiler.py", + "nloc": 13, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 31, + "end_line": 43, + "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": "config_compiler.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "config_compiler.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [ + "self" + ], + "start_line": 52, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "show_fortran_compilers", + "long_name": "show_fortran_compilers( _cache = [ ] )", + "filename": "config_compiler.py", + "nloc": 8, + "complexity": 2, + "token_count": 42, + "parameters": [ + "_cache" + ], + "start_line": 8, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "config_compiler.py", + "nloc": 13, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 31, + "end_line": 43, + "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": "config_compiler.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [ + "self" + ], + "start_line": 59, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": 49, + "complexity": 5, + "token_count": 236, + "diff_parsed": { + "added": [ + "def show_fortran_compilers(_cache=[]):", + " # Using cache to prevent infinite recursion", + " if _cache: return", + " _cache.append(1)", + "", + " from numpy.distutils.fcompiler import show_fcompilers", + " import distutils.core", + " dist = distutils.core._setup_distribution", + " show_fcompilers(dist)", + " return", + "", + " help_options = [", + " ('help-fcompiler',None, \"list available Fortran compilers\",", + " show_fortran_compilers),", + " ]", + "", + " boolean_options = ['debug','noopt','noarch']", + " # Do nothing." + ], + "deleted": [ + " ('help-fcompiler',None,\"list available Fortran compilers\"),", + " boolean_options = ['debug','noopt','noarch','help-fcompiler']", + " self.help_fcompiler = None", + " if self.help_fcompiler:", + " from numpy.distutils.fcompiler import show_fcompilers", + " show_fcompilers(self.distribution)", + " sys.exit()" + ] + } + } + ] + }, + { + "hash": "5cb0f8bb28951f09beec7036601eab8796ab5d03", + "msg": "Removed cc_dynamic from libraries list for Gnu95FCompiler (darwin).", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-08T08:37:32+00:00", + "author_timezone": 0, + "committer_date": "2006-04-08T08:37:32+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1bca125a3f0c1e86b7777adebcdde5671b713f92" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 0, + "insertions": 6, + "lines": 6, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/fcompiler/gnu.py", + "new_path": "numpy/distutils/fcompiler/gnu.py", + "filename": "gnu.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -247,6 +247,12 @@ class Gnu95FCompiler(GnuFCompiler):\n \n g2c = 'gfortran'\n \n+ def get_libraries(self):\n+ opt = GnuFCompiler.get_libraries(self)\n+ if sys.platform == 'darwin':\n+ opt.remove('cc_dynamic') \n+ return opt\n+\n if __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n", + "added_lines": 6, + "deleted_lines": 0, + "source_code": "\nimport re\nimport os\nimport sys\nimport warnings\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.ccompiler import simple_version_match\nfrom numpy.distutils.fcompiler import FCompiler\nfrom numpy.distutils.exec_command import exec_command, find_executable\nfrom numpy.distutils.misc_util import mingw32\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_match = simple_version_match(start=r'GNU Fortran (?!95)')\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,\"-Wall\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n 'linker_exe' : [fc_exe,\"-Wall\"]\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 g2c = 'g2c'\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 target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)\n if target is None:\n target = '10.3'\n major, minor = target.split('.')\n if int(minor) < 3:\n minor = '3'\n warnings.warn('Environment variable '\n 'MACOSX_DEPLOYMENT_TARGET reset to 10.3')\n os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major,\n minor)\n\n opt.extend(['-undefined', 'dynamic_lookup', '-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 g2c = self.g2c + '-pic'\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if not os.path.isfile(os.path.join(d,f)):\n g2c = self.g2c\n else:\n g2c = self.g2c\n\n if sys.platform=='win32':\n # To avoid undefined reference __EH_FRAME_BEGIN__ linker error,\n # don't use -lgcc option for mingw32 g77 linker.\n if not mingw32():\n opt.append('gcc')\n if g2c is not None:\n opt.append(g2c)\n if sys.platform == 'darwin':\n opt.append('cc_dynamic')\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n if self.get_version()<='3.3.3':\n # With this compiler version building Fortran BLAS/LAPACK\n # with -O3 caused failures in lib.lapack heevr,syevr tests.\n opt = ['-O2']\n else:\n opt = ['-O3']\n opt.append('-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\n # default march options in case we find nothing better\n if cpu.is_i686():\n march_opt = '-march=i686'\n elif cpu.is_i586():\n march_opt = '-march=i586'\n elif cpu.is_i486():\n march_opt = '-march=i486'\n elif cpu.is_i386():\n march_opt = '-march=i386'\n else:\n march_opt = ''\n\n gnu_ver = self.get_version()\n\n if gnu_ver >= '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n march_opt = '-march=k6'\n elif cpu.is_AthlonK7():\n march_opt = '-march=athlon'\n\n if gnu_ver >= '3.1.1':\n if cpu.is_AthlonK6_2():\n march_opt = '-march=k6-2'\n elif cpu.is_AthlonK6_3():\n march_opt = '-march=k6-3'\n elif cpu.is_AthlonMP():\n march_opt = '-march=athlon-mp'\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_Nocona():\n march_opt = '-march=nocona'\n elif cpu.is_Prescott():\n march_opt = '-march=prescott'\n elif cpu.is_PentiumIV():\n march_opt = '-march=pentium4'\n elif cpu.is_PentiumIII():\n march_opt = '-march=pentium3'\n elif cpu.is_PentiumM():\n march_opt = '-march=pentium3'\n elif cpu.is_PentiumII():\n march_opt = '-march=pentium2'\n\n if gnu_ver >= '3.4':\n if cpu.is_Opteron():\n march_opt = '-march=opteron'\n elif cpu.is_Athlon64():\n march_opt = '-march=athlon64'\n\n if gnu_ver >= '3.4.4':\n if cpu.is_PentiumM():\n march_opt = '-march=pentium-m'\n\n # Note: gcc 3.2 on win32 has breakage with -march specified\n if '3.1.1' <= gnu_ver <= '3.4' and sys.platform=='win32':\n march_opt = ''\n\n if march_opt:\n opt.append(march_opt)\n\n # other CPU flags\n if gnu_ver >= '3.1.1':\n if cpu.has_mmx(): opt.append('-mmmx')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n\n if gnu_ver > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if gnu_ver >= '3.4':\n if cpu.has_sse3(): opt.append('-msse3')\n if cpu.is_Intel():\n opt.append('-fomit-frame-pointer')\n if cpu.is_32bit():\n opt.append('-malign-double')\n return opt\n\nclass Gnu95FCompiler(GnuFCompiler):\n\n compiler_type = 'gnu95'\n version_match = simple_version_match(start='GNU Fortran 95')\n\n # 'gfortran --version' results:\n # Debian: GNU Fortran 95 (GCC 4.0.3 20051023 (prerelease) (Debian 4.0.2-3))\n # OS X: GNU Fortran 95 (GCC) 4.1.0\n # GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental)\n\n for fc_exe in map(find_executable,['gfortran','f95']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-ffixed-form\",\"-fno-second-underscore\"],\n 'compiler_f90' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_fix' : [fc_exe,\"-Wall\",\"-ffixed-form\",\"-fno-second-underscore\"],\n 'linker_so' : [fc_exe,\"-Wall\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n 'linker_exe' : [fc_exe,\"-Wall\"]\n }\n module_dir_switch = '-J'\n module_include_switch = '-I'\n\n g2c = 'gfortran'\n\n def get_libraries(self):\n opt = GnuFCompiler.get_libraries(self)\n if sys.platform == 'darwin':\n opt.remove('cc_dynamic') \n return opt\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.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\nimport warnings\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.ccompiler import simple_version_match\nfrom numpy.distutils.fcompiler import FCompiler\nfrom numpy.distutils.exec_command import exec_command, find_executable\nfrom numpy.distutils.misc_util import mingw32\n\nclass GnuFCompiler(FCompiler):\n\n compiler_type = 'gnu'\n version_match = simple_version_match(start=r'GNU Fortran (?!95)')\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,\"-Wall\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n 'linker_exe' : [fc_exe,\"-Wall\"]\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 g2c = 'g2c'\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 target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)\n if target is None:\n target = '10.3'\n major, minor = target.split('.')\n if int(minor) < 3:\n minor = '3'\n warnings.warn('Environment variable '\n 'MACOSX_DEPLOYMENT_TARGET reset to 10.3')\n os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major,\n minor)\n\n opt.extend(['-undefined', 'dynamic_lookup', '-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 g2c = self.g2c + '-pic'\n f = self.static_lib_format % (g2c, self.static_lib_extension)\n if not os.path.isfile(os.path.join(d,f)):\n g2c = self.g2c\n else:\n g2c = self.g2c\n\n if sys.platform=='win32':\n # To avoid undefined reference __EH_FRAME_BEGIN__ linker error,\n # don't use -lgcc option for mingw32 g77 linker.\n if not mingw32():\n opt.append('gcc')\n if g2c is not None:\n opt.append(g2c)\n if sys.platform == 'darwin':\n opt.append('cc_dynamic')\n return opt\n\n def get_flags_debug(self):\n return ['-g']\n\n def get_flags_opt(self):\n if self.get_version()<='3.3.3':\n # With this compiler version building Fortran BLAS/LAPACK\n # with -O3 caused failures in lib.lapack heevr,syevr tests.\n opt = ['-O2']\n else:\n opt = ['-O3']\n opt.append('-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\n # default march options in case we find nothing better\n if cpu.is_i686():\n march_opt = '-march=i686'\n elif cpu.is_i586():\n march_opt = '-march=i586'\n elif cpu.is_i486():\n march_opt = '-march=i486'\n elif cpu.is_i386():\n march_opt = '-march=i386'\n else:\n march_opt = ''\n\n gnu_ver = self.get_version()\n\n if gnu_ver >= '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n march_opt = '-march=k6'\n elif cpu.is_AthlonK7():\n march_opt = '-march=athlon'\n\n if gnu_ver >= '3.1.1':\n if cpu.is_AthlonK6_2():\n march_opt = '-march=k6-2'\n elif cpu.is_AthlonK6_3():\n march_opt = '-march=k6-3'\n elif cpu.is_AthlonMP():\n march_opt = '-march=athlon-mp'\n # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_Nocona():\n march_opt = '-march=nocona'\n elif cpu.is_Prescott():\n march_opt = '-march=prescott'\n elif cpu.is_PentiumIV():\n march_opt = '-march=pentium4'\n elif cpu.is_PentiumIII():\n march_opt = '-march=pentium3'\n elif cpu.is_PentiumM():\n march_opt = '-march=pentium3'\n elif cpu.is_PentiumII():\n march_opt = '-march=pentium2'\n\n if gnu_ver >= '3.4':\n if cpu.is_Opteron():\n march_opt = '-march=opteron'\n elif cpu.is_Athlon64():\n march_opt = '-march=athlon64'\n\n if gnu_ver >= '3.4.4':\n if cpu.is_PentiumM():\n march_opt = '-march=pentium-m'\n\n # Note: gcc 3.2 on win32 has breakage with -march specified\n if '3.1.1' <= gnu_ver <= '3.4' and sys.platform=='win32':\n march_opt = ''\n\n if march_opt:\n opt.append(march_opt)\n\n # other CPU flags\n if gnu_ver >= '3.1.1':\n if cpu.has_mmx(): opt.append('-mmmx')\n if cpu.has_3dnow(): opt.append('-m3dnow')\n\n if gnu_ver > '3.2.2':\n if cpu.has_sse2(): opt.append('-msse2')\n if cpu.has_sse(): opt.append('-msse')\n if gnu_ver >= '3.4':\n if cpu.has_sse3(): opt.append('-msse3')\n if cpu.is_Intel():\n opt.append('-fomit-frame-pointer')\n if cpu.is_32bit():\n opt.append('-malign-double')\n return opt\n\nclass Gnu95FCompiler(GnuFCompiler):\n\n compiler_type = 'gnu95'\n version_match = simple_version_match(start='GNU Fortran 95')\n\n # 'gfortran --version' results:\n # Debian: GNU Fortran 95 (GCC 4.0.3 20051023 (prerelease) (Debian 4.0.2-3))\n # OS X: GNU Fortran 95 (GCC) 4.1.0\n # GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental)\n\n for fc_exe in map(find_executable,['gfortran','f95']):\n if os.path.isfile(fc_exe):\n break\n executables = {\n 'version_cmd' : [fc_exe,\"--version\"],\n 'compiler_f77' : [fc_exe,\"-Wall\",\"-ffixed-form\",\"-fno-second-underscore\"],\n 'compiler_f90' : [fc_exe,\"-Wall\",\"-fno-second-underscore\"],\n 'compiler_fix' : [fc_exe,\"-Wall\",\"-ffixed-form\",\"-fno-second-underscore\"],\n 'linker_so' : [fc_exe,\"-Wall\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"],\n 'linker_exe' : [fc_exe,\"-Wall\"]\n }\n module_dir_switch = '-J'\n module_include_switch = '-I'\n\n g2c = 'gfortran'\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.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": "gnu.py", + "nloc": 19, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "get_libgcc_dir", + "long_name": "get_libgcc_dir( self )", + "filename": "gnu.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 86, + "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": "gnu.py", + "nloc": 7, + "complexity": 3, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 94, + "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": "gnu.py", + "nloc": 18, + "complexity": 7, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "gnu.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "gnu.py", + "nloc": 7, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 121, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "gnu.py", + "nloc": 75, + "complexity": 42, + "token_count": 436, + "parameters": [ + "self" + ], + "start_line": 131, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + }, + { + "name": "get_libraries", + "long_name": "get_libraries( self )", + "filename": "gnu.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "gnu.py", + "nloc": 19, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "get_libgcc_dir", + "long_name": "get_libgcc_dir( self )", + "filename": "gnu.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 86, + "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": "gnu.py", + "nloc": 7, + "complexity": 3, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 94, + "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": "gnu.py", + "nloc": 18, + "complexity": 7, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "gnu.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "gnu.py", + "nloc": 7, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 121, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "gnu.py", + "nloc": 75, + "complexity": 42, + "token_count": 436, + "parameters": [ + "self" + ], + "start_line": 131, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "get_libraries", + "long_name": "get_libraries( self )", + "filename": "gnu.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "nloc": 195, + "complexity": 64, + "token_count": 1175, + "diff_parsed": { + "added": [ + " def get_libraries(self):", + " opt = GnuFCompiler.get_libraries(self)", + " if sys.platform == 'darwin':", + " opt.remove('cc_dynamic')", + " return opt", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "6932d858cf4701106a7cedf0edce70c34bf75925", + "msg": "Add support to specify config_fc option in setup.py file.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-08T17:10:26+00:00", + "author_timezone": 0, + "committer_date": "2006-04-08T17:10:26+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "5cb0f8bb28951f09beec7036601eab8796ab5d03" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 4, + "insertions": 24, + "lines": 28, + "files": 2, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/command/build_clib.py", + "new_path": "numpy/distutils/command/build_clib.py", + "filename": "build_clib.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -91,10 +91,12 @@ def get_source_files(self):\n \n def build_libraries(self, libraries):\n \n- compiler = self.compiler\n- fcompiler = self.fcompiler\n \n for (lib_name, build_info) in libraries:\n+ # default compilers\n+ compiler = self.compiler\n+ fcompiler = self.fcompiler\n+\n sources = build_info.get('sources')\n if sources is None or not is_sequence(sources):\n raise DistutilsSetupError, \\\n@@ -103,6 +105,8 @@ def build_libraries(self, libraries):\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n \n+\n+ \n lib_file = compiler.library_filename(lib_name,\n output_dir=self.build_clib)\n \n@@ -113,6 +117,18 @@ def build_libraries(self, libraries):\n else:\n log.info(\"building '%s' library\", lib_name)\n \n+\n+ config_fc = build_info.get('config_fc',{})\n+ if fcompiler is not None and config_fc:\n+ log.info('using setup script specified config_fc for fortran compiler: %s' \\\n+ % (config_fc))\n+ from numpy.distutils.fcompiler import new_fcompiler\n+ fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,\n+ verbose=self.verbose,\n+ dry_run=self.dry_run,\n+ force=self.force)\n+ fcompiler.customize(config_fc)\n+\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n extra_postargs = build_info.get('extra_compiler_args') or []\n", + "added_lines": 18, + "deleted_lines": 2, + "source_code": "\"\"\" Modified version of build_clib that handles fortran source files.\n\"\"\"\n\nfrom distutils.command.build_clib import build_clib as old_build_clib\nfrom distutils.errors import DistutilsSetupError\n\nfrom numpy.distutils import log\nfrom distutils.dep_util import newer_group\nfrom numpy.distutils.misc_util import filter_sources, has_f_sources,\\\n has_cxx_sources, all_strings, get_lib_source_files, is_sequence\n\nclass build_clib(old_build_clib):\n\n description = \"build C/C++/F libraries used by Python extensions\"\n\n user_options = old_build_clib.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_clib.initialize_options(self)\n self.fcompiler = None\n return\n\n def finalize_options(self):\n old_build_clib.finalize_options(self)\n self.set_undefined_options('build_ext',\n ('fcompiler', 'fcompiler'))\n return\n\n def have_f_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_f_sources(build_info.get('sources',[])):\n return True\n return False\n\n def have_cxx_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_cxx_sources(build_info.get('sources',[])):\n return True\n return False\n\n def run(self):\n if not self.libraries:\n return\n\n # Make sure that library sources are complete.\n for (lib_name, build_info) in self.libraries:\n if not all_strings(build_info.get('sources',[])):\n self.run_command('build_src')\n\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n dry_run=self.dry_run,\n force=self.force)\n self.compiler.customize(self.distribution,\n need_cxx=self.have_cxx_sources())\n\n libraries = self.libraries\n self.libraries = None\n self.compiler.customize_cmd(self)\n self.libraries = libraries\n\n self.compiler.show_customization()\n\n if self.have_f_sources():\n from numpy.distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n\n libraries = self.libraries\n self.libraries = None\n self.fcompiler.customize_cmd(self)\n self.libraries = libraries\n\n self.fcompiler.show_customization()\n\n self.build_libraries(self.libraries)\n return\n\n def get_source_files(self):\n self.check_library_list(self.libraries)\n filenames = []\n for lib in self.libraries:\n filenames.extend(get_lib_source_files(lib))\n return filenames\n\n def build_libraries(self, libraries):\n\n\n for (lib_name, build_info) in libraries:\n # default compilers\n compiler = self.compiler\n fcompiler = self.fcompiler\n\n sources = build_info.get('sources')\n if sources is None or not is_sequence(sources):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n\n \n lib_file = compiler.library_filename(lib_name,\n output_dir=self.build_clib)\n\n depends = sources + build_info.get('depends',[])\n if not (self.force or newer_group(depends, lib_file, 'newer')):\n log.debug(\"skipping '%s' library (up-to-date)\", lib_name)\n continue\n else:\n log.info(\"building '%s' library\", lib_name)\n\n\n config_fc = build_info.get('config_fc',{})\n if fcompiler is not None and config_fc:\n log.info('using setup script specified config_fc for fortran compiler: %s' \\\n % (config_fc))\n from numpy.distutils.fcompiler import new_fcompiler\n fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n fcompiler.customize(config_fc)\n\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n extra_postargs = build_info.get('extra_compiler_args') or []\n\n c_sources, cxx_sources, f_sources, fmodule_sources \\\n = filter_sources(sources)\n\n if self.compiler.compiler_type=='msvc':\n # this hack works around the msvc compiler attributes\n # problem, msvc uses its own convention :(\n c_sources += cxx_sources\n cxx_sources = []\n\n if fmodule_sources:\n print 'XXX: Fortran 90 module support not implemented or tested'\n f_sources.extend(fmodule_sources)\n\n objects = []\n if c_sources:\n log.info(\"compiling C sources\")\n objects = compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n\n if cxx_sources:\n log.info(\"compiling C++ sources\")\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n\n cxx_objects = compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n objects.extend(cxx_objects)\n\n self.compiler.compiler_so[0] = old_compiler\n\n if f_sources:\n log.info(\"compiling Fortran sources\")\n f_objects = fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=[])\n objects.extend(f_objects)\n\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n\n clib_libraries = build_info.get('libraries',[])\n for lname,binfo in libraries:\n if lname in clib_libraries:\n clib_libraries.extend(binfo[1].get('libraries',[]))\n if clib_libraries:\n build_info['libraries'] = clib_libraries\n\n return\n", + "source_code_before": "\"\"\" Modified version of build_clib that handles fortran source files.\n\"\"\"\n\nfrom distutils.command.build_clib import build_clib as old_build_clib\nfrom distutils.errors import DistutilsSetupError\n\nfrom numpy.distutils import log\nfrom distutils.dep_util import newer_group\nfrom numpy.distutils.misc_util import filter_sources, has_f_sources,\\\n has_cxx_sources, all_strings, get_lib_source_files, is_sequence\n\nclass build_clib(old_build_clib):\n\n description = \"build C/C++/F libraries used by Python extensions\"\n\n user_options = old_build_clib.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_clib.initialize_options(self)\n self.fcompiler = None\n return\n\n def finalize_options(self):\n old_build_clib.finalize_options(self)\n self.set_undefined_options('build_ext',\n ('fcompiler', 'fcompiler'))\n return\n\n def have_f_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_f_sources(build_info.get('sources',[])):\n return True\n return False\n\n def have_cxx_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_cxx_sources(build_info.get('sources',[])):\n return True\n return False\n\n def run(self):\n if not self.libraries:\n return\n\n # Make sure that library sources are complete.\n for (lib_name, build_info) in self.libraries:\n if not all_strings(build_info.get('sources',[])):\n self.run_command('build_src')\n\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n dry_run=self.dry_run,\n force=self.force)\n self.compiler.customize(self.distribution,\n need_cxx=self.have_cxx_sources())\n\n libraries = self.libraries\n self.libraries = None\n self.compiler.customize_cmd(self)\n self.libraries = libraries\n\n self.compiler.show_customization()\n\n if self.have_f_sources():\n from numpy.distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n\n libraries = self.libraries\n self.libraries = None\n self.fcompiler.customize_cmd(self)\n self.libraries = libraries\n\n self.fcompiler.show_customization()\n\n self.build_libraries(self.libraries)\n return\n\n def get_source_files(self):\n self.check_library_list(self.libraries)\n filenames = []\n for lib in self.libraries:\n filenames.extend(get_lib_source_files(lib))\n return filenames\n\n def build_libraries(self, libraries):\n\n compiler = self.compiler\n fcompiler = self.fcompiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or not is_sequence(sources):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n lib_file = compiler.library_filename(lib_name,\n output_dir=self.build_clib)\n\n depends = sources + build_info.get('depends',[])\n if not (self.force or newer_group(depends, lib_file, 'newer')):\n log.debug(\"skipping '%s' library (up-to-date)\", lib_name)\n continue\n else:\n log.info(\"building '%s' library\", lib_name)\n\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n extra_postargs = build_info.get('extra_compiler_args') or []\n\n c_sources, cxx_sources, f_sources, fmodule_sources \\\n = filter_sources(sources)\n\n if self.compiler.compiler_type=='msvc':\n # this hack works around the msvc compiler attributes\n # problem, msvc uses its own convention :(\n c_sources += cxx_sources\n cxx_sources = []\n\n if fmodule_sources:\n print 'XXX: Fortran 90 module support not implemented or tested'\n f_sources.extend(fmodule_sources)\n\n objects = []\n if c_sources:\n log.info(\"compiling C sources\")\n objects = compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n\n if cxx_sources:\n log.info(\"compiling C++ sources\")\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n\n cxx_objects = compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n objects.extend(cxx_objects)\n\n self.compiler.compiler_so[0] = old_compiler\n\n if f_sources:\n log.info(\"compiling Fortran sources\")\n f_objects = fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=[])\n objects.extend(f_objects)\n\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n\n clib_libraries = build_info.get('libraries',[])\n for lname,binfo in libraries:\n if lname in clib_libraries:\n clib_libraries.extend(binfo[1].get('libraries',[]))\n if clib_libraries:\n build_info['libraries'] = clib_libraries\n\n return\n", + "methods": [ + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_clib.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_f_sources", + "long_name": "have_f_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_cxx_sources", + "long_name": "have_cxx_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "build_clib.py", + "nloc": 31, + "complexity": 5, + "token_count": 216, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "get_source_files", + "long_name": "get_source_files( self )", + "filename": "build_clib.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 80, + "complexity": 17, + "token_count": 517, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 104, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_clib.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_f_sources", + "long_name": "have_f_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_cxx_sources", + "long_name": "have_cxx_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "build_clib.py", + "nloc": 31, + "complexity": 5, + "token_count": 216, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "get_source_files", + "long_name": "get_source_files( self )", + "filename": "build_clib.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 70, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 80, + "complexity": 17, + "token_count": 517, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 104, + "top_nesting_level": 1 + } + ], + "nloc": 150, + "complexity": 32, + "token_count": 957, + "diff_parsed": { + "added": [ + " # default compilers", + " compiler = self.compiler", + " fcompiler = self.fcompiler", + "", + "", + "", + "", + " config_fc = build_info.get('config_fc',{})", + " if fcompiler is not None and config_fc:", + " log.info('using setup script specified config_fc for fortran compiler: %s' \\", + " % (config_fc))", + " from numpy.distutils.fcompiler import new_fcompiler", + " fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,", + " verbose=self.verbose,", + " dry_run=self.dry_run,", + " force=self.force)", + " fcompiler.customize(config_fc)", + "" + ], + "deleted": [ + " compiler = self.compiler", + " fcompiler = self.fcompiler" + ] + } + }, + { + "old_path": "numpy/distutils/fcompiler/__init__.py", + "new_path": "numpy/distutils/fcompiler/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -241,16 +241,20 @@ def customize(self, dist=None):\n instance is needed for (iii) and (iv).\n \"\"\"\n log.info('customize %s' % (self.__class__.__name__))\n+ from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\n- from distutils.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- conf = dist.get_option_dict('config_fc')\n+ elif isinstance(dist,Distribution):\n+ conf = dist.get_option_dict('config_fc')\n+ else:\n+ assert isinstance(dist,dict)\n+ conf = dist\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", + "added_lines": 6, + "deleted_lines": 2, + "source_code": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\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 elif isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n conf = dist\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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "source_code_before": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 distutils.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 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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "methods": [ + { + "name": "get_version_cmd", + "long_name": "get_version_cmd( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 360, + "end_line": 377, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 381, + "end_line": 417, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 419, + "end_line": 435, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 437, + "end_line": 438, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 439, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 442, + "end_line": 489, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 494, + "end_line": 507, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 509, + "end_line": 522, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 583, + "end_line": 596, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 598, + "end_line": 619, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 621, + "end_line": 658, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 660, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 714, + "end_line": 721, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 707, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 730, + "end_line": 751, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 753, + "end_line": 757, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 93, + "complexity": 38, + "token_count": 868, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 123, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 356, + "end_line": 373, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 377, + "end_line": 413, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 415, + "end_line": 431, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 433, + "end_line": 434, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 435, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 438, + "end_line": 485, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 490, + "end_line": 503, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 505, + "end_line": 518, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 579, + "end_line": 592, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 594, + "end_line": 615, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 617, + "end_line": 654, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 656, + "end_line": 701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 710, + "end_line": 717, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 703, + "end_line": 719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 726, + "end_line": 747, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 749, + "end_line": 753, + "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": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + } + ], + "nloc": 628, + "complexity": 167, + "token_count": 4159, + "diff_parsed": { + "added": [ + " from distutils.dist import Distribution", + " elif isinstance(dist,Distribution):", + " conf = dist.get_option_dict('config_fc')", + " else:", + " assert isinstance(dist,dict)", + " conf = dist" + ], + "deleted": [ + " from distutils.dist import Distribution", + " conf = dist.get_option_dict('config_fc')" + ] + } + } + ] + }, + { + "hash": "a8e674757141889f3609890a1d89a8634abc98bb", + "msg": "Fixed typo.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-08T18:33:04+00:00", + "author_timezone": 0, + "committer_date": "2006-04-08T18:33:04+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "6932d858cf4701106a7cedf0edce70c34bf75925" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 2, + "insertions": 3, + "lines": 5, + "files": 2, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/distutils/command/build_clib.py", + "new_path": "numpy/distutils/command/build_clib.py", + "filename": "build_clib.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -120,7 +120,8 @@ def build_libraries(self, libraries):\n \n config_fc = build_info.get('config_fc',{})\n if fcompiler is not None and config_fc:\n- log.info('using setup script specified config_fc for fortran compiler: %s' \\\n+ log.info('using setup script specified config_fc '\\\n+ 'for fortran compiler: %s' \\\n % (config_fc))\n from numpy.distutils.fcompiler import new_fcompiler\n fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": "\"\"\" Modified version of build_clib that handles fortran source files.\n\"\"\"\n\nfrom distutils.command.build_clib import build_clib as old_build_clib\nfrom distutils.errors import DistutilsSetupError\n\nfrom numpy.distutils import log\nfrom distutils.dep_util import newer_group\nfrom numpy.distutils.misc_util import filter_sources, has_f_sources,\\\n has_cxx_sources, all_strings, get_lib_source_files, is_sequence\n\nclass build_clib(old_build_clib):\n\n description = \"build C/C++/F libraries used by Python extensions\"\n\n user_options = old_build_clib.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_clib.initialize_options(self)\n self.fcompiler = None\n return\n\n def finalize_options(self):\n old_build_clib.finalize_options(self)\n self.set_undefined_options('build_ext',\n ('fcompiler', 'fcompiler'))\n return\n\n def have_f_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_f_sources(build_info.get('sources',[])):\n return True\n return False\n\n def have_cxx_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_cxx_sources(build_info.get('sources',[])):\n return True\n return False\n\n def run(self):\n if not self.libraries:\n return\n\n # Make sure that library sources are complete.\n for (lib_name, build_info) in self.libraries:\n if not all_strings(build_info.get('sources',[])):\n self.run_command('build_src')\n\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n dry_run=self.dry_run,\n force=self.force)\n self.compiler.customize(self.distribution,\n need_cxx=self.have_cxx_sources())\n\n libraries = self.libraries\n self.libraries = None\n self.compiler.customize_cmd(self)\n self.libraries = libraries\n\n self.compiler.show_customization()\n\n if self.have_f_sources():\n from numpy.distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n\n libraries = self.libraries\n self.libraries = None\n self.fcompiler.customize_cmd(self)\n self.libraries = libraries\n\n self.fcompiler.show_customization()\n\n self.build_libraries(self.libraries)\n return\n\n def get_source_files(self):\n self.check_library_list(self.libraries)\n filenames = []\n for lib in self.libraries:\n filenames.extend(get_lib_source_files(lib))\n return filenames\n\n def build_libraries(self, libraries):\n\n\n for (lib_name, build_info) in libraries:\n # default compilers\n compiler = self.compiler\n fcompiler = self.fcompiler\n\n sources = build_info.get('sources')\n if sources is None or not is_sequence(sources):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n\n \n lib_file = compiler.library_filename(lib_name,\n output_dir=self.build_clib)\n\n depends = sources + build_info.get('depends',[])\n if not (self.force or newer_group(depends, lib_file, 'newer')):\n log.debug(\"skipping '%s' library (up-to-date)\", lib_name)\n continue\n else:\n log.info(\"building '%s' library\", lib_name)\n\n\n config_fc = build_info.get('config_fc',{})\n if fcompiler is not None and config_fc:\n log.info('using setup script specified config_fc '\\\n 'for fortran compiler: %s' \\\n % (config_fc))\n from numpy.distutils.fcompiler import new_fcompiler\n fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n fcompiler.customize(config_fc)\n\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n extra_postargs = build_info.get('extra_compiler_args') or []\n\n c_sources, cxx_sources, f_sources, fmodule_sources \\\n = filter_sources(sources)\n\n if self.compiler.compiler_type=='msvc':\n # this hack works around the msvc compiler attributes\n # problem, msvc uses its own convention :(\n c_sources += cxx_sources\n cxx_sources = []\n\n if fmodule_sources:\n print 'XXX: Fortran 90 module support not implemented or tested'\n f_sources.extend(fmodule_sources)\n\n objects = []\n if c_sources:\n log.info(\"compiling C sources\")\n objects = compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n\n if cxx_sources:\n log.info(\"compiling C++ sources\")\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n\n cxx_objects = compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n objects.extend(cxx_objects)\n\n self.compiler.compiler_so[0] = old_compiler\n\n if f_sources:\n log.info(\"compiling Fortran sources\")\n f_objects = fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=[])\n objects.extend(f_objects)\n\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n\n clib_libraries = build_info.get('libraries',[])\n for lname,binfo in libraries:\n if lname in clib_libraries:\n clib_libraries.extend(binfo[1].get('libraries',[]))\n if clib_libraries:\n build_info['libraries'] = clib_libraries\n\n return\n", + "source_code_before": "\"\"\" Modified version of build_clib that handles fortran source files.\n\"\"\"\n\nfrom distutils.command.build_clib import build_clib as old_build_clib\nfrom distutils.errors import DistutilsSetupError\n\nfrom numpy.distutils import log\nfrom distutils.dep_util import newer_group\nfrom numpy.distutils.misc_util import filter_sources, has_f_sources,\\\n has_cxx_sources, all_strings, get_lib_source_files, is_sequence\n\nclass build_clib(old_build_clib):\n\n description = \"build C/C++/F libraries used by Python extensions\"\n\n user_options = old_build_clib.user_options + [\n ('fcompiler=', None,\n \"specify the Fortran compiler type\"),\n ]\n\n def initialize_options(self):\n old_build_clib.initialize_options(self)\n self.fcompiler = None\n return\n\n def finalize_options(self):\n old_build_clib.finalize_options(self)\n self.set_undefined_options('build_ext',\n ('fcompiler', 'fcompiler'))\n return\n\n def have_f_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_f_sources(build_info.get('sources',[])):\n return True\n return False\n\n def have_cxx_sources(self):\n for (lib_name, build_info) in self.libraries:\n if has_cxx_sources(build_info.get('sources',[])):\n return True\n return False\n\n def run(self):\n if not self.libraries:\n return\n\n # Make sure that library sources are complete.\n for (lib_name, build_info) in self.libraries:\n if not all_strings(build_info.get('sources',[])):\n self.run_command('build_src')\n\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n dry_run=self.dry_run,\n force=self.force)\n self.compiler.customize(self.distribution,\n need_cxx=self.have_cxx_sources())\n\n libraries = self.libraries\n self.libraries = None\n self.compiler.customize_cmd(self)\n self.libraries = libraries\n\n self.compiler.show_customization()\n\n if self.have_f_sources():\n from numpy.distutils.fcompiler import new_fcompiler\n self.fcompiler = new_fcompiler(compiler=self.fcompiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n self.fcompiler.customize(self.distribution)\n\n libraries = self.libraries\n self.libraries = None\n self.fcompiler.customize_cmd(self)\n self.libraries = libraries\n\n self.fcompiler.show_customization()\n\n self.build_libraries(self.libraries)\n return\n\n def get_source_files(self):\n self.check_library_list(self.libraries)\n filenames = []\n for lib in self.libraries:\n filenames.extend(get_lib_source_files(lib))\n return filenames\n\n def build_libraries(self, libraries):\n\n\n for (lib_name, build_info) in libraries:\n # default compilers\n compiler = self.compiler\n fcompiler = self.fcompiler\n\n sources = build_info.get('sources')\n if sources is None or not is_sequence(sources):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n\n \n lib_file = compiler.library_filename(lib_name,\n output_dir=self.build_clib)\n\n depends = sources + build_info.get('depends',[])\n if not (self.force or newer_group(depends, lib_file, 'newer')):\n log.debug(\"skipping '%s' library (up-to-date)\", lib_name)\n continue\n else:\n log.info(\"building '%s' library\", lib_name)\n\n\n config_fc = build_info.get('config_fc',{})\n if fcompiler is not None and config_fc:\n log.info('using setup script specified config_fc for fortran compiler: %s' \\\n % (config_fc))\n from numpy.distutils.fcompiler import new_fcompiler\n fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n fcompiler.customize(config_fc)\n\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n extra_postargs = build_info.get('extra_compiler_args') or []\n\n c_sources, cxx_sources, f_sources, fmodule_sources \\\n = filter_sources(sources)\n\n if self.compiler.compiler_type=='msvc':\n # this hack works around the msvc compiler attributes\n # problem, msvc uses its own convention :(\n c_sources += cxx_sources\n cxx_sources = []\n\n if fmodule_sources:\n print 'XXX: Fortran 90 module support not implemented or tested'\n f_sources.extend(fmodule_sources)\n\n objects = []\n if c_sources:\n log.info(\"compiling C sources\")\n objects = compiler.compile(c_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n\n if cxx_sources:\n log.info(\"compiling C++ sources\")\n old_compiler = self.compiler.compiler_so[0]\n self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0]\n\n cxx_objects = compiler.compile(cxx_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=extra_postargs)\n objects.extend(cxx_objects)\n\n self.compiler.compiler_so[0] = old_compiler\n\n if f_sources:\n log.info(\"compiling Fortran sources\")\n f_objects = fcompiler.compile(f_sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug,\n extra_postargs=[])\n objects.extend(f_objects)\n\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n\n clib_libraries = build_info.get('libraries',[])\n for lname,binfo in libraries:\n if lname in clib_libraries:\n clib_libraries.extend(binfo[1].get('libraries',[]))\n if clib_libraries:\n build_info['libraries'] = clib_libraries\n\n return\n", + "methods": [ + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_clib.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_f_sources", + "long_name": "have_f_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_cxx_sources", + "long_name": "have_cxx_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "build_clib.py", + "nloc": 31, + "complexity": 5, + "token_count": 216, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "get_source_files", + "long_name": "get_source_files( self )", + "filename": "build_clib.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 81, + "complexity": 17, + "token_count": 519, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_clib.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_f_sources", + "long_name": "have_f_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "have_cxx_sources", + "long_name": "have_cxx_sources( self )", + "filename": "build_clib.py", + "nloc": 5, + "complexity": 3, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "build_clib.py", + "nloc": 31, + "complexity": 5, + "token_count": 216, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "get_source_files", + "long_name": "get_source_files( self )", + "filename": "build_clib.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 80, + "complexity": 17, + "token_count": 517, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 104, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 81, + "complexity": 17, + "token_count": 519, + "parameters": [ + "self", + "libraries" + ], + "start_line": 92, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 1 + } + ], + "nloc": 151, + "complexity": 32, + "token_count": 959, + "diff_parsed": { + "added": [ + " log.info('using setup script specified config_fc '\\", + " 'for fortran compiler: %s' \\" + ], + "deleted": [ + " log.info('using setup script specified config_fc for fortran compiler: %s' \\" + ] + } + }, + { + "old_path": "numpy/distutils/fcompiler/__init__.py", + "new_path": "numpy/distutils/fcompiler/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -250,7 +250,7 @@ def customize(self, dist=None):\n dist.cmdclass['config_fc'] = config_fc\n dist.parse_config_files()\n dist.parse_command_line()\n- elif isinstance(dist,Distribution):\n+ if isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\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 if isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n conf = dist\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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "source_code_before": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\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 elif isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n conf = dist\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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "methods": [ + { + "name": "get_version_cmd", + "long_name": "get_version_cmd( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 360, + "end_line": 377, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 381, + "end_line": 417, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 419, + "end_line": 435, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 437, + "end_line": 438, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 439, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 442, + "end_line": 489, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 494, + "end_line": 507, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 509, + "end_line": 522, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 583, + "end_line": 596, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 598, + "end_line": 619, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 621, + "end_line": 658, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 660, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 714, + "end_line": 721, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 707, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 730, + "end_line": 751, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 753, + "end_line": 757, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 360, + "end_line": 377, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 381, + "end_line": 417, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 419, + "end_line": 435, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 437, + "end_line": 438, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 439, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 442, + "end_line": 489, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 494, + "end_line": 507, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 509, + "end_line": 522, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 583, + "end_line": 596, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 598, + "end_line": 619, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 621, + "end_line": 658, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 660, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 714, + "end_line": 721, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 707, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 730, + "end_line": 751, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 753, + "end_line": 757, + "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": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + } + ], + "nloc": 628, + "complexity": 167, + "token_count": 4159, + "diff_parsed": { + "added": [ + " if isinstance(dist,Distribution):" + ], + "deleted": [ + " elif isinstance(dist,Distribution):" + ] + } + } + ] + }, + { + "hash": "50e69de29085387db2e0ab7768bc9b81c2712169", + "msg": "Add Intel EM64T Fortran Compiler support.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2006-04-09T10:11:56+00:00", + "author_timezone": 0, + "committer_date": "2006-04-09T10:11:56+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "a8e674757141889f3609890a1d89a8634abc98bb" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmpnsajvf5i/repo_copy", + "deletions": 8, + "insertions": 32, + "lines": 40, + "files": 4, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "numpy/distutils/cpuinfo.py", + "new_path": "numpy/distutils/cpuinfo.py", + "filename": "cpuinfo.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -193,7 +193,7 @@ def _is_Itanium(self):\n \n def _is_XEON(self):\n return re.match(r'.*?XEON\\b',\n- self.info[0]['model name']) is not None\n+ self.info[0]['model name'],re.IGNORECASE) is not None\n \n _is_Xeon = _is_XEON\n \n", + "added_lines": 1, + "deleted_lines": 1, + "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: 1.1 $\n$Date: 2005/04/09 19:29:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: cpuinfo.py,v 1.1 2005/04/09 19:29:34 pearu Exp $\"\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_PentiumM(self):\n return re.match(r'.*?Pentium.*?M\\b',\n self.info[0]['model name']) is not None\n\n def _is_Prescott(self):\n return self.is_PentiumIV() and self.has_sse3()\n\n def _is_Nocona(self):\n return self.is_PentiumIV() and self.is_64bit()\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['family']) is not None\n\n def _is_XEON(self):\n return re.match(r'.*?XEON\\b',\n self.info[0]['model name'],re.IGNORECASE) is not None\n\n _is_Xeon = _is_XEON\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 True\n if self.info[0].get('clflush size','')=='64':\n return True\n if self.info[0].get('uname_m','')=='x86_64':\n return True\n if self.info[0].get('arch','')=='IA-64':\n return True\n return False\n\n def _is_32bit(self):\n return not self.is_64bit()\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: 1.1 $\n$Date: 2005/04/09 19:29:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: cpuinfo.py,v 1.1 2005/04/09 19:29:34 pearu Exp $\"\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_PentiumM(self):\n return re.match(r'.*?Pentium.*?M\\b',\n self.info[0]['model name']) is not None\n\n def _is_Prescott(self):\n return self.is_PentiumIV() and self.has_sse3()\n\n def _is_Nocona(self):\n return self.is_PentiumIV() and self.is_64bit()\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['family']) 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 _is_Xeon = _is_XEON\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 True\n if self.info[0].get('clflush size','')=='64':\n return True\n if self.info[0].get('uname_m','')=='x86_64':\n return True\n if self.info[0].get('arch','')=='IA-64':\n return True\n return False\n\n def _is_32bit(self):\n return not self.is_64bit()\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_PentiumM", + "long_name": "_is_PentiumM( 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_Prescott", + "long_name": "_is_Prescott( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Nocona", + "long_name": "_is_Nocona( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Itanium", + "long_name": "_is_Itanium( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 190, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_is_XEON", + "long_name": "_is_XEON( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 194, + "end_line": 196, + "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": 202, + "end_line": 203, + "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": 205, + "end_line": 206, + "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": 208, + "end_line": 209, + "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": 211, + "end_line": 212, + "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": 214, + "end_line": 215, + "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": 217, + "end_line": 218, + "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": 220, + "end_line": 221, + "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": 223, + "end_line": 224, + "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": 226, + "end_line": 227, + "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": 229, + "end_line": 230, + "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": 10, + "complexity": 5, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "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": 243, + "end_line": 244, + "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": 250, + "end_line": 269, + "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": 274, + "end_line": 275, + "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": 277, + "end_line": 278, + "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": 280, + "end_line": 281, + "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": 298, + "end_line": 300, + "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": 301, + "end_line": 302, + "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": 323, + "end_line": 348, + "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": 352, + "end_line": 354, + "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": 356, + "end_line": 357, + "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": 359, + "end_line": 360, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 365, + "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": 389, + "end_line": 434, + "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": 438, + "end_line": 439, + "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": 440, + "end_line": 441, + "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": 443, + "end_line": 444, + "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": 445, + "end_line": 446, + "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": 447, + "end_line": 448, + "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": 450, + "end_line": 452, + "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": 454, + "end_line": 455, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 466, + "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": 467, + "end_line": 468, + "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": 469, + "end_line": 470, + "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": 471, + "end_line": 472, + "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": 473, + "end_line": 474, + "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": 475, + "end_line": 476, + "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": 477, + "end_line": 478, + "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": 479, + "end_line": 480, + "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": 481, + "end_line": 482, + "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": 483, + "end_line": 484, + "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": 485, + "end_line": 486, + "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": 488, + "end_line": 489, + "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": 490, + "end_line": 491, + "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": 492, + "end_line": 493, + "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": 503, + "end_line": 542, + "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": 548, + "end_line": 549, + "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": 551, + "end_line": 552, + "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": 554, + "end_line": 555, + "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": 557, + "end_line": 559, + "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": 561, + "end_line": 563, + "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": 565, + "end_line": 567, + "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": 569, + "end_line": 571, + "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": 573, + "end_line": 574, + "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": 576, + "end_line": 578, + "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": 580, + "end_line": 582, + "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": 586, + "end_line": 587, + "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": 589, + "end_line": 590, + "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": 592, + "end_line": 593, + "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": 595, + "end_line": 596, + "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": 598, + "end_line": 599, + "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": 601, + "end_line": 602, + "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": 604, + "end_line": 606, + "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": 608, + "end_line": 610, + "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": 612, + "end_line": 614, + "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": 616, + "end_line": 618, + "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": 620, + "end_line": 621, + "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": 625, + "end_line": 626, + "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": 628, + "end_line": 629, + "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": 631, + "end_line": 636, + "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": 638, + "end_line": 646, + "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": 648, + "end_line": 649, + "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": 651, + "end_line": 653, + "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": 655, + "end_line": 656, + "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_PentiumM", + "long_name": "_is_PentiumM( 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_Prescott", + "long_name": "_is_Prescott( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Nocona", + "long_name": "_is_Nocona( self )", + "filename": "cpuinfo.py", + "nloc": 2, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_is_Itanium", + "long_name": "_is_Itanium( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 190, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_is_XEON", + "long_name": "_is_XEON( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 194, + "end_line": 196, + "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": 202, + "end_line": 203, + "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": 205, + "end_line": 206, + "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": 208, + "end_line": 209, + "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": 211, + "end_line": 212, + "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": 214, + "end_line": 215, + "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": 217, + "end_line": 218, + "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": 220, + "end_line": 221, + "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": 223, + "end_line": 224, + "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": 226, + "end_line": 227, + "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": 229, + "end_line": 230, + "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": 10, + "complexity": 5, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "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": 243, + "end_line": 244, + "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": 250, + "end_line": 269, + "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": 274, + "end_line": 275, + "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": 277, + "end_line": 278, + "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": 280, + "end_line": 281, + "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": 298, + "end_line": 300, + "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": 301, + "end_line": 302, + "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": 323, + "end_line": 348, + "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": 352, + "end_line": 354, + "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": 356, + "end_line": 357, + "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": 359, + "end_line": 360, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 365, + "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": 389, + "end_line": 434, + "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": 438, + "end_line": 439, + "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": 440, + "end_line": 441, + "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": 443, + "end_line": 444, + "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": 445, + "end_line": 446, + "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": 447, + "end_line": 448, + "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": 450, + "end_line": 452, + "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": 454, + "end_line": 455, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 466, + "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": 467, + "end_line": 468, + "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": 469, + "end_line": 470, + "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": 471, + "end_line": 472, + "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": 473, + "end_line": 474, + "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": 475, + "end_line": 476, + "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": 477, + "end_line": 478, + "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": 479, + "end_line": 480, + "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": 481, + "end_line": 482, + "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": 483, + "end_line": 484, + "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": 485, + "end_line": 486, + "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": 488, + "end_line": 489, + "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": 490, + "end_line": 491, + "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": 492, + "end_line": 493, + "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": 503, + "end_line": 542, + "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": 548, + "end_line": 549, + "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": 551, + "end_line": 552, + "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": 554, + "end_line": 555, + "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": 557, + "end_line": 559, + "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": 561, + "end_line": 563, + "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": 565, + "end_line": 567, + "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": 569, + "end_line": 571, + "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": 573, + "end_line": 574, + "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": 576, + "end_line": 578, + "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": 580, + "end_line": 582, + "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": 586, + "end_line": 587, + "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": 589, + "end_line": 590, + "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": 592, + "end_line": 593, + "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": 595, + "end_line": 596, + "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": 598, + "end_line": 599, + "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": 601, + "end_line": 602, + "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": 604, + "end_line": 606, + "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": 608, + "end_line": 610, + "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": 612, + "end_line": 614, + "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": 616, + "end_line": 618, + "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": 620, + "end_line": 621, + "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": 625, + "end_line": 626, + "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": 628, + "end_line": 629, + "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": 631, + "end_line": 636, + "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": 638, + "end_line": 646, + "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": 648, + "end_line": 649, + "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": 651, + "end_line": 653, + "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": 655, + "end_line": 656, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "_is_XEON", + "long_name": "_is_XEON( self )", + "filename": "cpuinfo.py", + "nloc": 3, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 194, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": 548, + "complexity": 227, + "token_count": 5012, + "diff_parsed": { + "added": [ + " self.info[0]['model name'],re.IGNORECASE) is not None" + ], + "deleted": [ + " self.info[0]['model name']) is not None" + ] + } + }, + { + "old_path": "numpy/distutils/fcompiler/__init__.py", + "new_path": "numpy/distutils/fcompiler/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -545,6 +545,8 @@ def __get_flags(self, command, envvar=None, confvar=None):\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n+ 'intelem':('intel','IntelEM64TFCompiler',\n+ \"Intel Fortran Compiler for EM64T-based apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n@@ -569,7 +571,7 @@ def __get_flags(self, command, envvar=None, confvar=None):\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n- 'intele','gnu95','g95')),\n+ 'intele','intelem','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n", + "added_lines": 3, + "deleted_lines": 1, + "source_code": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\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 if isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n conf = dist\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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'intelem':('intel','IntelEM64TFCompiler',\n \"Intel Fortran Compiler for EM64T-based apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','intelem','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "source_code_before": "\"\"\"numpy.distutils.fcompiler\n\nContains FCompiler, an abstract base class that defines the interface\nfor the numpy.distutils Fortran compiler abstraction model.\n\"\"\"\n\n__all__ = ['FCompiler','new_fcompiler','show_fcompilers',\n 'dummy_fortran_file']\n\nimport os\nimport sys\nimport re\nfrom types import StringType,NoneType\nfrom distutils.sysconfig import get_config_var\nfrom distutils.fancy_getopt import FancyGetopt\nfrom distutils.errors import DistutilsModuleError,DistutilsArgError,\\\n DistutilsExecError,CompileError,LinkError,DistutilsPlatformError\nfrom distutils.util import split_quoted\n\nfrom numpy.distutils.ccompiler import CCompiler, gen_lib_options\nfrom numpy.distutils import log\nfrom numpy.distutils.command.config_compiler import config_fc\nfrom numpy.distutils.misc_util import is_string, is_sequence\nfrom distutils.spawn import _nt_quote_args\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\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\"],\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_linker_exe(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.get('linker_exe')\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_linker_exe(self):\n \"\"\" List of linker flags to build an executable. \"\"\"\n if self.executables['linker_exe']:\n return self.executables['linker_exe'][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\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 from distutils.dist import Distribution\n if dist is None:\n # These hooks are for testing only!\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 if isinstance(dist,Distribution):\n conf = dist.get_option_dict('config_fc')\n else:\n assert isinstance(dist,dict)\n conf = dist\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\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 #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 linker_exe = self.__get_cmd(self.get_linker_exe,'LD')\n if linker_exe:\n linker_exe_flags = self.__get_flags(self.get_flags_linker_exe,'LDFLAGS')\n self.set_executables(linker_exe=[linker_exe]+linker_exe_flags)\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\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 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 is_string(output_dir):\n output_filename = os.path.join(output_dir, output_filename)\n elif output_dir is not None:\n raise TypeError, \"'output_dir' must be a string or None\"\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 is_string(self.objects):\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 linker = self.linker_exe[:]\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 ## Private methods:\n\n def __get_cmd(self, command, envvar=None, confvar=None):\n if command is None:\n var = None\n elif is_string(command):\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 is_string(command):\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 is_string(var):\n var = split_quoted(var)\n return var\n\n ## class FCompiler\n\nfcompiler_class = {'gnu':('gnu','GnuFCompiler',\n \"GNU Fortran Compiler\"),\n 'gnu95':('gnu','Gnu95FCompiler',\n \"GNU 95 Fortran Compiler\"),\n 'g95':('g95','G95FCompiler',\n \"GNU Fortran 95 Compiler\"),\n 'pg':('pg','PGroupFCompiler',\n \"Portland Group Fortran Compiler\"),\n 'absoft':('absoft','AbsoftFCompiler',\n \"Absoft Corp Fortran Compiler\"),\n 'mips':('mips','MipsFCompiler',\n \"MIPSpro Fortran Compiler\"),\n 'sun':('sun','SunFCompiler',\n \"Sun|Forte Fortran 95 Compiler\"),\n 'intel':('intel','IntelFCompiler',\n \"Intel Fortran Compiler for 32-bit apps\"),\n 'intelv':('intel','IntelVisualFCompiler',\n \"Intel Visual Fortran Compiler for 32-bit apps\"),\n 'intele':('intel','IntelItaniumFCompiler',\n \"Intel Fortran Compiler for Itanium apps\"),\n 'intelev':('intel','IntelItaniumVisualFCompiler',\n \"Intel Visual Fortran Compiler for Itanium apps\"),\n 'nag':('nag','NAGFCompiler',\n \"NAGWare Fortran 95 Compiler\"),\n 'compaq':('compaq','CompaqFCompiler',\n \"Compaq Fortran Compiler\"),\n 'compaqv':('compaq','CompaqVisualFCompiler',\n \"DIGITAL|Compaq Visual Fortran Compiler\"),\n 'vast':('vast','VastFCompiler',\n \"Pacific-Sierra Research Fortran 90 Compiler\"),\n 'hpux':('hpux','HPUXFCompiler',\n \"HP Fortran 90 Compiler\"),\n 'lahey':('lahey','LaheyFCompiler',\n \"Lahey/Fujitsu Fortran 95 Compiler\"),\n 'ibm':('ibm','IbmFCompiler',\n \"IBM XL Fortran Compiler\"),\n 'f':('f','FFCompiler',\n \"Fortran Company/NAG F Compiler\"),\n 'none':('none','NoneFCompiler',\"Fake Fortran compiler\")\n }\n\n_default_compilers = (\n # Platform mappings\n ('win32',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('cygwin.*',('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')),\n ('linux.*',('gnu','intel','lahey','pg','absoft','nag','vast','compaq',\n 'intele','gnu95','g95')),\n ('darwin.*',('nag','absoft','ibm','gnu','gnu95','g95')),\n ('sunos.*',('sun','gnu','gnu95','g95')),\n ('irix.*',('mips','gnu','gnu95',)),\n ('aix.*',('ibm','gnu','gnu95',)),\n # OS mappings\n ('posix',('gnu','gnu95',)),\n ('nt',('gnu','gnu95',)),\n ('mac',('gnu','gnu95',)),\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 is_sequence(compiler):\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 = 'numpy.distutils.fcompiler.'+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 distutils.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\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 atexit\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)\n\nif __name__ == '__main__':\n show_fcompilers()\n", + "methods": [ + { + "name": "get_version_cmd", + "long_name": "get_version_cmd( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 360, + "end_line": 377, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 381, + "end_line": 417, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 419, + "end_line": 435, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 437, + "end_line": 438, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 439, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 442, + "end_line": 489, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 494, + "end_line": 507, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 509, + "end_line": 522, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 585, + "end_line": 598, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 600, + "end_line": 621, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 623, + "end_line": 660, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 662, + "end_line": 707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 716, + "end_line": 723, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 709, + "end_line": 725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 732, + "end_line": 753, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 755, + "end_line": 759, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 128, + "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": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "get_linker_exe", + "long_name": "get_linker_exe( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 6, + "token_count": 98, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 164, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_version", + "long_name": "get_flags_version( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 173, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_fix", + "long_name": "get_flags_fix( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 191, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_exe", + "long_name": "get_flags_linker_exe( self )", + "filename": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "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": "__init__.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 209, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 210, + "end_line": 212, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_library_dirs", + "long_name": "get_library_dirs( self )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "customize", + "long_name": "customize( self , dist = None )", + "filename": "__init__.py", + "nloc": 97, + "complexity": 39, + "token_count": 888, + "parameters": [ + "self", + "dist" + ], + "start_line": 232, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 127, + "top_nesting_level": 1 + }, + { + "name": "dump_properties", + "long_name": "dump_properties( self )", + "filename": "__init__.py", + "nloc": 16, + "complexity": 5, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 360, + "end_line": 377, + "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": "__init__.py", + "nloc": 32, + "complexity": 9, + "token_count": 217, + "parameters": [ + "self", + "obj", + "src", + "ext", + "cc_args", + "extra_postargs", + "pp_opts" + ], + "start_line": 381, + "end_line": 417, + "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": "__init__.py", + "nloc": 17, + "complexity": 5, + "token_count": 129, + "parameters": [ + "self", + "module_dirs", + "module_build_dir" + ], + "start_line": 419, + "end_line": 435, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "lib" + ], + "start_line": 437, + "end_line": 438, + "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": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "dir" + ], + "start_line": 439, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "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": "__init__.py", + "nloc": 45, + "complexity": 12, + "token_count": 317, + "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": 442, + "end_line": 489, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 105, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 494, + "end_line": 507, + "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": "__init__.py", + "nloc": 14, + "complexity": 6, + "token_count": 110, + "parameters": [ + "self", + "command", + "envvar", + "confvar" + ], + "start_line": 509, + "end_line": 522, + "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": "__init__.py", + "nloc": 14, + "complexity": 5, + "token_count": 71, + "parameters": [ + "compilers", + "osname", + "platform" + ], + "start_line": 583, + "end_line": 596, + "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": "__init__.py", + "nloc": 21, + "complexity": 9, + "token_count": 129, + "parameters": [ + "osname", + "platform" + ], + "start_line": 598, + "end_line": 619, + "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": "__init__.py", + "nloc": 34, + "complexity": 7, + "token_count": 182, + "parameters": [ + "plat", + "compiler", + "verbose", + "dry_run", + "force" + ], + "start_line": 621, + "end_line": 658, + "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": "__init__.py", + "nloc": 41, + "complexity": 8, + "token_count": 263, + "parameters": [ + "dist" + ], + "start_line": 660, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "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": "__init__.py", + "nloc": 8, + "complexity": 3, + "token_count": 84, + "parameters": [ + "name", + "log_threshold" + ], + "start_line": 714, + "end_line": 721, + "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": "__init__.py", + "nloc": 10, + "complexity": 1, + "token_count": 48, + "parameters": [], + "start_line": 707, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "__init__.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 730, + "end_line": 751, + "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": "__init__.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "src" + ], + "start_line": 753, + "end_line": 757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 630, + "complexity": 167, + "token_count": 4171, + "diff_parsed": { + "added": [ + " 'intelem':('intel','IntelEM64TFCompiler',", + " \"Intel Fortran Compiler for EM64T-based apps\"),", + " 'intele','intelem','gnu95','g95'))," + ], + "deleted": [ + " 'intele','gnu95','g95'))," + ] + } + }, + { + "old_path": "numpy/distutils/fcompiler/intel.py", + "new_path": "numpy/distutils/fcompiler/intel.py", + "filename": "intel.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -54,9 +54,9 @@ def get_flags_arch(self):\n opt.extend(['-tpp7','-xB'])\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n- elif cpu.is_PentiumIV() or cpu.is_XEON():\n+ elif cpu.is_PentiumIV() or cpu.is_Xeon():\n opt.extend(['-tpp7','-xW'])\n- if cpu.has_mmx():\n+ if cpu.has_mmx() and not cpu.is_Xeon():\n opt.append('-xM')\n if cpu.has_sse2():\n opt.append('-arch SSE2')\n@@ -93,6 +93,27 @@ class IntelItaniumFCompiler(IntelFCompiler):\n 'ranlib' : [\"ranlib\"]\n }\n \n+class IntelEM64TFCompiler(IntelFCompiler):\n+ compiler_type = 'intelem'\n+\n+ version_pattern = r'Intel\\(R\\) Fortran Compiler for Intel\\(R\\) EM64T-based '\\\n+ 'applications, Version (?P[^\\s*]*)'\n+\n+ for fc_exe in map(find_executable,['ifort','efort','efc']):\n+ if os.path.isfile(fc_exe):\n+ break\n+\n+ executables = {\n+ 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n+ % {'fname':dummy_fortran_file()}],\n+ 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n+ 'compiler_fix' : [fc_exe,\"-FI\"],\n+ 'compiler_f90' : [fc_exe],\n+ 'linker_so' : [fc_exe,\"-shared\"],\n+ 'archiver' : [\"ar\", \"-cr\"],\n+ 'ranlib' : [\"ranlib\"]\n+ }\n+\n class IntelVisualFCompiler(FCompiler):\n \n compiler_type = 'intelv'\n", + "added_lines": 23, + "deleted_lines": 2, + "source_code": "# http://developer.intel.com/software/products/compilers/flin/\n\nimport os\nimport sys\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.fcompiler import FCompiler, dummy_fortran_file\nfrom numpy.distutils.exec_command import find_executable\n\nclass IntelFCompiler(FCompiler):\n\n compiler_type = 'intel'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit '\\\n 'applications, Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','ifc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-72\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n pic_flags = ['-KPIC']\n module_dir_switch = '-module ' # Don't remove ending space!\n module_include_switch = '-I'\n\n def get_flags(self):\n opt = self.pic_flags + [\"-cm\"]\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_opt(self):\n return ['-O3','-unroll']\n\n def get_flags_arch(self):\n opt = []\n if cpu.has_fdiv_bug():\n opt.append('-fdiv_check')\n if cpu.has_f00f_bug():\n opt.append('-0f_check')\n if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():\n opt.extend(['-tpp6'])\n elif cpu.is_PentiumM():\n opt.extend(['-tpp7','-xB'])\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n elif cpu.is_PentiumIV() or cpu.is_Xeon():\n opt.extend(['-tpp7','-xW'])\n if cpu.has_mmx() and not cpu.is_Xeon():\n opt.append('-xM')\n if cpu.has_sse2():\n opt.append('-arch SSE2')\n elif cpu.has_sse():\n opt.append('-arch SSE')\n return opt\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n v = self.get_version()\n if v and v >= '8.0':\n opt.append('-nofor_main')\n opt.extend(self.get_flags_arch())\n return opt\n\nclass IntelItaniumFCompiler(IntelFCompiler):\n compiler_type = 'intele'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','efort','efc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\nclass IntelEM64TFCompiler(IntelFCompiler):\n compiler_type = 'intelem'\n\n version_pattern = r'Intel\\(R\\) Fortran Compiler for Intel\\(R\\) EM64T-based '\\\n 'applications, Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','efort','efc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\nclass IntelVisualFCompiler(FCompiler):\n\n compiler_type = 'intelv'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n ar_exe = 'lib.exe'\n fc_exe = 'ifl'\n if sys.platform=='win32':\n from distutils.msvccompiler import MSVCCompiler\n ar_exe = MSVCCompiler().lib\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\n compile_switch = '/c '\n object_switch = '/Fo' #No space after /Fo!\n library_switch = '/OUT:' #No space after /OUT:!\n module_dir_switch = '/module:' #No space after /module:\n module_include_switch = '/I'\n\n def get_flags(self):\n opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_debug(self):\n return ['/4Yb','/d2']\n\n def get_flags_opt(self):\n return ['/O3','/Qip','/Qipo','/Qipo_obj']\n\n def get_flags_arch(self):\n opt = []\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt.extend(['/G6','/Qaxi'])\n elif cpu.is_PentiumIII():\n opt.extend(['/G6','/QaxK'])\n elif cpu.is_Pentium():\n opt.append('/G5')\n elif cpu.is_PentiumIV():\n opt.extend(['/G7','/QaxW'])\n if cpu.has_mmx():\n opt.append('/QaxM')\n return opt\n\nclass IntelItaniumVisualFCompiler(IntelVisualFCompiler):\n\n compiler_type = 'intelev'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n fc_exe = 'efl' # XXX this is a wild guess\n ar_exe = IntelVisualFCompiler.ar_exe\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='intel')\n compiler.customize()\n print compiler.get_version()\n", + "source_code_before": "# http://developer.intel.com/software/products/compilers/flin/\n\nimport os\nimport sys\n\nfrom numpy.distutils.cpuinfo import cpu\nfrom numpy.distutils.fcompiler import FCompiler, dummy_fortran_file\nfrom numpy.distutils.exec_command import find_executable\n\nclass IntelFCompiler(FCompiler):\n\n compiler_type = 'intel'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit '\\\n 'applications, Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','ifc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-72\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\n pic_flags = ['-KPIC']\n module_dir_switch = '-module ' # Don't remove ending space!\n module_include_switch = '-I'\n\n def get_flags(self):\n opt = self.pic_flags + [\"-cm\"]\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_opt(self):\n return ['-O3','-unroll']\n\n def get_flags_arch(self):\n opt = []\n if cpu.has_fdiv_bug():\n opt.append('-fdiv_check')\n if cpu.has_f00f_bug():\n opt.append('-0f_check')\n if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():\n opt.extend(['-tpp6'])\n elif cpu.is_PentiumM():\n opt.extend(['-tpp7','-xB'])\n elif cpu.is_Pentium():\n opt.append('-tpp5')\n elif cpu.is_PentiumIV() or cpu.is_XEON():\n opt.extend(['-tpp7','-xW'])\n if cpu.has_mmx():\n opt.append('-xM')\n if cpu.has_sse2():\n opt.append('-arch SSE2')\n elif cpu.has_sse():\n opt.append('-arch SSE')\n return opt\n\n def get_flags_linker_so(self):\n opt = FCompiler.get_flags_linker_so(self)\n v = self.get_version()\n if v and v >= '8.0':\n opt.append('-nofor_main')\n opt.extend(self.get_flags_arch())\n return opt\n\nclass IntelItaniumFCompiler(IntelFCompiler):\n compiler_type = 'intele'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n for fc_exe in map(find_executable,['ifort','efort','efc']):\n if os.path.isfile(fc_exe):\n break\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [\"ar\", \"-cr\"],\n 'ranlib' : [\"ranlib\"]\n }\n\nclass IntelVisualFCompiler(FCompiler):\n\n compiler_type = 'intelv'\n version_pattern = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n ar_exe = 'lib.exe'\n fc_exe = 'ifl'\n if sys.platform=='win32':\n from distutils.msvccompiler import MSVCCompiler\n ar_exe = MSVCCompiler().lib\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\n compile_switch = '/c '\n object_switch = '/Fo' #No space after /Fo!\n library_switch = '/OUT:' #No space after /OUT:!\n module_dir_switch = '/module:' #No space after /module:\n module_include_switch = '/I'\n\n def get_flags(self):\n opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']\n return opt\n\n def get_flags_free(self):\n return [\"-FR\"]\n\n def get_flags_debug(self):\n return ['/4Yb','/d2']\n\n def get_flags_opt(self):\n return ['/O3','/Qip','/Qipo','/Qipo_obj']\n\n def get_flags_arch(self):\n opt = []\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt.extend(['/G6','/Qaxi'])\n elif cpu.is_PentiumIII():\n opt.extend(['/G6','/QaxK'])\n elif cpu.is_Pentium():\n opt.append('/G5')\n elif cpu.is_PentiumIV():\n opt.extend(['/G7','/QaxW'])\n if cpu.has_mmx():\n opt.append('/QaxM')\n return opt\n\nclass IntelItaniumVisualFCompiler(IntelVisualFCompiler):\n\n compiler_type = 'intelev'\n version_pattern = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n fc_exe = 'efl' # XXX this is a wild guess\n ar_exe = IntelVisualFCompiler.ar_exe\n\n executables = {\n 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\\n % {'fname':dummy_fortran_file()}],\n 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],\n 'compiler_fix' : [fc_exe,\"-FI\",\"-4L72\",\"-w\"],\n 'compiler_f90' : [fc_exe],\n 'linker_so' : [fc_exe,\"-shared\"],\n 'archiver' : [ar_exe, \"/verbose\", \"/OUT:\"],\n 'ranlib' : None\n }\n\nif __name__ == '__main__':\n from distutils import log\n log.set_verbosity(2)\n from numpy.distutils.fcompiler import new_fcompiler\n compiler = new_fcompiler(compiler='intel')\n compiler.customize()\n print compiler.get_version()\n", + "methods": [ + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 40, + "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": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 21, + "complexity": 14, + "token_count": 163, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "intel.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 67, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 146, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 150, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "intel.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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 156, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 13, + "complexity": 7, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 159, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 40, + "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": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 21, + "complexity": 13, + "token_count": 156, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "get_flags_linker_so", + "long_name": "get_flags_linker_so( self )", + "filename": "intel.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 67, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "get_flags", + "long_name": "get_flags( self )", + "filename": "intel.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 125, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_flags_free", + "long_name": "get_flags_free( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "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": "get_flags_debug", + "long_name": "get_flags_debug( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "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": "get_flags_opt", + "long_name": "get_flags_opt( self )", + "filename": "intel.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 135, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 13, + "complexity": 7, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 138, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "get_flags_arch", + "long_name": "get_flags_arch( self )", + "filename": "intel.py", + "nloc": 21, + "complexity": 14, + "token_count": 163, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "nloc": 165, + "complexity": 31, + "token_count": 1041, + "diff_parsed": { + "added": [ + " elif cpu.is_PentiumIV() or cpu.is_Xeon():", + " if cpu.has_mmx() and not cpu.is_Xeon():", + "class IntelEM64TFCompiler(IntelFCompiler):", + " compiler_type = 'intelem'", + "", + " version_pattern = r'Intel\\(R\\) Fortran Compiler for Intel\\(R\\) EM64T-based '\\", + " 'applications, Version (?P[^\\s*]*)'", + "", + " for fc_exe in map(find_executable,['ifort','efort','efc']):", + " if os.path.isfile(fc_exe):", + " break", + "", + " executables = {", + " 'version_cmd' : [fc_exe, \"-FI -V -c %(fname)s.f -o %(fname)s.o\" \\", + " % {'fname':dummy_fortran_file()}],", + " 'compiler_f77' : [fc_exe,\"-FI\",\"-w90\",\"-w95\"],", + " 'compiler_fix' : [fc_exe,\"-FI\"],", + " 'compiler_f90' : [fc_exe],", + " 'linker_so' : [fc_exe,\"-shared\"],", + " 'archiver' : [\"ar\", \"-cr\"],", + " 'ranlib' : [\"ranlib\"]", + " }", + "" + ], + "deleted": [ + " elif cpu.is_PentiumIV() or cpu.is_XEON():", + " if cpu.has_mmx():" + ] + } + }, + { + "old_path": "numpy/distutils/system_info.py", + "new_path": "numpy/distutils/system_info.py", + "filename": "system_info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -746,15 +746,16 @@ def __init__(self):\n system_info.__init__(self)\n else:\n from cpuinfo import cpu\n+ l = 'mkl' # use shared library\n if cpu.is_Itanium():\n plt = '64'\n- l = 'mkl_ipf'\n+ #l = 'mkl_ipf'\n elif cpu.is_Xeon():\n plt = 'em64t'\n- l = 'mkl_em64t'\n+ #l = 'mkl_em64t'\n else:\n plt = '32'\n- l = 'mkl_ia32'\n+ #l = 'mkl_ia32'\n if l not in self._lib_mkl:\n self._lib_mkl.insert(0,l)\n system_info.__init__(self,\n@@ -783,7 +784,7 @@ def calc_info(self):\n mkl = get_info('mkl')\n if not mkl:\n return\n- lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])\n+ lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])\n info = {'libraries': lapack_libs}\n dict_append(info,**mkl)\n self.set_info(**info)\n", + "added_lines": 5, + "deleted_lines": 4, + "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 numpy_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 umfpack_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' is looked for in\n\n1) Directory of main setup.py file being run.\n2) Home directory of user running the setup.py file (Not implemented yet)\n3) System wide directory (location of this file...)\n\nThe first one found is used to get system configuration options The\nformat is that used by ConfigParser (i.e., Windows .INI style). The\nsection DEFAULT has options that are the default for each section. The\navailable sections are fftw, atlas, and x11. Appropiate defaults are\nused if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command, get_pythonexe\nfrom numpy.distutils.misc_util import is_sequence, is_string\nimport distutils.sysconfig\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\',\n os.path.join(distutils.sysconfig.EXEC_PREFIX,\n 'libs')]\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 '/opt/local/lib', '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/opt/local/include', '/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_standard_file(fname):\n \"\"\"Returns a list of files named 'fname' from\n 1) System-wide directory (directory-location of this module)\n 2) Users HOME directory (os.environ['HOME'])\n 3) Local directory\n \"\"\"\n # System-wide file\n filenames = []\n try:\n f = __file__\n except NameError:\n f = sys.argv[0]\n else:\n sysfile = os.path.join(os.path.split(os.path.abspath(f))[0],\n fname)\n if os.path.isfile(sysfile):\n filenames.append(sysfile)\n\n # Home directory\n # And look for the user config file\n try:\n f = os.environ['HOME']\n except KeyError:\n pass\n else:\n user_file = os.path.join(f, fname)\n if os.path.isfile(user_file):\n filenames.append(user_file)\n\n # Local file\n if os.path.isfile(fname):\n filenames.append(os.path.abspath(fname))\n\n return filenames\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 'mkl':mkl_info,\n 'lapack_mkl':lapack_mkl_info, # use lapack_opt instead\n 'blas_mkl':blas_mkl_info, # use blas_opt instead\n 'x11':x11_info,\n 'fft_opt':fft_opt_info,\n 'fftw':fftw_info,\n 'fftw2':fftw2_info,\n 'fftw3':fftw3_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 'f2py':f2py_info,\n 'Numeric':Numeric_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 'umfpack':umfpack_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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\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 UmfpackNotFoundError(NotFoundError):\n \"\"\"\n UMFPACK sparse solver (http://www.cise.ufl.edu/research/sparse/umfpack/)\n not found. Directories to search for the libraries can be specified in the\n numpy/distutils/site.cfg file (section [umfpack]) or by setting\n the UMFPACK environment variable.\"\"\"\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['libraries'] = ''\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 self.files = get_standard_file('site.cfg')\n self.parse_config_files()\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def parse_config_files(self):\n self.cp.read(self.files)\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n\n def calc_libraries_info(self):\n libs = self.get_libraries()\n dirs = self.get_lib_dirs()\n info = {}\n for lib in libs:\n i = None\n for d in dirs:\n i = self.check_libs(d,[lib])\n if i is not None:\n break\n if i is not None:\n dict_append(info,**i)\n else:\n print 'Library %s was not found. Ignoring' % (lib)\n return info\n\n def set_info(self,**info):\n if info:\n lib_info = self.calc_libraries_info()\n dict_append(info,**lib_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 numpy.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(repr(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 env_var = self.dir_env_var\n if env_var:\n if is_sequence(env_var):\n e0 = env_var[-1]\n for e in env_var:\n if os.environ.has_key(e):\n e0 = e\n break\n if not env_var[0]==e0:\n print 'Setting %s=%s' % (env_var[0],e0)\n env_var = e0\n if env_var and os.environ.has_key(env_var):\n d = os.environ[env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' \\\n % (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 if not default:\n return []\n if is_string(default):\n return [default]\n return default\n return [b for b in [a.strip() for a in libs.split(',')] if b]\n\n def get_libraries(self, key='libraries'):\n return self.get_libs(key,'')\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 return\n\n def check_libs2(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 info = self._check_libs(lib_dir,libs,opt_libs,exts)\n if info is not None: return info\n return\n\n def _lib_list(self, lib_dir, libs, exts):\n assert is_string(lib_dir)\n liblist = []\n for l in libs:\n for ext in exts:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n break\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, exts):\n found_libs = self._lib_list(lib_dir, libs, exts)\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, exts)\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 else:\n warnings.warn(\"Library error: libs=%s found_libs=%s\" % \\\n (libs, found_libs))\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\n\nclass fft_opt_info(system_info):\n\n def calc_info(self):\n info = {}\n fftw_info = get_info('fftw3') or get_info('fftw2') or get_info('dfftw')\n djbfft_info = get_info('djbfft')\n if fftw_info:\n dict_append(info,**fftw_info)\n if djbfft_info:\n dict_append(info,**djbfft_info)\n self.set_info(**info)\n return\n\n\nclass fftw_info(system_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_ver_info(self,ver_param):\n \"\"\"Returns True on successful version detection, else False\"\"\"\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', ver_param['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,ver_param['includes']))==len(ver_param['includes']):\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=ver_param['macros'])\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n return True\n else:\n if self.verbosity>0:\n print ' %s not found' % (ver_param['name'])\n return False\n\n def calc_info(self):\n for i in self.ver_info:\n if self.calc_ver_info(i):\n break\n\nclass fftw2_info(fftw_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}\n ]\n\nclass fftw3_info(fftw_info):\n #variables to override\n section = 'fftw3'\n dir_env_var = 'FFTW3'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n ]\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n ver_info = [ { 'name':'dfftw',\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 ver_info = [ { 'name':'sfftw',\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 ver_info = [ { 'name':'fftw threads',\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 ver_info = [ { 'name':'dfftw threads',\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 ver_info = [ { 'name':'sfftw threads',\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','libdjbfft'+so_ext])\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 return\n\nclass mkl_info(system_info):\n section = 'mkl'\n dir_env_var = 'MKL'\n _lib_mkl = ['mkl','vml','guide']\n\n def get_mkl_rootdir(self):\n mklroot = os.environ.get('MKLROOT',None)\n if mklroot is not None:\n return mklroot\n paths = os.environ.get('LD_LIBRARY_PATH','').split(os.pathsep)\n ld_so_conf = '/etc/ld.so.conf'\n if os.path.isfile(ld_so_conf):\n for d in open(ld_so_conf,'r').readlines():\n d = d.strip()\n if d: paths.append(d)\n intel_mkl_dirs = []\n for path in paths:\n path_atoms = path.split(os.sep)\n for m in path_atoms:\n if m.startswith('mkl'):\n d = os.sep.join(path_atoms[:path_atoms.index(m)+2])\n intel_mkl_dirs.append(d)\n break\n for d in paths:\n dirs = glob(os.path.join(d,'mkl','*')) + glob(os.path.join(d,'mkl*'))\n for d in dirs:\n if os.path.isdir(os.path.join(d,'lib')):\n return d\n return None\n\n def __init__(self):\n mklroot = self.get_mkl_rootdir()\n if mklroot is None:\n system_info.__init__(self)\n else:\n from cpuinfo import cpu\n l = 'mkl' # use shared library\n if cpu.is_Itanium():\n plt = '64'\n #l = 'mkl_ipf'\n elif cpu.is_Xeon():\n plt = 'em64t'\n #l = 'mkl_em64t'\n else:\n plt = '32'\n #l = 'mkl_ia32'\n if l not in self._lib_mkl:\n self._lib_mkl.insert(0,l)\n system_info.__init__(self,\n default_lib_dirs=[os.path.join(mklroot,'lib',plt)],\n default_include_dirs=[os.path.join(mklroot,'include')])\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n mkl_libs = self.get_libs('mkl_libs',self._lib_mkl)\n mkl = None\n for d in lib_dirs:\n mkl = self.check_libs2(d,mkl_libs)\n if mkl is not None:\n break\n if mkl is None:\n return\n info = {}\n dict_append(info,**mkl)\n dict_append(info,libraries = ['pthread'], include_dirs = incl_dirs)\n self.set_info(**info)\n\nclass lapack_mkl_info(mkl_info):\n\n def calc_info(self):\n mkl = get_info('mkl')\n if not mkl:\n return\n lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])\n info = {'libraries': lapack_libs}\n dict_append(info,**mkl)\n self.set_info(**info)\n\nclass blas_mkl_info(mkl_info):\n pass\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\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 numpy/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 dir_env_var = ['PTATLAS','ATLAS']\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n dir_env_var = ['PTATLAS','ATLAS']\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 numpy_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_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\ndef get_atlas_version(**config):\n os.environ['NO_SCIPY_IMPORT']='get_atlas_version'\n from core import Extension, setup\n from misc_util import get_cmd\n import log\n magic = hex(hash(repr(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 build_dir = _get_build_temp()\n extra_args = ['--build-lib',build_dir]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n import distutils.core\n old_dist = distutils.core._setup_distribution\n distutils.core._setup_distribution = None\n return_flag = True\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n return_flag = False\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n distutils.core._setup_distribution = old_dist\n\n if return_flag:\n return\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n target = os.path.join(build_dir,'atlas_version'+so_ext)\n cmd = [get_pythonexe(),'-c',\n '\"import imp,os;os.environ[\\\\\"NO_SCIPY_IMPORT\\\\\"]='\\\n '\\\\\"system_info.get_atlas_version:load atlas_version\\\\\";'\\\n '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.search(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'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec'])\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 lapack_mkl_info = get_info('lapack_mkl')\n if lapack_mkl_info:\n self.set_info(**lapack_mkl_info)\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 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 if atlas_version=='3.2.1_pre3.3.6':\n 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',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\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 blas_mkl_info = get_info('blas_mkl')\n if blas_mkl_info:\n self.set_info(**blas_mkl_info)\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 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 = 'Numeric'\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 = []\n for v in ['__version__','version']:\n vrs = getattr(module,v,None)\n if vrs is None:\n continue\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (vrs)),\n (self.modulename.upper(),None)]\n break\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 Numeric_info(_numpy_info):\n section = 'Numeric'\n modulename = 'Numeric'\n\nclass numpy_info(_numpy_info):\n section = 'numpy'\n modulename = 'numpy'\n\nclass f2py_info(system_info):\n def calc_info(self):\n try:\n import numpy.f2py as f2py\n except ImportError:\n return\n f2py_dir = os.path.join(os.path.dirname(f2py.__file__),'src')\n self.set_info(sources = [os.path.join(f2py_dir,'fortranobject.c')],\n include_dirs = [f2py_dir])\n return\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\nclass umfpack_info(system_info):\n section = 'umfpack'\n dir_env_var = 'UMFPACK'\n notfounderror = UmfpackNotFoundError\n _lib_names = ['umfpack','amd']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n umfpack_libs = self.get_libs('umfpack_libs', self._lib_names)\n for d in lib_dirs:\n umf = self.check_libs(d,umfpack_libs,[])\n if umf is not None:\n info = umf\n break\n else:\n return\n\n include_dirs = self.get_include_dirs()\n\n inc_dir = None\n for d in include_dirs:\n d = os.path.join(d,'umfpack')\n if self.combine_paths(d,'umfpack.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir],\n define_macros=[('SCIPY_UMFPACK_H',None)],\n swig_opts = ['-I' + inc_dir])\n\n self.set_info(**info)\n return\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 is_string(a):\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 show_only = []\n for n in sys.argv[1:]:\n if n[-5:] != '_info':\n n = n + '_info'\n show_only.append(n)\n show_all = not show_only\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n if not show_all:\n if n not in show_only: continue\n del show_only[show_only.index(n)]\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n if show_only:\n print 'Info classes not defined:',','.join(show_only)\nif __name__ == \"__main__\":\n show_all()\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n\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 numpy_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 umfpack_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' is looked for in\n\n1) Directory of main setup.py file being run.\n2) Home directory of user running the setup.py file (Not implemented yet)\n3) System wide directory (location of this file...)\n\nThe first one found is used to get system configuration options The\nformat is that used by ConfigParser (i.e., Windows .INI style). The\nsection DEFAULT has options that are the default for each section. The\navailable sections are fftw, atlas, and x11. Appropiate defaults are\nused if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\nfrom exec_command import find_executable, exec_command, get_pythonexe\nfrom numpy.distutils.misc_util import is_sequence, is_string\nimport distutils.sysconfig\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\',\n os.path.join(distutils.sysconfig.EXEC_PREFIX,\n 'libs')]\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 '/opt/local/lib', '/sw/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include',\n '/opt/local/include', '/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_standard_file(fname):\n \"\"\"Returns a list of files named 'fname' from\n 1) System-wide directory (directory-location of this module)\n 2) Users HOME directory (os.environ['HOME'])\n 3) Local directory\n \"\"\"\n # System-wide file\n filenames = []\n try:\n f = __file__\n except NameError:\n f = sys.argv[0]\n else:\n sysfile = os.path.join(os.path.split(os.path.abspath(f))[0],\n fname)\n if os.path.isfile(sysfile):\n filenames.append(sysfile)\n\n # Home directory\n # And look for the user config file\n try:\n f = os.environ['HOME']\n except KeyError:\n pass\n else:\n user_file = os.path.join(f, fname)\n if os.path.isfile(user_file):\n filenames.append(user_file)\n\n # Local file\n if os.path.isfile(fname):\n filenames.append(os.path.abspath(fname))\n\n return filenames\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 'mkl':mkl_info,\n 'lapack_mkl':lapack_mkl_info, # use lapack_opt instead\n 'blas_mkl':blas_mkl_info, # use blas_opt instead\n 'x11':x11_info,\n 'fft_opt':fft_opt_info,\n 'fftw':fftw_info,\n 'fftw2':fftw2_info,\n 'fftw3':fftw3_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 'f2py':f2py_info,\n 'Numeric':Numeric_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 'umfpack':umfpack_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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/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 numpy/distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\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 UmfpackNotFoundError(NotFoundError):\n \"\"\"\n UMFPACK sparse solver (http://www.cise.ufl.edu/research/sparse/umfpack/)\n not found. Directories to search for the libraries can be specified in the\n numpy/distutils/site.cfg file (section [umfpack]) or by setting\n the UMFPACK environment variable.\"\"\"\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['libraries'] = ''\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 self.files = get_standard_file('site.cfg')\n self.parse_config_files()\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, int)\n\n def parse_config_files(self):\n self.cp.read(self.files)\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n\n def calc_libraries_info(self):\n libs = self.get_libraries()\n dirs = self.get_lib_dirs()\n info = {}\n for lib in libs:\n i = None\n for d in dirs:\n i = self.check_libs(d,[lib])\n if i is not None:\n break\n if i is not None:\n dict_append(info,**i)\n else:\n print 'Library %s was not found. Ignoring' % (lib)\n return info\n\n def set_info(self,**info):\n if info:\n lib_info = self.calc_libraries_info()\n dict_append(info,**lib_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 numpy.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(repr(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 env_var = self.dir_env_var\n if env_var:\n if is_sequence(env_var):\n e0 = env_var[-1]\n for e in env_var:\n if os.environ.has_key(e):\n e0 = e\n break\n if not env_var[0]==e0:\n print 'Setting %s=%s' % (env_var[0],e0)\n env_var = e0\n if env_var and os.environ.has_key(env_var):\n d = os.environ[env_var]\n if d=='None':\n print 'Disabled',self.__class__.__name__,'(%s is None)' \\\n % (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 if not default:\n return []\n if is_string(default):\n return [default]\n return default\n return [b for b in [a.strip() for a in libs.split(',')] if b]\n\n def get_libraries(self, key='libraries'):\n return self.get_libs(key,'')\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 return\n\n def check_libs2(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 info = self._check_libs(lib_dir,libs,opt_libs,exts)\n if info is not None: return info\n return\n\n def _lib_list(self, lib_dir, libs, exts):\n assert is_string(lib_dir)\n liblist = []\n for l in libs:\n for ext in exts:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n break\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, exts):\n found_libs = self._lib_list(lib_dir, libs, exts)\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, exts)\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 else:\n warnings.warn(\"Library error: libs=%s found_libs=%s\" % \\\n (libs, found_libs))\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\n\nclass fft_opt_info(system_info):\n\n def calc_info(self):\n info = {}\n fftw_info = get_info('fftw3') or get_info('fftw2') or get_info('dfftw')\n djbfft_info = get_info('djbfft')\n if fftw_info:\n dict_append(info,**fftw_info)\n if djbfft_info:\n dict_append(info,**djbfft_info)\n self.set_info(**info)\n return\n\n\nclass fftw_info(system_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_ver_info(self,ver_param):\n \"\"\"Returns True on successful version detection, else False\"\"\"\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', ver_param['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,ver_param['includes']))==len(ver_param['includes']):\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=ver_param['macros'])\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n return True\n else:\n if self.verbosity>0:\n print ' %s not found' % (ver_param['name'])\n return False\n\n def calc_info(self):\n for i in self.ver_info:\n if self.calc_ver_info(i):\n break\n\nclass fftw2_info(fftw_info):\n #variables to override\n section = 'fftw'\n dir_env_var = 'FFTW'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw2',\n 'libs':['rfftw', 'fftw'],\n 'includes':['fftw.h','rfftw.h'],\n 'macros':[('SCIPY_FFTW_H',None)]}\n ]\n\nclass fftw3_info(fftw_info):\n #variables to override\n section = 'fftw3'\n dir_env_var = 'FFTW3'\n notfounderror = FFTWNotFoundError\n ver_info = [ { 'name':'fftw3',\n 'libs':['fftw3'],\n 'includes':['fftw3.h'],\n 'macros':[('SCIPY_FFTW3_H',None)]},\n ]\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n ver_info = [ { 'name':'dfftw',\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 ver_info = [ { 'name':'sfftw',\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 ver_info = [ { 'name':'fftw threads',\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 ver_info = [ { 'name':'dfftw threads',\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 ver_info = [ { 'name':'sfftw threads',\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','libdjbfft'+so_ext])\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 return\n\nclass mkl_info(system_info):\n section = 'mkl'\n dir_env_var = 'MKL'\n _lib_mkl = ['mkl','vml','guide']\n\n def get_mkl_rootdir(self):\n mklroot = os.environ.get('MKLROOT',None)\n if mklroot is not None:\n return mklroot\n paths = os.environ.get('LD_LIBRARY_PATH','').split(os.pathsep)\n ld_so_conf = '/etc/ld.so.conf'\n if os.path.isfile(ld_so_conf):\n for d in open(ld_so_conf,'r').readlines():\n d = d.strip()\n if d: paths.append(d)\n intel_mkl_dirs = []\n for path in paths:\n path_atoms = path.split(os.sep)\n for m in path_atoms:\n if m.startswith('mkl'):\n d = os.sep.join(path_atoms[:path_atoms.index(m)+2])\n intel_mkl_dirs.append(d)\n break\n for d in paths:\n dirs = glob(os.path.join(d,'mkl','*')) + glob(os.path.join(d,'mkl*'))\n for d in dirs:\n if os.path.isdir(os.path.join(d,'lib')):\n return d\n return None\n\n def __init__(self):\n mklroot = self.get_mkl_rootdir()\n if mklroot is None:\n system_info.__init__(self)\n else:\n from cpuinfo import cpu\n if cpu.is_Itanium():\n plt = '64'\n l = 'mkl_ipf'\n elif cpu.is_Xeon():\n plt = 'em64t'\n l = 'mkl_em64t'\n else:\n plt = '32'\n l = 'mkl_ia32'\n if l not in self._lib_mkl:\n self._lib_mkl.insert(0,l)\n system_info.__init__(self,\n default_lib_dirs=[os.path.join(mklroot,'lib',plt)],\n default_include_dirs=[os.path.join(mklroot,'include')])\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n mkl_libs = self.get_libs('mkl_libs',self._lib_mkl)\n mkl = None\n for d in lib_dirs:\n mkl = self.check_libs2(d,mkl_libs)\n if mkl is not None:\n break\n if mkl is None:\n return\n info = {}\n dict_append(info,**mkl)\n dict_append(info,libraries = ['pthread'], include_dirs = incl_dirs)\n self.set_info(**info)\n\nclass lapack_mkl_info(mkl_info):\n\n def calc_info(self):\n mkl = get_info('mkl')\n if not mkl:\n return\n lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])\n info = {'libraries': lapack_libs}\n dict_append(info,**mkl)\n self.set_info(**info)\n\nclass blas_mkl_info(mkl_info):\n pass\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\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 numpy/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 dir_env_var = ['PTATLAS','ATLAS']\n _lib_names = ['ptf77blas','ptcblas']\n\nclass atlas_blas_threads_info(atlas_blas_info):\n dir_env_var = ['PTATLAS','ATLAS']\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 numpy_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_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\ndef get_atlas_version(**config):\n os.environ['NO_SCIPY_IMPORT']='get_atlas_version'\n from core import Extension, setup\n from misc_util import get_cmd\n import log\n magic = hex(hash(repr(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 build_dir = _get_build_temp()\n extra_args = ['--build-lib',build_dir]\n for a in sys.argv:\n if re.match('[-][-]compiler[=]',a):\n extra_args.append(a)\n import distutils.core\n old_dist = distutils.core._setup_distribution\n distutils.core._setup_distribution = None\n return_flag = True\n try:\n dist = setup(ext_modules=[ext],\n script_name = 'get_atlas_version',\n script_args = ['build_src','build_ext']+extra_args)\n return_flag = False\n except Exception,msg:\n print \"##### msg: %s\" % msg\n if not msg:\n msg = \"Unknown Exception\"\n log.warn(msg)\n distutils.core._setup_distribution = old_dist\n\n if return_flag:\n return\n\n from distutils.sysconfig import get_config_var\n so_ext = get_config_var('SO')\n target = os.path.join(build_dir,'atlas_version'+so_ext)\n cmd = [get_pythonexe(),'-c',\n '\"import imp,os;os.environ[\\\\\"NO_SCIPY_IMPORT\\\\\"]='\\\n '\\\\\"system_info.get_atlas_version:load atlas_version\\\\\";'\\\n '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.search(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'])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec'])\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 lapack_mkl_info = get_info('lapack_mkl')\n if lapack_mkl_info:\n self.set_info(**lapack_mkl_info)\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 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 if atlas_version=='3.2.1_pre3.3.6':\n 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',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\n link_args.extend(['-Wl,-framework','-Wl,Accelerate'])\n elif os.path.exists('/System/Library/Frameworks/vecLib.framework/'):\n args.extend(['-faltivec',\n '-I/System/Library/Frameworks/vecLib.framework/Headers',\n ])\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 blas_mkl_info = get_info('blas_mkl')\n if blas_mkl_info:\n self.set_info(**blas_mkl_info)\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 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 = 'Numeric'\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 = []\n for v in ['__version__','version']:\n vrs = getattr(module,v,None)\n if vrs is None:\n continue\n macros = [(self.modulename.upper()+'_VERSION',\n '\"\\\\\"%s\\\\\"\"' % (vrs)),\n (self.modulename.upper(),None)]\n break\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 Numeric_info(_numpy_info):\n section = 'Numeric'\n modulename = 'Numeric'\n\nclass numpy_info(_numpy_info):\n section = 'numpy'\n modulename = 'numpy'\n\nclass f2py_info(system_info):\n def calc_info(self):\n try:\n import numpy.f2py as f2py\n except ImportError:\n return\n f2py_dir = os.path.join(os.path.dirname(f2py.__file__),'src')\n self.set_info(sources = [os.path.join(f2py_dir,'fortranobject.c')],\n include_dirs = [f2py_dir])\n return\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\nclass umfpack_info(system_info):\n section = 'umfpack'\n dir_env_var = 'UMFPACK'\n notfounderror = UmfpackNotFoundError\n _lib_names = ['umfpack','amd']\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n umfpack_libs = self.get_libs('umfpack_libs', self._lib_names)\n for d in lib_dirs:\n umf = self.check_libs(d,umfpack_libs,[])\n if umf is not None:\n info = umf\n break\n else:\n return\n\n include_dirs = self.get_include_dirs()\n\n inc_dir = None\n for d in include_dirs:\n d = os.path.join(d,'umfpack')\n if self.combine_paths(d,'umfpack.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir],\n define_macros=[('SCIPY_UMFPACK_H',None)],\n swig_opts = ['-I' + inc_dir])\n\n self.set_info(**info)\n return\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 is_string(a):\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 show_only = []\n for n in sys.argv[1:]:\n if n[-5:] != '_info':\n n = n + '_info'\n show_only.append(n)\n show_all = not show_only\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n if not show_all:\n if n not in show_only: continue\n del show_only[show_only.index(n)]\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n if show_only:\n print 'Info classes not defined:',','.join(show_only)\nif __name__ == \"__main__\":\n show_all()\n", + "methods": [ + { + "name": "get_standard_file", + "long_name": "get_standard_file( fname )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 6, + "token_count": 142, + "parameters": [ + "fname" + ], + "start_line": 154, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "get_info", + "long_name": "get_info( name , notfound_action = 0 )", + "filename": "system_info.py", + "nloc": 52, + "complexity": 1, + "token_count": 230, + "parameters": [ + "name", + "notfound_action" + ], + "start_line": 189, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 19, + "complexity": 1, + "token_count": 140, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs", + "verbosity" + ], + "start_line": 328, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "parse_config_files", + "long_name": "parse_config_files( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "calc_libraries_info", + "long_name": "calc_libraries_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 5, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 353, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "info" + ], + "start_line": 369, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 375, + "end_line": 376, + "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": 208, + "parameters": [ + "self", + "notfound_action" + ], + "start_line": 378, + "end_line": 413, + "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": 47, + "complexity": 20, + "token_count": 399, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 415, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "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": 469, + "end_line": 470, + "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": 10, + "complexity": 7, + "token_count": 74, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 472, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_libraries", + "long_name": "get_libraries( self , key = 'libraries' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "key" + ], + "start_line": 483, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 5, + "token_count": 79, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 486, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_libs2", + "long_name": "check_libs2( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 10, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 500, + "end_line": 511, + "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 , exts )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self", + "lib_dir", + "libs", + "exts" + ], + "start_line": 513, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "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": 525, + "end_line": 527, + "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 , exts )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 3, + "token_count": 114, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs", + "exts" + ], + "start_line": 529, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 543, + "end_line": 544, + "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": 10, + "complexity": 5, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 549, + "end_line": 558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_ver_info", + "long_name": "calc_ver_info( self , ver_param )", + "filename": "system_info.py", + "nloc": 31, + "complexity": 9, + "token_count": 184, + "parameters": [ + "self", + "ver_param" + ], + "start_line": 578, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 3, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 611, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 683, + "end_line": 688, + "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": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 690, + "end_line": 711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "get_mkl_rootdir", + "long_name": "get_mkl_rootdir( self )", + "filename": "system_info.py", + "nloc": 24, + "complexity": 11, + "token_count": 211, + "parameters": [ + "self" + ], + "start_line": 718, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 18, + "complexity": 5, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 4, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 765, + "end_line": 779, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 783, + "end_line": 790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 808, + "end_line": 814, + "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": 816, + "end_line": 896, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "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": 901, + "end_line": 923, + "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": 946, + "end_line": 958, + "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": 965, + "end_line": 970, + "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": 972, + "end_line": 1056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 1 + }, + { + "name": "_get_build_temp", + "long_name": "_get_build_temp( )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 1075, + "end_line": 1078, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "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": 1086, + "end_line": 1095, + "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": 54, + "complexity": 10, + "token_count": 322, + "parameters": [ + "config" + ], + "start_line": 1080, + "end_line": 1144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 72, + "complexity": 20, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 1149, + "end_line": 1229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 57, + "complexity": 14, + "token_count": 331, + "parameters": [ + "self" + ], + "start_line": 1234, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "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": 1304, + "end_line": 1316, + "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": 1324, + "end_line": 1329, + "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": 1331, + "end_line": 1366, + "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": 1372, + "end_line": 1375, + "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": 1377, + "end_line": 1396, + "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": 1403, + "end_line": 1424, + "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": 29, + "complexity": 8, + "token_count": 161, + "parameters": [ + "self" + ], + "start_line": 1426, + "end_line": 1461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 1476, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1490, + "end_line": 1495, + "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": 1497, + "end_line": 1517, + "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": 1523, + "end_line": 1528, + "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": 1530, + "end_line": 1552, + "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": 1564, + "end_line": 1567, + "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": 1568, + "end_line": 1571, + "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": 1573, + "end_line": 1626, + "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": 23, + "complexity": 6, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 1690, + "end_line": 1716, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args , ** kws )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 11, + "token_count": 191, + "parameters": [ + "args", + "kws" + ], + "start_line": 1729, + "end_line": 1753, + "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": 1757, + "end_line": 1773, + "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": 20, + "complexity": 8, + "token_count": 137, + "parameters": [], + "start_line": 1775, + "end_line": 1794, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_standard_file", + "long_name": "get_standard_file( fname )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 6, + "token_count": 142, + "parameters": [ + "fname" + ], + "start_line": 154, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "get_info", + "long_name": "get_info( name , notfound_action = 0 )", + "filename": "system_info.py", + "nloc": 52, + "complexity": 1, + "token_count": 230, + "parameters": [ + "name", + "notfound_action" + ], + "start_line": 189, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 19, + "complexity": 1, + "token_count": 140, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs", + "verbosity" + ], + "start_line": 328, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "parse_config_files", + "long_name": "parse_config_files( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "calc_libraries_info", + "long_name": "calc_libraries_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 5, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 353, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "info" + ], + "start_line": 369, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 375, + "end_line": 376, + "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": 208, + "parameters": [ + "self", + "notfound_action" + ], + "start_line": 378, + "end_line": 413, + "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": 47, + "complexity": 20, + "token_count": 399, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 415, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "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": 469, + "end_line": 470, + "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": 10, + "complexity": 7, + "token_count": 74, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 472, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "get_libraries", + "long_name": "get_libraries( self , key = 'libraries' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "key" + ], + "start_line": 483, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 5, + "token_count": 79, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 486, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_libs2", + "long_name": "check_libs2( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 10, + "complexity": 4, + "token_count": 72, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 500, + "end_line": 511, + "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 , exts )", + "filename": "system_info.py", + "nloc": 11, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self", + "lib_dir", + "libs", + "exts" + ], + "start_line": 513, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "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": 525, + "end_line": 527, + "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 , exts )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 3, + "token_count": 114, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs", + "exts" + ], + "start_line": 529, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 543, + "end_line": 544, + "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": 10, + "complexity": 5, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 549, + "end_line": 558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_ver_info", + "long_name": "calc_ver_info( self , ver_param )", + "filename": "system_info.py", + "nloc": 31, + "complexity": 9, + "token_count": 184, + "parameters": [ + "self", + "ver_param" + ], + "start_line": 578, + "end_line": 609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 3, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 611, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 683, + "end_line": 688, + "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": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 690, + "end_line": 711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "get_mkl_rootdir", + "long_name": "get_mkl_rootdir( self )", + "filename": "system_info.py", + "nloc": 24, + "complexity": 11, + "token_count": 211, + "parameters": [ + "self" + ], + "start_line": 718, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 762, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 15, + "complexity": 4, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 764, + "end_line": 778, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 782, + "end_line": 789, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 807, + "end_line": 813, + "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": 815, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "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": 900, + "end_line": 922, + "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": 945, + "end_line": 957, + "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": 964, + "end_line": 969, + "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": 971, + "end_line": 1055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 1 + }, + { + "name": "_get_build_temp", + "long_name": "_get_build_temp( )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 1074, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "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": 1085, + "end_line": 1094, + "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": 54, + "complexity": 10, + "token_count": 322, + "parameters": [ + "config" + ], + "start_line": 1079, + "end_line": 1143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 72, + "complexity": 20, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 1148, + "end_line": 1228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 57, + "complexity": 14, + "token_count": 331, + "parameters": [ + "self" + ], + "start_line": 1233, + "end_line": 1294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 62, + "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": 1303, + "end_line": 1315, + "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": 1323, + "end_line": 1328, + "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": 1330, + "end_line": 1365, + "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": 1371, + "end_line": 1374, + "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": 1376, + "end_line": 1395, + "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": 1402, + "end_line": 1423, + "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": 29, + "complexity": 8, + "token_count": 161, + "parameters": [ + "self" + ], + "start_line": 1425, + "end_line": 1460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 1475, + "end_line": 1483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1489, + "end_line": 1494, + "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": 1496, + "end_line": 1516, + "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": 1522, + "end_line": 1527, + "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": 1529, + "end_line": 1551, + "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": 1563, + "end_line": 1566, + "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": 1567, + "end_line": 1570, + "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": 1572, + "end_line": 1625, + "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": 23, + "complexity": 6, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 1689, + "end_line": 1715, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args , ** kws )", + "filename": "system_info.py", + "nloc": 22, + "complexity": 11, + "token_count": 191, + "parameters": [ + "args", + "kws" + ], + "start_line": 1728, + "end_line": 1752, + "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": 1756, + "end_line": 1772, + "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": 20, + "complexity": 8, + "token_count": 137, + "parameters": [], + "start_line": 1774, + "end_line": 1793, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 783, + "end_line": 790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 18, + "complexity": 5, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 743, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "nloc": 1572, + "complexity": 341, + "token_count": 8787, + "diff_parsed": { + "added": [ + " l = 'mkl' # use shared library", + " #l = 'mkl_ipf'", + " #l = 'mkl_em64t'", + " #l = 'mkl_ia32'", + " lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])" + ], + "deleted": [ + " l = 'mkl_ipf'", + " l = 'mkl_em64t'", + " l = 'mkl_ia32'", + " lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])" + ] + } + } + ] + } +] \ No newline at end of file