diff --git "a/partition_75.json" "b/partition_75.json" new file mode 100644--- /dev/null +++ "b/partition_75.json" @@ -0,0 +1,86315 @@ +[ + { + "hash": "7cff614fe4080f735fe6b66c0f55ff4377b750bd", + "msg": "numpy no longer needs to be a namespace package.", + "author": { + "name": "Robert Kern", + "email": "robert.kern@gmail.com" + }, + "committer": { + "name": "Robert Kern", + "email": "robert.kern@gmail.com" + }, + "author_date": "2006-01-19T22:21:20+00:00", + "author_timezone": 0, + "committer_date": "2006-01-19T22:21:20+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "8e801afb78576b88737b97e5e1b2ca79930d5fb4" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 6, + "insertions": 0, + "lines": 6, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/__init__.py", + "new_path": "numpy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -19,12 +19,6 @@\n except ImportError:\n show_config = None\n \n-try:\n- import pkg_resources as _pk # activate namespace packages (manipulates __path__)\n- del _pk\n-except ImportError:\n- pass\n-\n if show_config is None:\n import sys as _sys\n print >> _sys.stderr, 'Running from numpy source directory.'\n", + "added_lines": 0, + "deleted_lines": 6, + "source_code": "\"\"\"\\\nNumPy\n==========\n\nYou can support the development of NumPy and SciPy by purchasing\ndocumentation at\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\n\"\"\"\n\ntry:\n from __config__ import show as show_config\nexcept ImportError:\n show_config = None\n\nif show_config is None:\n import sys as _sys\n print >> _sys.stderr, 'Running from numpy source directory.'\n del _sys\nelse:\n from version import version as __version__\n\n import os as _os\n NUMPY_IMPORT_VERBOSE = int(_os.environ.get('NUMPY_IMPORT_VERBOSE','0'))\n del _os\n from _import_tools import PackageLoader\n pkgload = PackageLoader()\n pkgload('testing','core','linalg','lib','dft','random','f2py','distutils',\n verbose=NUMPY_IMPORT_VERBOSE,postpone=False)\n\n __doc__ += \"\"\"\n\nAvailable subpackages\n---------------------\n\"\"\"\n __doc__ += pkgload.get_pkgdocs()\n\n test = ScipyTest('numpy').test\n import add_newdocs\n\n __doc__ += \"\"\"\n\nUtility tools\n-------------\n\n test --- Run numpy unittests\n pkgload --- Load numpy packages\n show_config --- Show numpy build configuration\n dual --- Overwrite certain functions with high-performance Scipy tools\n __version__ --- Numpy version string\n\nEnvironment variables\n---------------------\n\n NUMPY_IMPORT_VERBOSE --- pkgload verbose flag, default is 0.\n\"\"\"\n", + "source_code_before": "\"\"\"\\\nNumPy\n==========\n\nYou can support the development of NumPy and SciPy by purchasing\ndocumentation at\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\n\"\"\"\n\ntry:\n from __config__ import show as show_config\nexcept ImportError:\n show_config = None\n\ntry:\n import pkg_resources as _pk # activate namespace packages (manipulates __path__)\n del _pk\nexcept ImportError:\n pass\n\nif show_config is None:\n import sys as _sys\n print >> _sys.stderr, 'Running from numpy source directory.'\n del _sys\nelse:\n from version import version as __version__\n\n import os as _os\n NUMPY_IMPORT_VERBOSE = int(_os.environ.get('NUMPY_IMPORT_VERBOSE','0'))\n del _os\n from _import_tools import PackageLoader\n pkgload = PackageLoader()\n pkgload('testing','core','linalg','lib','dft','random','f2py','distutils',\n verbose=NUMPY_IMPORT_VERBOSE,postpone=False)\n\n __doc__ += \"\"\"\n\nAvailable subpackages\n---------------------\n\"\"\"\n __doc__ += pkgload.get_pkgdocs()\n\n test = ScipyTest('numpy').test\n import add_newdocs\n\n __doc__ += \"\"\"\n\nUtility tools\n-------------\n\n test --- Run numpy unittests\n pkgload --- Load numpy packages\n show_config --- Show numpy build configuration\n dual --- Overwrite certain functions with high-performance Scipy tools\n __version__ --- Numpy version string\n\nEnvironment variables\n---------------------\n\n NUMPY_IMPORT_VERBOSE --- pkgload verbose flag, default is 0.\n\"\"\"\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 56, + "complexity": 0, + "token_count": 121, + "diff_parsed": { + "added": [], + "deleted": [ + "try:", + " import pkg_resources as _pk # activate namespace packages (manipulates __path__)", + " del _pk", + "except ImportError:", + " pass", + "" + ] + } + } + ] + }, + { + "hash": "39edf8031bbbaad86b85195e0db3090ad9c9f681", + "msg": "Defined False_ and True_", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-01-20T00:19:09+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T00:19:09+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "7cff614fe4080f735fe6b66c0f55ff4377b750bd" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 9, + "insertions": 11, + "lines": 20, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/numeric.py", + "new_path": "numpy/core/numeric.py", + "filename": "numeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -16,7 +16,7 @@\n 'seterr', 'geterr', 'setbufsize', 'getbufsize',\n 'seterrcall', 'geterrcall',\n 'Inf', 'inf', 'infty', 'Infinity',\n- 'nan', 'NaN']\n+ 'nan', 'NaN', 'False_', 'True_']\n \n import sys\n import multiarray\n@@ -472,6 +472,8 @@ def _setdef():\n \n Inf = inf = infty = Infinity = PINF\n nan = NaN = NAN\n+False_ = bool_(False)\n+True_ = bool_(True)\n \n import oldnumeric\n from oldnumeric import *\n", + "added_lines": 3, + "deleted_lines": 1, + "source_code": "__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',\n 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtype',\n 'fromstring', 'fromfile', 'frombuffer','newbuffer',\n 'getbuffer',\n 'where', 'concatenate', 'fastCopyAndTranspose', 'lexsort',\n 'register_dtype', 'set_numeric_ops', 'can_cast',\n 'asarray', 'asanyarray', 'isfortran', 'zeros_like', 'empty_like',\n 'correlate', 'convolve', 'inner', 'dot', 'outer', 'vdot',\n 'alterdot', 'restoredot', 'cross',\n 'array2string', 'get_printoptions', 'set_printoptions',\n 'array_repr', 'array_str', 'set_string_function',\n 'little_endian',\n 'indices', 'fromfunction',\n 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',\n 'ones', 'identity', 'allclose',\n 'seterr', 'geterr', 'setbufsize', 'getbufsize',\n 'seterrcall', 'geterrcall',\n 'Inf', 'inf', 'infty', 'Infinity',\n 'nan', 'NaN', 'False_', 'True_']\n\nimport sys\nimport multiarray\nimport umath\nfrom umath import *\nimport numerictypes\nfrom numerictypes import *\n\ndef extend_all(module):\n adict = {}\n for a in __all__:\n adict[a] = 1\n try:\n mall = getattr(module, '__all__')\n except AttributeError:\n mall = [k for k in module.__dict__.keys() if not k.startswith('_')]\n for a in mall:\n if a not in adict:\n __all__.append(a)\n\nextend_all(umath)\nextend_all(numerictypes)\n\nnewaxis = None\n\nndarray = multiarray.ndarray\nbigndarray = multiarray.bigndarray\nflatiter = multiarray.flatiter\nbroadcast = multiarray.broadcast\ndtype=multiarray.dtype\nufunc = type(sin)\n\narange = multiarray.arange\narray = multiarray.array\nzeros = multiarray.zeros\nempty = multiarray.empty\nfromstring = multiarray.fromstring\nfromfile = multiarray.fromfile\nfrombuffer = multiarray.frombuffer\nnewbuffer = multiarray.newbuffer\ngetbuffer = multiarray.getbuffer\nwhere = multiarray.where\nconcatenate = multiarray.concatenate\nfastCopyAndTranspose = multiarray._fastCopyAndTranspose\nregister_dtype = multiarray.register_dtype\nset_numeric_ops = multiarray.set_numeric_ops\ncan_cast = multiarray.can_cast\nlexsort = multiarray.lexsort\n\n\ndef asarray(a, dtype=None, fortran=False):\n \"\"\"returns a as an array. Unlike array(),\n no copy is performed if a is already an array. Subclasses are converted\n to base class ndarray.\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran)\n\ndef asanyarray(a, dtype=None, copy=False, fortran=False):\n \"\"\"will pass subclasses through...\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran, subok=1)\n\ndef isfortran(a):\n return a.flags['FNC']\n\n# from Fernando Perez's IPython\ndef zeros_like(a):\n \"\"\"Return an array of zeros of the shape and typecode of a.\n\n If you don't explicitly need the array to be zeroed, you should instead\n use empty_like(), which is faster as it only allocates memory.\"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(zeros(a.shape, a.dtype, a.flags['FNC']))\n\ndef empty_like(a):\n \"\"\"Return an empty (uninitialized) array of the shape and typecode of a.\n\n Note that this does NOT initialize the returned array. If you require\n your array to be initialized, you should use zeros_like().\n\n \"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(empty(a.shape, a.dtype, a.flags['FNC']))\n\n# end Fernando's utilities\n\n_mode_from_name_dict = {'v': 0,\n 's' : 1,\n 'f' : 2}\n\ndef _mode_from_name(mode):\n if isinstance(mode, type(\"\")):\n return _mode_from_name_dict[mode.lower()[0]]\n return mode\n\ndef correlate(a,v,mode='valid'):\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,v,mode)\n\n\ndef convolve(a,v,mode='full'):\n \"\"\"Returns the discrete, linear convolution of 1-D\n sequences a and v; mode can be 0 (valid), 1 (same), or 2 (full)\n to specify size of the resulting sequence.\n \"\"\"\n if (len(v) > len(a)):\n a, v = v, a\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,asarray(v)[::-1],mode)\n\n\ninner = multiarray.inner\ndot = multiarray.dot\n\ndef outer(a,b):\n \"\"\"outer(a,b) returns the outer product of two vectors.\n result(i,j) = a(i)*b(j) when a and b are vectors\n Will accept any arguments that can be made into vectors.\n \"\"\"\n a = asarray(a)\n b = asarray(b)\n return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]\n\ndef vdot(a, b):\n \"\"\"Returns the dot product of 2 vectors (or anything that can be made into\n a vector). NB: this is not the same as `dot`, as it takes the conjugate\n of its first argument if complex and always returns a scalar.\"\"\"\n return dot(asarray(a).ravel().conj(), asarray(b).ravel())\n\n# try to import blas optimized dot if available\ntry:\n # importing this changes the dot function for basic 4 types\n # to blas-optimized versions.\n from _dotblas import dot, vdot, inner, alterdot, restoredot\nexcept ImportError:\n def alterdot():\n pass\n def restoredot():\n pass\n\n\ndef _move_axis_to_0(a, axis):\n if axis == 0:\n return a\n n = a.ndim\n if axis < 0:\n axis += n\n axes = range(1, axis+1) + [0,] + range(axis+1, n)\n return a.transpose(axes)\n\ndef cross(a, b, axisa=-1, axisb=-1, axisc=-1):\n \"\"\"Return the cross product of two (arrays of) vectors.\n\n The cross product is performed over the last axis of a and b by default,\n and can handle axes with dimensions 2 and 3. For a dimension of 2,\n the z-component of the equivalent three-dimensional cross product is\n returned.\n \"\"\"\n a = _move_axis_to_0(asarray(a), axisa)\n b = _move_axis_to_0(asarray(b), axisb)\n msg = \"incompatible dimensions for cross product\\n\"\\\n \"(dimension must be 2 or 3)\"\n if (a.shape[0] not in [2,3]) or (b.shape[0] not in [2,3]):\n raise ValueError(msg)\n if a.shape[0] == 2:\n if (b.shape[0] == 2):\n cp = a[0]*b[1] - a[1]*b[0]\n if cp.ndim == 0:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n else:\n x = a[1]*b[2]\n y = -a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n elif a.shape[0] == 3:\n if (b.shape[0] == 3):\n x = a[1]*b[2] - a[2]*b[1]\n y = a[2]*b[0] - a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n else:\n x = -a[2]*b[1]\n y = a[2]*b[0]\n z = a[0]*b[1] - a[1]*b[0]\n cp = array([x,y,z])\n if cp.ndim == 1:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n\n\n#Use numarray's printing function\nfrom arrayprint import array2string, get_printoptions, set_printoptions\n\n_typelessdata = [int_, float_, complex_]\nif issubclass(intc, int):\n _typelessdata.append(intc)\n\nif issubclass(longlong, int):\n _typelessdata.append(longlong)\n\ndef array_repr(arr, max_line_width=None, precision=None, suppress_small=None):\n if arr.size > 0 or arr.shape==(0,):\n lst = array2string(arr, max_line_width, precision, suppress_small,\n ', ', \"array(\")\n else: # show zero-length shape unless it is (0,)\n lst = \"[], shape=%s\" % (repr(arr.shape),)\n typeless = arr.dtype.type in _typelessdata\n\n if arr.__class__ is not ndarray:\n cName= arr.__class__.__name__\n else:\n cName = \"array\"\n if typeless and arr.size:\n return cName + \"(%s)\" % lst\n else:\n typename=arr.dtype.type.__name__[:-8]\n if issubclass(arr.dtype.type, flexible):\n if typename not in ['unicode','string','void']:\n typename = arr.dtype.type.__name__\n typename = \"(%s,%d)\" % (typename, arr.itemsize)\n return cName + \"(%s, dtype=%s)\" % (lst, typename)\n\ndef array_str(a, max_line_width=None, precision=None, suppress_small=None):\n return array2string(a, max_line_width, precision, suppress_small, ' ', \"\")\n\nset_string_function = multiarray.set_string_function\nset_string_function(array_str, 0)\nset_string_function(array_repr, 1)\n\n\nlittle_endian = (sys.byteorder == 'little')\n\ndef indices(dimensions, dtype=int_):\n \"\"\"indices(dimensions,dtype=int_) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n tmp = ones(dimensions, dtype)\n lst = []\n for i in range(len(dimensions)):\n lst.append( add.accumulate(tmp, i, )-1 )\n return array(lst)\n\ndef fromfunction(function, dimensions, **kwargs):\n \"\"\"fromfunction(function, dimensions) returns an array constructed by\n calling function on a tuple of number grids. The function should\n accept as many arguments as there are dimensions which is a list of\n numbers indicating the length of the desired output for each axis.\n\n The function can also accept keyword arguments which will be\n passed in as well.\n \"\"\"\n args = indices(dimensions)\n return function(*args,**kwargs)\n\ndef isscalar(num):\n if isinstance(num, generic):\n return True\n else:\n return type(num) in ScalarType\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is equivalent to using base_repr with base 2, but about 25x\n faster.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n import math\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n\nfrom cPickle import load, loads\n_cload = load\n_file = file\n\ndef load(file):\n if isinstance(file, type(\"\")):\n file = _file(file,\"rb\")\n return _cload(file)\n\n# These are all essentially abbreviations\n# These might wind up in a special abbreviations module\n\ndef ones(shape, dtype=int_, fortran=False):\n \"\"\"ones(shape, dtype=int_) returns an array of the given\n dimensions which is initialized to all ones. \n \"\"\"\n # This appears to be slower...\n #a = empty(shape, dtype, fortran)\n #a.fill(1)\n a = zeros(shape, dtype, fortran)\n a+=1\n return a\n\ndef identity(n,dtype=int_):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n a = array([1]+n*[0],dtype=dtype)\n b = empty((n,n),dtype=dtype)\n b.flat = a\n return b\n\ndef allclose (a, b, rtol=1.e-5, atol=1.e-8):\n \"\"\" allclose(a,b,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 The relative error rtol must be positive and << 1.0\n The absolute error atol comes into play for those elements\n of y that are very small or zero; it says how small x must be also.\n \"\"\"\n x = array(a, copy=False)\n y = array(b, copy=False)\n d = less(absolute(x-y), atol + rtol * absolute(y))\n return d.ravel().all()\n\ndef _setpyvals(lst, frame, where=0):\n if not isinstance(lst, list) or len(lst) != 3:\n raise ValueError, \"Invalid pyvalues (length 3 list needed).\"\n\n try:\n wh = where.lower()[0]\n except (AttributeError, TypeError, IndexError):\n wh = None\n\n if where==0 or wh == 'l':\n frame.f_locals[UFUNC_PYVALS_NAME] = lst\n elif where == 1 or wh == 'g':\n frame.f_globals[UFUNC_PYVALS_NAME] = lst\n elif where == 2 or wh == 'b':\n frame.f_builtins[UFUNC_PYVALS_NAME] = lst \n\n umath.update_use_defaults()\n return\n\ndef _getpyvals(frame):\n try:\n return frame.f_locals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_globals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_builtins[UFUNC_PYVALS_NAME]\n except KeyError:\n return [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n\n_errdict = {\"ignore\":ERR_IGNORE,\n \"warn\":ERR_WARN,\n \"raise\":ERR_RAISE,\n \"call\":ERR_CALL}\n\n_errdict_rev = {}\nfor key in _errdict.keys():\n _errdict_rev[_errdict[key]] = key\ndel key\n\ndef seterr(divide=\"ignore\", over=\"ignore\", under=\"ignore\",\n invalid=\"ignore\", where=0):\n maskvalue = ((_errdict[divide] << SHIFT_DIVIDEBYZERO) +\n (_errdict[over] << SHIFT_OVERFLOW ) +\n (_errdict[under] << SHIFT_UNDERFLOW) +\n (_errdict[invalid] << SHIFT_INVALID))\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[1] = maskvalue\n _setpyvals(pyvals, frame, where)\n\ndef geterr():\n frame = sys._getframe().f_back\n maskvalue = _getpyvals(frame)[1]\n\n mask = 3\n res = {}\n val = (maskvalue >> SHIFT_DIVIDEBYZERO) & mask\n res['divide'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_OVERFLOW) & mask\n res['over'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_UNDERFLOW) & mask\n res['under'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_INVALID) & mask\n res['invalid'] = _errdict_rev[val]\n return res\n\ndef setbufsize(size, where=0):\n if size > 10e6:\n raise ValueError, \"Very big buffers.. %s\" % size\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[0] = size\n _setpyvals(pyvals, frame, where)\n\ndef getbufsize():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[0]\n\ndef seterrcall(func, where=0):\n if not callable(func):\n raise ValueError, \"Only callable can be used as callback\"\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[2] = func\n _setpyvals(pyvals, frame, where)\n\ndef geterrcall():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[2]\n\ndef _setdef():\n frame = sys._getframe()\n defval = [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n frame.f_globals[UFUNC_PYVALS_NAME] = defval\n frame.f_builtins[UFUNC_PYVALS_NAME] = defval\n umath.update_use_defaults()\n\n# set the default values\n_setdef()\n\nInf = inf = infty = Infinity = PINF\nnan = NaN = NAN\nFalse_ = bool_(False)\nTrue_ = bool_(True)\n\nimport oldnumeric\nfrom oldnumeric import *\nextend_all(oldnumeric)\n", + "source_code_before": "__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',\n 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtype',\n 'fromstring', 'fromfile', 'frombuffer','newbuffer',\n 'getbuffer',\n 'where', 'concatenate', 'fastCopyAndTranspose', 'lexsort',\n 'register_dtype', 'set_numeric_ops', 'can_cast',\n 'asarray', 'asanyarray', 'isfortran', 'zeros_like', 'empty_like',\n 'correlate', 'convolve', 'inner', 'dot', 'outer', 'vdot',\n 'alterdot', 'restoredot', 'cross',\n 'array2string', 'get_printoptions', 'set_printoptions',\n 'array_repr', 'array_str', 'set_string_function',\n 'little_endian',\n 'indices', 'fromfunction',\n 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',\n 'ones', 'identity', 'allclose',\n 'seterr', 'geterr', 'setbufsize', 'getbufsize',\n 'seterrcall', 'geterrcall',\n 'Inf', 'inf', 'infty', 'Infinity',\n 'nan', 'NaN']\n\nimport sys\nimport multiarray\nimport umath\nfrom umath import *\nimport numerictypes\nfrom numerictypes import *\n\ndef extend_all(module):\n adict = {}\n for a in __all__:\n adict[a] = 1\n try:\n mall = getattr(module, '__all__')\n except AttributeError:\n mall = [k for k in module.__dict__.keys() if not k.startswith('_')]\n for a in mall:\n if a not in adict:\n __all__.append(a)\n\nextend_all(umath)\nextend_all(numerictypes)\n\nnewaxis = None\n\nndarray = multiarray.ndarray\nbigndarray = multiarray.bigndarray\nflatiter = multiarray.flatiter\nbroadcast = multiarray.broadcast\ndtype=multiarray.dtype\nufunc = type(sin)\n\narange = multiarray.arange\narray = multiarray.array\nzeros = multiarray.zeros\nempty = multiarray.empty\nfromstring = multiarray.fromstring\nfromfile = multiarray.fromfile\nfrombuffer = multiarray.frombuffer\nnewbuffer = multiarray.newbuffer\ngetbuffer = multiarray.getbuffer\nwhere = multiarray.where\nconcatenate = multiarray.concatenate\nfastCopyAndTranspose = multiarray._fastCopyAndTranspose\nregister_dtype = multiarray.register_dtype\nset_numeric_ops = multiarray.set_numeric_ops\ncan_cast = multiarray.can_cast\nlexsort = multiarray.lexsort\n\n\ndef asarray(a, dtype=None, fortran=False):\n \"\"\"returns a as an array. Unlike array(),\n no copy is performed if a is already an array. Subclasses are converted\n to base class ndarray.\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran)\n\ndef asanyarray(a, dtype=None, copy=False, fortran=False):\n \"\"\"will pass subclasses through...\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran, subok=1)\n\ndef isfortran(a):\n return a.flags['FNC']\n\n# from Fernando Perez's IPython\ndef zeros_like(a):\n \"\"\"Return an array of zeros of the shape and typecode of a.\n\n If you don't explicitly need the array to be zeroed, you should instead\n use empty_like(), which is faster as it only allocates memory.\"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(zeros(a.shape, a.dtype, a.flags['FNC']))\n\ndef empty_like(a):\n \"\"\"Return an empty (uninitialized) array of the shape and typecode of a.\n\n Note that this does NOT initialize the returned array. If you require\n your array to be initialized, you should use zeros_like().\n\n \"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(empty(a.shape, a.dtype, a.flags['FNC']))\n\n# end Fernando's utilities\n\n_mode_from_name_dict = {'v': 0,\n 's' : 1,\n 'f' : 2}\n\ndef _mode_from_name(mode):\n if isinstance(mode, type(\"\")):\n return _mode_from_name_dict[mode.lower()[0]]\n return mode\n\ndef correlate(a,v,mode='valid'):\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,v,mode)\n\n\ndef convolve(a,v,mode='full'):\n \"\"\"Returns the discrete, linear convolution of 1-D\n sequences a and v; mode can be 0 (valid), 1 (same), or 2 (full)\n to specify size of the resulting sequence.\n \"\"\"\n if (len(v) > len(a)):\n a, v = v, a\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,asarray(v)[::-1],mode)\n\n\ninner = multiarray.inner\ndot = multiarray.dot\n\ndef outer(a,b):\n \"\"\"outer(a,b) returns the outer product of two vectors.\n result(i,j) = a(i)*b(j) when a and b are vectors\n Will accept any arguments that can be made into vectors.\n \"\"\"\n a = asarray(a)\n b = asarray(b)\n return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]\n\ndef vdot(a, b):\n \"\"\"Returns the dot product of 2 vectors (or anything that can be made into\n a vector). NB: this is not the same as `dot`, as it takes the conjugate\n of its first argument if complex and always returns a scalar.\"\"\"\n return dot(asarray(a).ravel().conj(), asarray(b).ravel())\n\n# try to import blas optimized dot if available\ntry:\n # importing this changes the dot function for basic 4 types\n # to blas-optimized versions.\n from _dotblas import dot, vdot, inner, alterdot, restoredot\nexcept ImportError:\n def alterdot():\n pass\n def restoredot():\n pass\n\n\ndef _move_axis_to_0(a, axis):\n if axis == 0:\n return a\n n = a.ndim\n if axis < 0:\n axis += n\n axes = range(1, axis+1) + [0,] + range(axis+1, n)\n return a.transpose(axes)\n\ndef cross(a, b, axisa=-1, axisb=-1, axisc=-1):\n \"\"\"Return the cross product of two (arrays of) vectors.\n\n The cross product is performed over the last axis of a and b by default,\n and can handle axes with dimensions 2 and 3. For a dimension of 2,\n the z-component of the equivalent three-dimensional cross product is\n returned.\n \"\"\"\n a = _move_axis_to_0(asarray(a), axisa)\n b = _move_axis_to_0(asarray(b), axisb)\n msg = \"incompatible dimensions for cross product\\n\"\\\n \"(dimension must be 2 or 3)\"\n if (a.shape[0] not in [2,3]) or (b.shape[0] not in [2,3]):\n raise ValueError(msg)\n if a.shape[0] == 2:\n if (b.shape[0] == 2):\n cp = a[0]*b[1] - a[1]*b[0]\n if cp.ndim == 0:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n else:\n x = a[1]*b[2]\n y = -a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n elif a.shape[0] == 3:\n if (b.shape[0] == 3):\n x = a[1]*b[2] - a[2]*b[1]\n y = a[2]*b[0] - a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n else:\n x = -a[2]*b[1]\n y = a[2]*b[0]\n z = a[0]*b[1] - a[1]*b[0]\n cp = array([x,y,z])\n if cp.ndim == 1:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n\n\n#Use numarray's printing function\nfrom arrayprint import array2string, get_printoptions, set_printoptions\n\n_typelessdata = [int_, float_, complex_]\nif issubclass(intc, int):\n _typelessdata.append(intc)\n\nif issubclass(longlong, int):\n _typelessdata.append(longlong)\n\ndef array_repr(arr, max_line_width=None, precision=None, suppress_small=None):\n if arr.size > 0 or arr.shape==(0,):\n lst = array2string(arr, max_line_width, precision, suppress_small,\n ', ', \"array(\")\n else: # show zero-length shape unless it is (0,)\n lst = \"[], shape=%s\" % (repr(arr.shape),)\n typeless = arr.dtype.type in _typelessdata\n\n if arr.__class__ is not ndarray:\n cName= arr.__class__.__name__\n else:\n cName = \"array\"\n if typeless and arr.size:\n return cName + \"(%s)\" % lst\n else:\n typename=arr.dtype.type.__name__[:-8]\n if issubclass(arr.dtype.type, flexible):\n if typename not in ['unicode','string','void']:\n typename = arr.dtype.type.__name__\n typename = \"(%s,%d)\" % (typename, arr.itemsize)\n return cName + \"(%s, dtype=%s)\" % (lst, typename)\n\ndef array_str(a, max_line_width=None, precision=None, suppress_small=None):\n return array2string(a, max_line_width, precision, suppress_small, ' ', \"\")\n\nset_string_function = multiarray.set_string_function\nset_string_function(array_str, 0)\nset_string_function(array_repr, 1)\n\n\nlittle_endian = (sys.byteorder == 'little')\n\ndef indices(dimensions, dtype=int_):\n \"\"\"indices(dimensions,dtype=int_) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n tmp = ones(dimensions, dtype)\n lst = []\n for i in range(len(dimensions)):\n lst.append( add.accumulate(tmp, i, )-1 )\n return array(lst)\n\ndef fromfunction(function, dimensions, **kwargs):\n \"\"\"fromfunction(function, dimensions) returns an array constructed by\n calling function on a tuple of number grids. The function should\n accept as many arguments as there are dimensions which is a list of\n numbers indicating the length of the desired output for each axis.\n\n The function can also accept keyword arguments which will be\n passed in as well.\n \"\"\"\n args = indices(dimensions)\n return function(*args,**kwargs)\n\ndef isscalar(num):\n if isinstance(num, generic):\n return True\n else:\n return type(num) in ScalarType\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is equivalent to using base_repr with base 2, but about 25x\n faster.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n import math\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n\nfrom cPickle import load, loads\n_cload = load\n_file = file\n\ndef load(file):\n if isinstance(file, type(\"\")):\n file = _file(file,\"rb\")\n return _cload(file)\n\n# These are all essentially abbreviations\n# These might wind up in a special abbreviations module\n\ndef ones(shape, dtype=int_, fortran=False):\n \"\"\"ones(shape, dtype=int_) returns an array of the given\n dimensions which is initialized to all ones. \n \"\"\"\n # This appears to be slower...\n #a = empty(shape, dtype, fortran)\n #a.fill(1)\n a = zeros(shape, dtype, fortran)\n a+=1\n return a\n\ndef identity(n,dtype=int_):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n a = array([1]+n*[0],dtype=dtype)\n b = empty((n,n),dtype=dtype)\n b.flat = a\n return b\n\ndef allclose (a, b, rtol=1.e-5, atol=1.e-8):\n \"\"\" allclose(a,b,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 The relative error rtol must be positive and << 1.0\n The absolute error atol comes into play for those elements\n of y that are very small or zero; it says how small x must be also.\n \"\"\"\n x = array(a, copy=False)\n y = array(b, copy=False)\n d = less(absolute(x-y), atol + rtol * absolute(y))\n return d.ravel().all()\n\ndef _setpyvals(lst, frame, where=0):\n if not isinstance(lst, list) or len(lst) != 3:\n raise ValueError, \"Invalid pyvalues (length 3 list needed).\"\n\n try:\n wh = where.lower()[0]\n except (AttributeError, TypeError, IndexError):\n wh = None\n\n if where==0 or wh == 'l':\n frame.f_locals[UFUNC_PYVALS_NAME] = lst\n elif where == 1 or wh == 'g':\n frame.f_globals[UFUNC_PYVALS_NAME] = lst\n elif where == 2 or wh == 'b':\n frame.f_builtins[UFUNC_PYVALS_NAME] = lst \n\n umath.update_use_defaults()\n return\n\ndef _getpyvals(frame):\n try:\n return frame.f_locals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_globals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_builtins[UFUNC_PYVALS_NAME]\n except KeyError:\n return [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n\n_errdict = {\"ignore\":ERR_IGNORE,\n \"warn\":ERR_WARN,\n \"raise\":ERR_RAISE,\n \"call\":ERR_CALL}\n\n_errdict_rev = {}\nfor key in _errdict.keys():\n _errdict_rev[_errdict[key]] = key\ndel key\n\ndef seterr(divide=\"ignore\", over=\"ignore\", under=\"ignore\",\n invalid=\"ignore\", where=0):\n maskvalue = ((_errdict[divide] << SHIFT_DIVIDEBYZERO) +\n (_errdict[over] << SHIFT_OVERFLOW ) +\n (_errdict[under] << SHIFT_UNDERFLOW) +\n (_errdict[invalid] << SHIFT_INVALID))\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[1] = maskvalue\n _setpyvals(pyvals, frame, where)\n\ndef geterr():\n frame = sys._getframe().f_back\n maskvalue = _getpyvals(frame)[1]\n\n mask = 3\n res = {}\n val = (maskvalue >> SHIFT_DIVIDEBYZERO) & mask\n res['divide'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_OVERFLOW) & mask\n res['over'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_UNDERFLOW) & mask\n res['under'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_INVALID) & mask\n res['invalid'] = _errdict_rev[val]\n return res\n\ndef setbufsize(size, where=0):\n if size > 10e6:\n raise ValueError, \"Very big buffers.. %s\" % size\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[0] = size\n _setpyvals(pyvals, frame, where)\n\ndef getbufsize():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[0]\n\ndef seterrcall(func, where=0):\n if not callable(func):\n raise ValueError, \"Only callable can be used as callback\"\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[2] = func\n _setpyvals(pyvals, frame, where)\n\ndef geterrcall():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[2]\n\ndef _setdef():\n frame = sys._getframe()\n defval = [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n frame.f_globals[UFUNC_PYVALS_NAME] = defval\n frame.f_builtins[UFUNC_PYVALS_NAME] = defval\n umath.update_use_defaults()\n\n# set the default values\n_setdef()\n\nInf = inf = infty = Infinity = PINF\nnan = NaN = NAN\n\nimport oldnumeric\nfrom oldnumeric import *\nextend_all(oldnumeric)\n", + "methods": [ + { + "name": "extend_all", + "long_name": "extend_all( module )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 7, + "token_count": 73, + "parameters": [ + "module" + ], + "start_line": 28, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( a , dtype = None , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "dtype", + "fortran" + ], + "start_line": 70, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "asanyarray", + "long_name": "asanyarray( a , dtype = None , copy = False , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "a", + "dtype", + "copy", + "fortran" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isfortran", + "long_name": "isfortran( a )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "a" + ], + "start_line": 82, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "zeros_like", + "long_name": "zeros_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 86, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "empty_like", + "long_name": "empty_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 94, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_mode_from_name", + "long_name": "_mode_from_name( mode )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 30, + "parameters": [ + "mode" + ], + "start_line": 110, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "correlate", + "long_name": "correlate( a , v , mode = 'valid' )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 115, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convolve", + "long_name": "convolve( a , v , mode = 'full' )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 57, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 120, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "outer", + "long_name": "outer( a , b )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "a", + "b" + ], + "start_line": 134, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "vdot", + "long_name": "vdot( a , b )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 33, + "parameters": [ + "a", + "b" + ], + "start_line": 143, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "alterdot", + "long_name": "alterdot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 155, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "restoredot", + "long_name": "restoredot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 157, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_move_axis_to_0", + "long_name": "_move_axis_to_0( a , axis )", + "filename": "numeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "a", + "axis" + ], + "start_line": 161, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cross", + "long_name": "cross( a , b , axisa = - 1 , axisb = - 1 , axisc = - 1 )", + "filename": "numeric.py", + "nloc": 32, + "complexity": 9, + "token_count": 360, + "parameters": [ + "a", + "b", + "axisa", + "axisb", + "axisc" + ], + "start_line": 170, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( arr , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 20, + "complexity": 8, + "token_count": 176, + "parameters": [ + "arr", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 221, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( a , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = int_ )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 54, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 253, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( function , dimensions , ** kwargs )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "function", + "dimensions", + "kwargs" + ], + "start_line": 263, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "num" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "binary_repr", + "long_name": "binary_repr( num )", + "filename": "numeric.py", + "nloc": 9, + "complexity": 3, + "token_count": 50, + "parameters": [ + "num" + ], + "start_line": 291, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "base_repr", + "long_name": "base_repr( number , base = 2 , padding = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "number", + "base", + "padding" + ], + "start_line": 306, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "load", + "long_name": "load( file )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "file" + ], + "start_line": 329, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int_ , fortran = False )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "shape", + "dtype", + "fortran" + ], + "start_line": 337, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n , dtype = int_ )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "n", + "dtype" + ], + "start_line": 348, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "a", + "b", + "rtol", + "atol" + ], + "start_line": 356, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_setpyvals", + "long_name": "_setpyvals( lst , frame , where = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 10, + "token_count": 112, + "parameters": [ + "lst", + "frame", + "where" + ], + "start_line": 369, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_getpyvals", + "long_name": "_getpyvals( frame )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 4, + "token_count": 49, + "parameters": [ + "frame" + ], + "start_line": 388, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "seterr", + "long_name": "seterr( divide = \"ignore\" , over = \"ignore\" , under = \"ignore\" , invalid = \"ignore\" , where = 0 )", + "filename": "numeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 95, + "parameters": [ + "divide", + "over", + "under", + "invalid", + "where" + ], + "start_line": 410, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "geterr", + "long_name": "geterr( )", + "filename": "numeric.py", + "nloc": 14, + "complexity": 1, + "token_count": 107, + "parameters": [], + "start_line": 422, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "setbufsize", + "long_name": "setbufsize( size , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "size", + "where" + ], + "start_line": 438, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getbufsize", + "long_name": "getbufsize( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 447, + "end_line": 449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "seterrcall", + "long_name": "seterrcall( func , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "func", + "where" + ], + "start_line": 451, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "geterrcall", + "long_name": "geterrcall( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 459, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_setdef", + "long_name": "_setdef( )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "extend_all", + "long_name": "extend_all( module )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 7, + "token_count": 73, + "parameters": [ + "module" + ], + "start_line": 28, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( a , dtype = None , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "dtype", + "fortran" + ], + "start_line": 70, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "asanyarray", + "long_name": "asanyarray( a , dtype = None , copy = False , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "a", + "dtype", + "copy", + "fortran" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isfortran", + "long_name": "isfortran( a )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "a" + ], + "start_line": 82, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "zeros_like", + "long_name": "zeros_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 86, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "empty_like", + "long_name": "empty_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 94, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_mode_from_name", + "long_name": "_mode_from_name( mode )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 30, + "parameters": [ + "mode" + ], + "start_line": 110, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "correlate", + "long_name": "correlate( a , v , mode = 'valid' )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 115, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convolve", + "long_name": "convolve( a , v , mode = 'full' )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 57, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 120, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "outer", + "long_name": "outer( a , b )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "a", + "b" + ], + "start_line": 134, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "vdot", + "long_name": "vdot( a , b )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 33, + "parameters": [ + "a", + "b" + ], + "start_line": 143, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "alterdot", + "long_name": "alterdot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 155, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "restoredot", + "long_name": "restoredot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 157, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_move_axis_to_0", + "long_name": "_move_axis_to_0( a , axis )", + "filename": "numeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "a", + "axis" + ], + "start_line": 161, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cross", + "long_name": "cross( a , b , axisa = - 1 , axisb = - 1 , axisc = - 1 )", + "filename": "numeric.py", + "nloc": 32, + "complexity": 9, + "token_count": 360, + "parameters": [ + "a", + "b", + "axisa", + "axisb", + "axisc" + ], + "start_line": 170, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( arr , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 20, + "complexity": 8, + "token_count": 176, + "parameters": [ + "arr", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 221, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( a , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = int_ )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 54, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 253, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( function , dimensions , ** kwargs )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "function", + "dimensions", + "kwargs" + ], + "start_line": 263, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "num" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "binary_repr", + "long_name": "binary_repr( num )", + "filename": "numeric.py", + "nloc": 9, + "complexity": 3, + "token_count": 50, + "parameters": [ + "num" + ], + "start_line": 291, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "base_repr", + "long_name": "base_repr( number , base = 2 , padding = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "number", + "base", + "padding" + ], + "start_line": 306, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "load", + "long_name": "load( file )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "file" + ], + "start_line": 329, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int_ , fortran = False )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "shape", + "dtype", + "fortran" + ], + "start_line": 337, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n , dtype = int_ )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "n", + "dtype" + ], + "start_line": 348, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "a", + "b", + "rtol", + "atol" + ], + "start_line": 356, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_setpyvals", + "long_name": "_setpyvals( lst , frame , where = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 10, + "token_count": 112, + "parameters": [ + "lst", + "frame", + "where" + ], + "start_line": 369, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_getpyvals", + "long_name": "_getpyvals( frame )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 4, + "token_count": 49, + "parameters": [ + "frame" + ], + "start_line": 388, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "seterr", + "long_name": "seterr( divide = \"ignore\" , over = \"ignore\" , under = \"ignore\" , invalid = \"ignore\" , where = 0 )", + "filename": "numeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 95, + "parameters": [ + "divide", + "over", + "under", + "invalid", + "where" + ], + "start_line": 410, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "geterr", + "long_name": "geterr( )", + "filename": "numeric.py", + "nloc": 14, + "complexity": 1, + "token_count": 107, + "parameters": [], + "start_line": 422, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "setbufsize", + "long_name": "setbufsize( size , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "size", + "where" + ], + "start_line": 438, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getbufsize", + "long_name": "getbufsize( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 447, + "end_line": 449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "seterrcall", + "long_name": "seterrcall( func , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "func", + "where" + ], + "start_line": 451, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "geterrcall", + "long_name": "geterrcall( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 459, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_setdef", + "long_name": "_setdef( )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 335, + "complexity": 81, + "token_count": 2583, + "diff_parsed": { + "added": [ + " 'nan', 'NaN', 'False_', 'True_']", + "False_ = bool_(False)", + "True_ = bool_(True)" + ], + "deleted": [ + " 'nan', 'NaN']" + ] + } + }, + { + "old_path": "numpy/core/tests/test_numeric.py", + "new_path": "numpy/core/tests/test_numeric.py", + "filename": "test_numeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -67,31 +67,31 @@ def check_matscalar(self):\n \n class test_bool_scalar(ScipyTestCase):\n def test_logical(self):\n- f = bool_(False)\n- t = bool_(True)\n+ f = False_\n+ t = True_\n s = \"xyz\"\n self.failUnless((t and s) is s)\n self.failUnless((f and s) is f)\n \n def test_bitwise_or(self):\n- f = bool_(False)\n- t = bool_(True)\n+ f = False_\n+ t = True_\n self.failUnless((t | t) is t)\n self.failUnless((f | t) is t)\n self.failUnless((t | f) is t)\n self.failUnless((f | f) is f)\n \n def test_bitwise_and(self): \n- f = bool_(False)\n- t = bool_(True)\n+ f = False_\n+ t = True_\n self.failUnless((t & t) is t)\n self.failUnless((f & t) is f)\n self.failUnless((t & f) is f)\n self.failUnless((f & f) is f)\n \n def test_bitwise_xor(self): \n- f = bool_(False)\n- t = bool_(True)\n+ f = False_\n+ t = True_\n self.failUnless((t ^ t) is f)\n self.failUnless((f ^ t) is t)\n self.failUnless((t ^ f) is t)\n", + "added_lines": 8, + "deleted_lines": 8, + "source_code": "from numpy.core import *\nfrom numpy.random import rand\nfrom numpy.testing import *\nfrom numpy.core.multiarray import dot as dot_\n\nclass test_dot(ScipyTestCase):\n def setUp(self):\n self.A = rand(10,8)\n self.b1 = rand(8,1)\n self.b2 = rand(8)\n self.b3 = rand(1,8)\n self.b4 = rand(10)\n self.N = 14\n\n def check_matmat(self):\n A = self.A\n c1 = dot(A.transpose(), A)\n c2 = dot_(A.transpose(), A)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matvec(self):\n A, b1 = self.A, self.b1\n c1 = dot(A, b1)\n c2 = dot_(A, b1)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matvec2(self):\n A, b2 = self.A, self.b2 \n c1 = dot(A, b2)\n c2 = dot_(A, b2)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat(self):\n A, b4 = self.A, self.b4\n c1 = dot(b4, A)\n c2 = dot_(b4, A)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat2(self):\n b3, A = self.b3, self.A\n c1 = dot(b3, A.transpose())\n c2 = dot_(b3, A.transpose())\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat3(self):\n A, b4 = self.A, self.b4\n c1 = dot(A.transpose(),b4)\n c2 = dot_(A.transpose(),b4)\n assert_almost_equal(c1, c2, decimal=self.N) \n\n def check_vecvecouter(self):\n b1, b3 = self.b1, self.b3\n c1 = dot(b1, b3)\n c2 = dot_(b1, b3)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecvecinner(self):\n b1, b3 = self.b1, self.b3\n c1 = dot(b3, b1)\n c2 = dot_(b3, b1)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matscalar(self):\n\tb1 = matrix(ones((3,3),dtype=complex))\n\tassert_equal(b1*1.0, b1)\n\n\nclass test_bool_scalar(ScipyTestCase):\n def test_logical(self):\n f = False_\n t = True_\n s = \"xyz\"\n self.failUnless((t and s) is s)\n self.failUnless((f and s) is f)\n\n def test_bitwise_or(self):\n f = False_\n t = True_\n self.failUnless((t | t) is t)\n self.failUnless((f | t) is t)\n self.failUnless((t | f) is t)\n self.failUnless((f | f) is f)\n\n def test_bitwise_and(self): \n f = False_\n t = True_\n self.failUnless((t & t) is t)\n self.failUnless((f & t) is f)\n self.failUnless((t & f) is f)\n self.failUnless((f & f) is f)\n\n def test_bitwise_xor(self): \n f = False_\n t = True_\n self.failUnless((t ^ t) is f)\n self.failUnless((f ^ t) is t)\n self.failUnless((t ^ f) is t)\n self.failUnless((f ^ f) is f)\n \n \n \n", + "source_code_before": "from numpy.core import *\nfrom numpy.random import rand\nfrom numpy.testing import *\nfrom numpy.core.multiarray import dot as dot_\n\nclass test_dot(ScipyTestCase):\n def setUp(self):\n self.A = rand(10,8)\n self.b1 = rand(8,1)\n self.b2 = rand(8)\n self.b3 = rand(1,8)\n self.b4 = rand(10)\n self.N = 14\n\n def check_matmat(self):\n A = self.A\n c1 = dot(A.transpose(), A)\n c2 = dot_(A.transpose(), A)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matvec(self):\n A, b1 = self.A, self.b1\n c1 = dot(A, b1)\n c2 = dot_(A, b1)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matvec2(self):\n A, b2 = self.A, self.b2 \n c1 = dot(A, b2)\n c2 = dot_(A, b2)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat(self):\n A, b4 = self.A, self.b4\n c1 = dot(b4, A)\n c2 = dot_(b4, A)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat2(self):\n b3, A = self.b3, self.A\n c1 = dot(b3, A.transpose())\n c2 = dot_(b3, A.transpose())\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecmat3(self):\n A, b4 = self.A, self.b4\n c1 = dot(A.transpose(),b4)\n c2 = dot_(A.transpose(),b4)\n assert_almost_equal(c1, c2, decimal=self.N) \n\n def check_vecvecouter(self):\n b1, b3 = self.b1, self.b3\n c1 = dot(b1, b3)\n c2 = dot_(b1, b3)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_vecvecinner(self):\n b1, b3 = self.b1, self.b3\n c1 = dot(b3, b1)\n c2 = dot_(b3, b1)\n assert_almost_equal(c1, c2, decimal=self.N)\n\n def check_matscalar(self):\n\tb1 = matrix(ones((3,3),dtype=complex))\n\tassert_equal(b1*1.0, b1)\n\n\nclass test_bool_scalar(ScipyTestCase):\n def test_logical(self):\n f = bool_(False)\n t = bool_(True)\n s = \"xyz\"\n self.failUnless((t and s) is s)\n self.failUnless((f and s) is f)\n\n def test_bitwise_or(self):\n f = bool_(False)\n t = bool_(True)\n self.failUnless((t | t) is t)\n self.failUnless((f | t) is t)\n self.failUnless((t | f) is t)\n self.failUnless((f | f) is f)\n\n def test_bitwise_and(self): \n f = bool_(False)\n t = bool_(True)\n self.failUnless((t & t) is t)\n self.failUnless((f & t) is f)\n self.failUnless((t & f) is f)\n self.failUnless((f & f) is f)\n\n def test_bitwise_xor(self): \n f = bool_(False)\n t = bool_(True)\n self.failUnless((t ^ t) is f)\n self.failUnless((f ^ t) is t)\n self.failUnless((t ^ f) is t)\n self.failUnless((f ^ f) is f)\n \n \n \n", + "methods": [ + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 7, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_matmat", + "long_name": "check_matmat( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matvec", + "long_name": "check_matvec( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matvec2", + "long_name": "check_matvec2( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 27, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat", + "long_name": "check_vecmat( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat2", + "long_name": "check_vecmat2( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat3", + "long_name": "check_vecmat3( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecvecouter", + "long_name": "check_vecvecouter( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 51, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecvecinner", + "long_name": "check_vecvecinner( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 57, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matscalar", + "long_name": "check_matscalar( self )", + "filename": "test_numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 63, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_logical", + "long_name": "test_logical( self )", + "filename": "test_numeric.py", + "nloc": 6, + "complexity": 3, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_or", + "long_name": "test_bitwise_or( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_and", + "long_name": "test_bitwise_and( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_xor", + "long_name": "test_bitwise_xor( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 92, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 7, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_matmat", + "long_name": "check_matmat( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matvec", + "long_name": "check_matvec( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matvec2", + "long_name": "check_matvec2( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 27, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat", + "long_name": "check_vecmat( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat2", + "long_name": "check_vecmat2( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecmat3", + "long_name": "check_vecmat3( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecvecouter", + "long_name": "check_vecvecouter( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 51, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_vecvecinner", + "long_name": "check_vecvecinner( self )", + "filename": "test_numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 57, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_matscalar", + "long_name": "check_matscalar( self )", + "filename": "test_numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 63, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_logical", + "long_name": "test_logical( self )", + "filename": "test_numeric.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_or", + "long_name": "test_bitwise_or( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_and", + "long_name": "test_bitwise_and( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_xor", + "long_name": "test_bitwise_xor( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 92, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "test_bitwise_or", + "long_name": "test_bitwise_or( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_xor", + "long_name": "test_bitwise_xor( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 92, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_logical", + "long_name": "test_logical( self )", + "filename": "test_numeric.py", + "nloc": 6, + "complexity": 3, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test_bitwise_and", + "long_name": "test_bitwise_and( self )", + "filename": "test_numeric.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "nloc": 83, + "complexity": 16, + "token_count": 727, + "diff_parsed": { + "added": [ + " f = False_", + " t = True_", + " f = False_", + " t = True_", + " f = False_", + " t = True_", + " f = False_", + " t = True_" + ], + "deleted": [ + " f = bool_(False)", + " t = bool_(True)", + " f = bool_(False)", + " t = bool_(True)", + " f = bool_(False)", + " t = bool_(True)", + " f = bool_(False)", + " t = bool_(True)" + ] + } + } + ] + }, + { + "hash": "01597c2bbe93f5d444355fd6efe5322da53bc770", + "msg": "Made ma immune to a bug in choose", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-01-20T00:21:47+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T00:21:47+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "39edf8031bbbaad86b85195e0db3090ad9c9f681" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 15, + "insertions": 12, + "lines": 27, + "files": 2, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/core/ma.py", + "new_path": "numpy/core/ma.py", + "filename": "ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1707,20 +1707,12 @@ def where (condition, x, y):\n the value masked.\n \"\"\"\n fc = filled(not_equal(condition,0), 0)\n- if x is masked:\n- xv = 0\n- xm = 1\n- else:\n- xv = filled(x)\n- xm = getmask(x)\n- if xm is nomask: xm = 0\n- if y is masked:\n- yv = 0\n- ym = 1\n- else:\n- yv = filled(y)\n- ym = getmask(y)\n- if ym is nomask: ym = 0\n+ xv = filled(x)\n+ xm = getmask(x)\n+ if xm is nomask: xm = numeric.False_\n+ yv = filled(y)\n+ ym = getmask(y)\n+ if ym is nomask: ym = numeric.False_\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n", + "added_lines": 6, + "deleted_lines": 14, + "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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType=bool_\nnomask = None # To be changed to 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 if m is nomask or (isinstance(m, ndarray) and \\\n m.dtype.type is MaskType):\n return 1\n else:\n return 0\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 if xm is nomask: xm = numeric.False_\n yv = filled(y)\n ym = getmask(y)\n if ym is nomask: ym = numeric.False_\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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType=bool_\nnomask = None # To be changed to 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 if m is nomask or (isinstance(m, ndarray) and \\\n m.dtype.type is MaskType):\n return 1\n else:\n return 0\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 if x is masked:\n xv = 0\n xm = 1\n else:\n xv = filled(x)\n xm = getmask(x)\n if xm is nomask: xm = 0\n if y is masked:\n yv = 0\n ym = 1\n else:\n yv = filled(y)\n ym = getmask(y)\n if ym is nomask: ym = 0\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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 6, + "complexity": 4, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 305, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "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 , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 328, + "end_line": 329, + "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": 330, + "end_line": 331, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 337, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 349, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 372, + "end_line": 373, + "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": 376, + "end_line": 385, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 387, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 403, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 425, + "end_line": 436, + "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": 438, + "end_line": 441, + "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": 442, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 505, + "end_line": 506, + "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": 508, + "end_line": 509, + "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": 511, + "end_line": 512, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 543, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 626, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 650, + "end_line": 652, + "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": 654, + "end_line": 659, + "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": 661, + "end_line": 670, + "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": 672, + "end_line": 675, + "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": 677, + "end_line": 684, + "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": 686, + "end_line": 689, + "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": 691, + "end_line": 698, + "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": 700, + "end_line": 703, + "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": 705, + "end_line": 725, + "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": 727, + "end_line": 772, + "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": 774, + "end_line": 779, + "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": 781, + "end_line": 786, + "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": 788, + "end_line": 802, + "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": 804, + "end_line": 812, + "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": 819, + "end_line": 845, + "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": 847, + "end_line": 869, + "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": 871, + "end_line": 881, + "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": 883, + "end_line": 886, + "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": 888, + "end_line": 890, + "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": 892, + "end_line": 894, + "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": 896, + "end_line": 898, + "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": 904, + "end_line": 906, + "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": 908, + "end_line": 910, + "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": 912, + "end_line": 914, + "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": 916, + "end_line": 918, + "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": 922, + "end_line": 924, + "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": 926, + "end_line": 928, + "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": 930, + "end_line": 931, + "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": 933, + "end_line": 934, + "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": 936, + "end_line": 938, + "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": 940, + "end_line": 942, + "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": 944, + "end_line": 946, + "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": 950, + "end_line": 952, + "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": 954, + "end_line": 956, + "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": 958, + "end_line": 960, + "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": 962, + "end_line": 964, + "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": 966, + "end_line": 968, + "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": 970, + "end_line": 972, + "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": 974, + "end_line": 976, + "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": 978, + "end_line": 980, + "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": 982, + "end_line": 1023, + "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": 1025, + "end_line": 1066, + "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": 1068, + "end_line": 1109, + "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": 1113, + "end_line": 1150, + "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": 1152, + "end_line": 1153, + "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": 1155, + "end_line": 1156, + "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": 1158, + "end_line": 1159, + "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": 1161, + "end_line": 1162, + "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": 1164, + "end_line": 1165, + "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": 1167, + "end_line": 1168, + "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": 1170, + "end_line": 1173, + "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": 1175, + "end_line": 1179, + "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": 1181, + "end_line": 1189, + "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": 1191, + "end_line": 1219, + "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": 1221, + "end_line": 1223, + "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": 1225, + "end_line": 1227, + "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": 1229, + "end_line": 1269, + "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": 1271, + "end_line": 1273, + "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": 1275, + "end_line": 1277, + "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": 1279, + "end_line": 1281, + "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": 1284, + "end_line": 1286, + "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": 1288, + "end_line": 1298, + "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": 1300, + "end_line": 1308, + "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": 1310, + "end_line": 1315, + "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": 1317, + "end_line": 1321, + "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": 1325, + "end_line": 1329, + "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": 1333, + "end_line": 1340, + "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": 1342, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1348, + "end_line": 1349, + "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": 1353, + "end_line": 1354, + "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": 1357, + "end_line": 1366, + "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": 1368, + "end_line": 1370, + "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": 1372, + "end_line": 1374, + "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": 1376, + "end_line": 1382, + "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": 1384, + "end_line": 1388, + "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": 1408, + "end_line": 1410, + "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": 1415, + "end_line": 1430, + "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": 1432, + "end_line": 1450, + "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": 1452, + "end_line": 1471, + "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": 1473, + "end_line": 1477, + "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": 1479, + "end_line": 1483, + "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": 1487, + "end_line": 1489, + "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": 1491, + "end_line": 1499, + "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": 1501, + "end_line": 1509, + "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": 1511, + "end_line": 1519, + "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": 1521, + "end_line": 1536, + "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": 1538, + "end_line": 1541, + "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": 1543, + "end_line": 1547, + "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": 1549, + "end_line": 1552, + "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": 1554, + "end_line": 1557, + "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": 1560, + "end_line": 1563, + "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": 1565, + "end_line": 1582, + "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": 1584, + "end_line": 1588, + "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": 1593, + "end_line": 1700, + "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": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 1724, + "end_line": 1726, + "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": 1727, + "end_line": 1731, + "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": 1722, + "end_line": 1738, + "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": 1740, + "end_line": 1746, + "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": 1748, + "end_line": 1750, + "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": 1752, + "end_line": 1754, + "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": 1756, + "end_line": 1758, + "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": 1760, + "end_line": 1762, + "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": 1764, + "end_line": 1769, + "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": 1771, + "end_line": 1778, + "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": 1780, + "end_line": 1791, + "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": 1793, + "end_line": 1804, + "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": 1806, + "end_line": 1813, + "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": 1815, + "end_line": 1822, + "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": 1824, + "end_line": 1838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1840, + "end_line": 1848, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1850, + "end_line": 1858, + "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": 1861, + "end_line": 1874, + "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": 1876, + "end_line": 1884, + "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": 1886, + "end_line": 1896, + "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": 1898, + "end_line": 1910, + "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": 1912, + "end_line": 1917, + "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": 1919, + "end_line": 1928, + "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": 1932, + "end_line": 1936, + "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": 1938, + "end_line": 1951, + "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": 1953, + "end_line": 1962, + "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": 1964, + "end_line": 1975, + "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": 1981, + "end_line": 1985, + "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": 1987, + "end_line": 2000, + "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": 2002, + "end_line": 2011, + "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": 2013, + "end_line": 2024, + "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": 2028, + "end_line": 2045, + "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": 2047, + "end_line": 2054, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2056, + "end_line": 2063, + "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": 2065, + "end_line": 2073, + "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": 2075, + "end_line": 2089, + "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": 2091, + "end_line": 2093, + "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": 2095, + "end_line": 2101, + "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": 2107, + "end_line": 2108, + "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": 2109, + "end_line": 2110, + "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": 2119, + "end_line": 2120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2126, + "end_line": 2127, + "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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 6, + "complexity": 4, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 305, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "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 , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 328, + "end_line": 329, + "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": 330, + "end_line": 331, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 337, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 349, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 372, + "end_line": 373, + "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": 376, + "end_line": 385, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 387, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 403, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 425, + "end_line": 436, + "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": 438, + "end_line": 441, + "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": 442, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 505, + "end_line": 506, + "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": 508, + "end_line": 509, + "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": 511, + "end_line": 512, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 543, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 626, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 650, + "end_line": 652, + "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": 654, + "end_line": 659, + "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": 661, + "end_line": 670, + "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": 672, + "end_line": 675, + "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": 677, + "end_line": 684, + "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": 686, + "end_line": 689, + "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": 691, + "end_line": 698, + "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": 700, + "end_line": 703, + "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": 705, + "end_line": 725, + "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": 727, + "end_line": 772, + "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": 774, + "end_line": 779, + "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": 781, + "end_line": 786, + "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": 788, + "end_line": 802, + "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": 804, + "end_line": 812, + "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": 819, + "end_line": 845, + "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": 847, + "end_line": 869, + "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": 871, + "end_line": 881, + "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": 883, + "end_line": 886, + "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": 888, + "end_line": 890, + "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": 892, + "end_line": 894, + "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": 896, + "end_line": 898, + "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": 904, + "end_line": 906, + "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": 908, + "end_line": 910, + "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": 912, + "end_line": 914, + "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": 916, + "end_line": 918, + "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": 922, + "end_line": 924, + "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": 926, + "end_line": 928, + "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": 930, + "end_line": 931, + "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": 933, + "end_line": 934, + "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": 936, + "end_line": 938, + "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": 940, + "end_line": 942, + "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": 944, + "end_line": 946, + "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": 950, + "end_line": 952, + "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": 954, + "end_line": 956, + "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": 958, + "end_line": 960, + "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": 962, + "end_line": 964, + "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": 966, + "end_line": 968, + "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": 970, + "end_line": 972, + "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": 974, + "end_line": 976, + "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": 978, + "end_line": 980, + "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": 982, + "end_line": 1023, + "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": 1025, + "end_line": 1066, + "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": 1068, + "end_line": 1109, + "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": 1113, + "end_line": 1150, + "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": 1152, + "end_line": 1153, + "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": 1155, + "end_line": 1156, + "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": 1158, + "end_line": 1159, + "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": 1161, + "end_line": 1162, + "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": 1164, + "end_line": 1165, + "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": 1167, + "end_line": 1168, + "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": 1170, + "end_line": 1173, + "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": 1175, + "end_line": 1179, + "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": 1181, + "end_line": 1189, + "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": 1191, + "end_line": 1219, + "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": 1221, + "end_line": 1223, + "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": 1225, + "end_line": 1227, + "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": 1229, + "end_line": 1269, + "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": 1271, + "end_line": 1273, + "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": 1275, + "end_line": 1277, + "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": 1279, + "end_line": 1281, + "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": 1284, + "end_line": 1286, + "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": 1288, + "end_line": 1298, + "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": 1300, + "end_line": 1308, + "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": 1310, + "end_line": 1315, + "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": 1317, + "end_line": 1321, + "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": 1325, + "end_line": 1329, + "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": 1333, + "end_line": 1340, + "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": 1342, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1348, + "end_line": 1349, + "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": 1353, + "end_line": 1354, + "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": 1357, + "end_line": 1366, + "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": 1368, + "end_line": 1370, + "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": 1372, + "end_line": 1374, + "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": 1376, + "end_line": 1382, + "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": 1384, + "end_line": 1388, + "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": 1408, + "end_line": 1410, + "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": 1415, + "end_line": 1430, + "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": 1432, + "end_line": 1450, + "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": 1452, + "end_line": 1471, + "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": 1473, + "end_line": 1477, + "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": 1479, + "end_line": 1483, + "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": 1487, + "end_line": 1489, + "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": 1491, + "end_line": 1499, + "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": 1501, + "end_line": 1509, + "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": 1511, + "end_line": 1519, + "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": 1521, + "end_line": 1536, + "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": 1538, + "end_line": 1541, + "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": 1543, + "end_line": 1547, + "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": 1549, + "end_line": 1552, + "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": 1554, + "end_line": 1557, + "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": 1560, + "end_line": 1563, + "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": 1565, + "end_line": 1582, + "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": 1584, + "end_line": 1588, + "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": 1593, + "end_line": 1700, + "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": 21, + "complexity": 5, + "token_count": 149, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1728, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "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": 1732, + "end_line": 1734, + "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": 1735, + "end_line": 1739, + "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": 1730, + "end_line": 1746, + "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": 1748, + "end_line": 1754, + "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": 1756, + "end_line": 1758, + "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": 1760, + "end_line": 1762, + "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": 1764, + "end_line": 1766, + "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": 1768, + "end_line": 1770, + "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": 1772, + "end_line": 1777, + "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": 1779, + "end_line": 1786, + "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": 1788, + "end_line": 1799, + "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": 1801, + "end_line": 1812, + "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": 1814, + "end_line": 1821, + "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": 1823, + "end_line": 1830, + "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": 1832, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1848, + "end_line": 1856, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1858, + "end_line": 1866, + "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": 1869, + "end_line": 1882, + "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": 1884, + "end_line": 1892, + "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": 1894, + "end_line": 1904, + "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": 1906, + "end_line": 1918, + "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": 1920, + "end_line": 1925, + "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": 1927, + "end_line": 1936, + "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": 1940, + "end_line": 1944, + "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": 1946, + "end_line": 1959, + "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": 1961, + "end_line": 1970, + "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": 1972, + "end_line": 1983, + "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": 1989, + "end_line": 1993, + "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": 1995, + "end_line": 2008, + "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": 2010, + "end_line": 2019, + "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": 2021, + "end_line": 2032, + "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": 2036, + "end_line": 2053, + "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": 2055, + "end_line": 2062, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2064, + "end_line": 2071, + "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": 2073, + "end_line": 2081, + "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": 2083, + "end_line": 2097, + "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": 2099, + "end_line": 2101, + "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": 2103, + "end_line": 2109, + "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": 2115, + "end_line": 2116, + "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": 2117, + "end_line": 2118, + "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": 2127, + "end_line": 2128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2134, + "end_line": 2135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "nloc": 1692, + "complexity": 463, + "token_count": 11862, + "diff_parsed": { + "added": [ + " xv = filled(x)", + " xm = getmask(x)", + " if xm is nomask: xm = numeric.False_", + " yv = filled(y)", + " ym = getmask(y)", + " if ym is nomask: ym = numeric.False_" + ], + "deleted": [ + " if x is masked:", + " xv = 0", + " xm = 1", + " else:", + " xv = filled(x)", + " xm = getmask(x)", + " if xm is nomask: xm = 0", + " if y is masked:", + " yv = 0", + " ym = 1", + " else:", + " yv = filled(y)", + " ym = getmask(y)", + " if ym is nomask: ym = 0" + ] + } + }, + { + "old_path": "numpy/core/tests/test_umath.py", + "new_path": "numpy/core/tests/test_umath.py", + "filename": "test_umath.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -3,7 +3,7 @@\n set_package_path()\n from numpy.core.umath import minimum, maximum, exp\n import numpy.core.umath as ncu\n-from numpy import zeros, ndarray\n+from numpy import zeros, ndarray, array, choose\n restore_path()\n \n class test_log1p(ScipyTestCase):\n@@ -131,6 +131,11 @@ def __array__(self):\n assert_equal(maximum(a, B()), 0)\n assert_equal(maximum(a, C()), 0)\n \n+class test_choose(ScipyTestCase):\n+ def test_mixed(self):\n+ c = array([True,True])\n+ a = array([True,True])\n+ assert_equal(choose(c, (a, 1)), array([1,1]))\n \n if __name__ == \"__main__\":\n ScipyTest().run()\n", + "added_lines": 6, + "deleted_lines": 1, + "source_code": "\nfrom numpy.testing import *\nset_package_path()\nfrom numpy.core.umath import minimum, maximum, exp\nimport numpy.core.umath as ncu\nfrom numpy import zeros, ndarray, array, choose\nrestore_path()\n\nclass test_log1p(ScipyTestCase):\n def check_log1p(self):\n assert_almost_equal(ncu.log1p(0.2), ncu.log(1.2))\n assert_almost_equal(ncu.log1p(1e-6), ncu.log(1+1e-6))\n\nclass test_expm1(ScipyTestCase):\n def check_expm1(self):\n assert_almost_equal(ncu.expm1(0.2), ncu.exp(0.2)-1)\n assert_almost_equal(ncu.expm1(1e-6), ncu.exp(1e-6)-1)\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(maximum.reduce([1,2j]),1)\n assert_equal(maximum.reduce([1+3j,2j]),1+3j)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(minimum.reduce([1,2j]),2j)\n\nclass test_floating_point(ScipyTestCase):\n def check_floating_point(self):\n assert_equal(ncu.FLOATING_POINT_SUPPORT, 1)\n\nclass test_special_methods(ScipyTestCase):\n def test_wrap(self):\n class with_wrap(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n r = with_wrap()\n r.arr = arr\n r.context = context\n return r \n a = with_wrap()\n x = minimum(a, a)\n assert_equal(x.arr, zeros(1))\n func, args, i = x.context\n self.failUnless(func is minimum)\n self.failUnlessEqual(len(args), 2)\n assert_equal(args[0], a)\n assert_equal(args[1], a)\n self.failUnlessEqual(i, 0)\n\n def test_old_wrap(self):\n class with_wrap(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr):\n r = with_wrap()\n r.arr = arr\n return r \n a = with_wrap()\n x = minimum(a, a)\n assert_equal(x.arr, zeros(1))\n\n def test_priority(self):\n class A(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n r = type(self)()\n r.arr = arr\n r.context = context\n return r\n class B(A):\n __array_priority__ = 20.\n class C(A):\n __array_priority__ = 40.\n x = zeros(1)\n a = A()\n b = B()\n c = C()\n f = minimum\n self.failUnless(type(f(x,x)) is ndarray)\n self.failUnless(type(f(x,a)) is A)\n self.failUnless(type(f(x,b)) is B)\n self.failUnless(type(f(x,c)) is C)\n self.failUnless(type(f(a,x)) is A)\n self.failUnless(type(f(b,x)) is B)\n self.failUnless(type(f(c,x)) is C)\n\n self.failUnless(type(f(a,a)) is A)\n self.failUnless(type(f(a,b)) is B)\n self.failUnless(type(f(b,a)) is B)\n self.failUnless(type(f(b,b)) is B)\n self.failUnless(type(f(b,c)) is C)\n self.failUnless(type(f(c,b)) is C)\n self.failUnless(type(f(c,c)) is C)\n\n self.failUnless(type(exp(a) is A))\n self.failUnless(type(exp(b) is B))\n self.failUnless(type(exp(c) is C))\n\n def test_failing_wrap(self):\n class A(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n raise RuntimeError\n a = A()\n self.failUnlessRaises(RuntimeError, maximum, a, a)\n\n def test_array_with_context(self):\n class A(object):\n def __array__(self, dtype=None, context=None):\n func, args, i = context\n self.func = func\n self.args = args\n self.i = i\n return zeros(1)\n class B(object):\n def __array__(self, dtype=None):\n return zeros(1, dtype)\n class C(object):\n def __array__(self):\n return zeros(1)\n a = A()\n maximum(zeros(1), a)\n self.failUnless(a.func is maximum)\n assert_equal(a.args[0], 0)\n self.failUnless(a.args[1] is a)\n self.failUnless(a.i == 1)\n assert_equal(maximum(a, B()), 0)\n assert_equal(maximum(a, C()), 0)\n\nclass test_choose(ScipyTestCase):\n def test_mixed(self):\n c = array([True,True])\n a = array([True,True])\n assert_equal(choose(c, (a, 1)), array([1,1]))\n \nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\nfrom numpy.testing import *\nset_package_path()\nfrom numpy.core.umath import minimum, maximum, exp\nimport numpy.core.umath as ncu\nfrom numpy import zeros, ndarray\nrestore_path()\n\nclass test_log1p(ScipyTestCase):\n def check_log1p(self):\n assert_almost_equal(ncu.log1p(0.2), ncu.log(1.2))\n assert_almost_equal(ncu.log1p(1e-6), ncu.log(1+1e-6))\n\nclass test_expm1(ScipyTestCase):\n def check_expm1(self):\n assert_almost_equal(ncu.expm1(0.2), ncu.exp(0.2)-1)\n assert_almost_equal(ncu.expm1(1e-6), ncu.exp(1e-6)-1)\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(maximum.reduce([1,2j]),1)\n assert_equal(maximum.reduce([1+3j,2j]),1+3j)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(minimum.reduce([1,2j]),2j)\n\nclass test_floating_point(ScipyTestCase):\n def check_floating_point(self):\n assert_equal(ncu.FLOATING_POINT_SUPPORT, 1)\n\nclass test_special_methods(ScipyTestCase):\n def test_wrap(self):\n class with_wrap(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n r = with_wrap()\n r.arr = arr\n r.context = context\n return r \n a = with_wrap()\n x = minimum(a, a)\n assert_equal(x.arr, zeros(1))\n func, args, i = x.context\n self.failUnless(func is minimum)\n self.failUnlessEqual(len(args), 2)\n assert_equal(args[0], a)\n assert_equal(args[1], a)\n self.failUnlessEqual(i, 0)\n\n def test_old_wrap(self):\n class with_wrap(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr):\n r = with_wrap()\n r.arr = arr\n return r \n a = with_wrap()\n x = minimum(a, a)\n assert_equal(x.arr, zeros(1))\n\n def test_priority(self):\n class A(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n r = type(self)()\n r.arr = arr\n r.context = context\n return r\n class B(A):\n __array_priority__ = 20.\n class C(A):\n __array_priority__ = 40.\n x = zeros(1)\n a = A()\n b = B()\n c = C()\n f = minimum\n self.failUnless(type(f(x,x)) is ndarray)\n self.failUnless(type(f(x,a)) is A)\n self.failUnless(type(f(x,b)) is B)\n self.failUnless(type(f(x,c)) is C)\n self.failUnless(type(f(a,x)) is A)\n self.failUnless(type(f(b,x)) is B)\n self.failUnless(type(f(c,x)) is C)\n\n self.failUnless(type(f(a,a)) is A)\n self.failUnless(type(f(a,b)) is B)\n self.failUnless(type(f(b,a)) is B)\n self.failUnless(type(f(b,b)) is B)\n self.failUnless(type(f(b,c)) is C)\n self.failUnless(type(f(c,b)) is C)\n self.failUnless(type(f(c,c)) is C)\n\n self.failUnless(type(exp(a) is A))\n self.failUnless(type(exp(b) is B))\n self.failUnless(type(exp(c) is C))\n\n def test_failing_wrap(self):\n class A(object):\n def __array__(self):\n return zeros(1)\n def __array_wrap__(self, arr, context):\n raise RuntimeError\n a = A()\n self.failUnlessRaises(RuntimeError, maximum, a, a)\n\n def test_array_with_context(self):\n class A(object):\n def __array__(self, dtype=None, context=None):\n func, args, i = context\n self.func = func\n self.args = args\n self.i = i\n return zeros(1)\n class B(object):\n def __array__(self, dtype=None):\n return zeros(1, dtype)\n class C(object):\n def __array__(self):\n return zeros(1)\n a = A()\n maximum(zeros(1), a)\n self.failUnless(a.func is maximum)\n assert_equal(a.args[0], 0)\n self.failUnless(a.args[1] is a)\n self.failUnless(a.i == 1)\n assert_equal(maximum(a, B()), 0)\n assert_equal(maximum(a, C()), 0)\n\n \nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_log1p", + "long_name": "check_log1p( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 10, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_expm1", + "long_name": "check_expm1( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 25, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_floating_point", + "long_name": "check_floating_point( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "test_wrap.__array__", + "long_name": "test_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_wrap.__array_wrap__", + "long_name": "test_wrap.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 37, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "test_wrap", + "long_name": "test_wrap( self )", + "filename": "test_umath.py", + "nloc": 13, + "complexity": 1, + "token_count": 93, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "test_old_wrap.__array__", + "long_name": "test_old_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_old_wrap.__array_wrap__", + "long_name": "test_old_wrap.__array_wrap__( self , arr )", + "filename": "test_umath.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "arr" + ], + "start_line": 56, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 3 + }, + { + "name": "test_old_wrap", + "long_name": "test_old_wrap( self )", + "filename": "test_umath.py", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 52, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "test_priority.__array__", + "long_name": "test_priority.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 66, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_priority.__array_wrap__", + "long_name": "test_priority.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "test_priority", + "long_name": "test_priority( self )", + "filename": "test_umath.py", + "nloc": 30, + "complexity": 1, + "token_count": 325, + "parameters": [ + "self" + ], + "start_line": 64, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 1 + }, + { + "name": "test_failing_wrap.__array__", + "long_name": "test_failing_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_failing_wrap.__array_wrap__", + "long_name": "test_failing_wrap.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_failing_wrap", + "long_name": "test_failing_wrap( self )", + "filename": "test_umath.py", + "nloc": 6, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self , dtype = None , context = None )", + "filename": "test_umath.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "dtype", + "context" + ], + "start_line": 113, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self , dtype = None )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "dtype" + ], + "start_line": 120, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 123, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context", + "long_name": "test_array_with_context( self )", + "filename": "test_umath.py", + "nloc": 15, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "test_mixed", + "long_name": "test_mixed( self )", + "filename": "test_umath.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 135, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_log1p", + "long_name": "check_log1p( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 10, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_expm1", + "long_name": "check_expm1( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 25, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_floating_point", + "long_name": "check_floating_point( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "test_wrap.__array__", + "long_name": "test_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_wrap.__array_wrap__", + "long_name": "test_wrap.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 37, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "test_wrap", + "long_name": "test_wrap( self )", + "filename": "test_umath.py", + "nloc": 13, + "complexity": 1, + "token_count": 93, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "test_old_wrap.__array__", + "long_name": "test_old_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_old_wrap.__array_wrap__", + "long_name": "test_old_wrap.__array_wrap__( self , arr )", + "filename": "test_umath.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "arr" + ], + "start_line": 56, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 3 + }, + { + "name": "test_old_wrap", + "long_name": "test_old_wrap( self )", + "filename": "test_umath.py", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 52, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "test_priority.__array__", + "long_name": "test_priority.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 66, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_priority.__array_wrap__", + "long_name": "test_priority.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 3 + }, + { + "name": "test_priority", + "long_name": "test_priority( self )", + "filename": "test_umath.py", + "nloc": 30, + "complexity": 1, + "token_count": 325, + "parameters": [ + "self" + ], + "start_line": 64, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 1 + }, + { + "name": "test_failing_wrap.__array__", + "long_name": "test_failing_wrap.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_failing_wrap.__array_wrap__", + "long_name": "test_failing_wrap.__array_wrap__( self , arr , context )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self", + "arr", + "context" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_failing_wrap", + "long_name": "test_failing_wrap( self )", + "filename": "test_umath.py", + "nloc": 6, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self , dtype = None , context = None )", + "filename": "test_umath.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "dtype", + "context" + ], + "start_line": 113, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self , dtype = None )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "dtype" + ], + "start_line": 120, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context.__array__", + "long_name": "test_array_with_context.__array__( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 123, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "test_array_with_context", + "long_name": "test_array_with_context( self )", + "filename": "test_umath.py", + "nloc": 15, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "test_mixed", + "long_name": "test_mixed( self )", + "filename": "test_umath.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 135, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "nloc": 126, + "complexity": 22, + "token_count": 1104, + "diff_parsed": { + "added": [ + "from numpy import zeros, ndarray, array, choose", + "class test_choose(ScipyTestCase):", + " def test_mixed(self):", + " c = array([True,True])", + " a = array([True,True])", + " assert_equal(choose(c, (a, 1)), array([1,1]))" + ], + "deleted": [ + "from numpy import zeros, ndarray" + ] + } + } + ] + }, + { + "hash": "c8ca3be233f0cc830be025f80b18eefcaaf62ccd", + "msg": "Fix inappropriate DECREF.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T00:57:59+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T00:57:59+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "01597c2bbe93f5d444355fd6efe5322da53bc770" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 7, + "insertions": 7, + "lines": 14, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/include/numpy/arrayobject.h", + "new_path": "numpy/core/include/numpy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -1342,8 +1342,8 @@ typedef struct {\n \t PyUnicode_Check(obj))\n #define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n \t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n-#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n-\t\t\t\t PyArray_IsPythonScalar(obj))\n+#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n+\t\t\t\t PyArray_CheckScalar(obj))\n \t\n #define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x000904\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) { \\\n it->dataptr += it->strides[0]; \\\n it->coordinates[0]++; \\\n } \\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x000904\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) { \\\n it->dataptr += it->strides[0]; \\\n it->coordinates[0]++; \\\n } \\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n\t\t\t\t PyArray_IsPythonScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 281, + "complexity": 0, + "token_count": 1305, + "diff_parsed": { + "added": [ + "#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\", + "\t\t\t\t PyArray_CheckScalar(obj))" + ], + "deleted": [ + "#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\", + "\t\t\t\t PyArray_IsPythonScalar(obj))" + ] + } + }, + { + "old_path": "numpy/core/src/multiarraymodule.c", + "new_path": "numpy/core/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -1467,14 +1467,14 @@ PyArray_ConvertToCommonType(PyObject *op, int *retn)\n \t\t\tflags |= FORCECAST;\n \t\t\tPy_DECREF(Py_None);\n \t\t}\n+\t\tPy_INCREF(intype);\n \t\tmps[i] = (PyArrayObject*)\n- PyArray_CheckFromAny(otmp, intype, 0, 0, flags, NULL);\n+ PyArray_FromAny(otmp, intype, 0, 0, flags, NULL);\n \t\tPy_DECREF(otmp);\n-\t\tPy_XDECREF(stype);\n-\t\tstype=NULL;\n-\t\tintype=NULL;\n if (mps[i] == NULL) goto fail;\n-\t}\t\n+\t}\n+\tPy_DECREF(intype);\n+\tPy_XDECREF(stype);\n \treturn mps;\n \n fail:\n", + "added_lines": 5, + "deleted_lines": 5, + "source_code": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\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\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\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 dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) 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.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", 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)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\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\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\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\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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_DescrConverter, \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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "source_code_before": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\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\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\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 dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) 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.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", 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)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\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\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\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\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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_DescrConverter, \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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4389, + "end_line": 4405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4419, + "end_line": 4544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "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": 4562, + "end_line": 4600, + "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": 4604, + "end_line": 4697, + "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": 4713, + "end_line": 4730, + "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": 4736, + "end_line": 4747, + "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": 4754, + "end_line": 4760, + "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": 4767, + "end_line": 4773, + "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": 4777, + "end_line": 4783, + "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": 4787, + "end_line": 4796, + "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": 4803, + "end_line": 4854, + "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": 4860, + "end_line": 4892, + "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": 4899, + "end_line": 4983, + "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": 4989, + "end_line": 5001, + "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": 12, + "parameters": [], + "start_line": 5007, + "end_line": 5010, + "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": 5016, + "end_line": 5022, + "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": 5028, + "end_line": 5044, + "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": 5050, + "end_line": 5067, + "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": 5074, + "end_line": 5114, + "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": 5122, + "end_line": 5130, + "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": 5142, + "end_line": 5152, + "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": 5161, + "end_line": 5172, + "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": 5179, + "end_line": 5202, + "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": 5209, + "end_line": 5217, + "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": 5226, + "end_line": 5244, + "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": 5310, + "end_line": 5423, + "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": 5428, + "end_line": 5452, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5457, + "end_line": 5550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 437, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4389, + "end_line": 4405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4419, + "end_line": 4544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "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": 4562, + "end_line": 4600, + "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": 4604, + "end_line": 4697, + "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": 4713, + "end_line": 4730, + "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": 4736, + "end_line": 4747, + "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": 4754, + "end_line": 4760, + "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": 4767, + "end_line": 4773, + "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": 4777, + "end_line": 4783, + "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": 4787, + "end_line": 4796, + "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": 4803, + "end_line": 4854, + "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": 4860, + "end_line": 4892, + "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": 4899, + "end_line": 4983, + "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": 4989, + "end_line": 5001, + "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": 12, + "parameters": [], + "start_line": 5007, + "end_line": 5010, + "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": 5016, + "end_line": 5022, + "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": 5028, + "end_line": 5044, + "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": 5050, + "end_line": 5067, + "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": 5074, + "end_line": 5114, + "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": 5122, + "end_line": 5130, + "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": 5142, + "end_line": 5152, + "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": 5161, + "end_line": 5172, + "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": 5179, + "end_line": 5202, + "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": 5209, + "end_line": 5217, + "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": 5226, + "end_line": 5244, + "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": 5310, + "end_line": 5423, + "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": 5428, + "end_line": 5452, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5457, + "end_line": 5550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + } + ], + "nloc": 4171, + "complexity": 914, + "token_count": 27241, + "diff_parsed": { + "added": [ + "\t\tPy_INCREF(intype);", + " PyArray_FromAny(otmp, intype, 0, 0, flags, NULL);", + "\t}", + "\tPy_DECREF(intype);", + "\tPy_XDECREF(stype);" + ], + "deleted": [ + " PyArray_CheckFromAny(otmp, intype, 0, 0, flags, NULL);", + "\t\tPy_XDECREF(stype);", + "\t\tstype=NULL;", + "\t\tintype=NULL;", + "\t}" + ] + } + } + ] + }, + { + "hash": "b22888655e8136aa3f60932f83d211602206f034", + "msg": "changed nomask from None to False_", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-01-20T02:59:30+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T02:59:30+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "c8ca3be233f0cc830be025f80b18eefcaaf62ccd" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/ma.py", + "new_path": "numpy/core/ma.py", + "filename": "ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -22,7 +22,7 @@\n ufunc_fills = {}\n \n MaskType=bool_\n-nomask = None # To be changed to MaskType(0)\n+nomask = MaskType(0)\n divide_tolerance = 1.e-35\n \n class MAError (Exception):\n", + "added_lines": 1, + "deleted_lines": 1, + "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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\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 if m is nomask or (isinstance(m, ndarray) and \\\n m.dtype.type is MaskType):\n return 1\n else:\n return 0\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 if xm is nomask: xm = numeric.False_\n yv = filled(y)\n ym = getmask(y)\n if ym is nomask: ym = numeric.False_\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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\n\n# Ufunc domain lookup for __array_wrap__\nufunc_domain = {}\n# Ufunc fills lookup for __array__\nufunc_fills = {}\n\nMaskType=bool_\nnomask = None # To be changed to 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 if m is nomask or (isinstance(m, ndarray) and \\\n m.dtype.type is MaskType):\n return 1\n else:\n return 0\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 if xm is nomask: xm = numeric.False_\n yv = filled(y)\n ym = getmask(y)\n if ym is nomask: ym = numeric.False_\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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 6, + "complexity": 4, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 305, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "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 , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 328, + "end_line": 329, + "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": 330, + "end_line": 331, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 337, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 349, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 372, + "end_line": 373, + "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": 376, + "end_line": 385, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 387, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 403, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 425, + "end_line": 436, + "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": 438, + "end_line": 441, + "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": 442, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 505, + "end_line": 506, + "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": 508, + "end_line": 509, + "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": 511, + "end_line": 512, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 543, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 626, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 650, + "end_line": 652, + "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": 654, + "end_line": 659, + "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": 661, + "end_line": 670, + "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": 672, + "end_line": 675, + "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": 677, + "end_line": 684, + "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": 686, + "end_line": 689, + "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": 691, + "end_line": 698, + "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": 700, + "end_line": 703, + "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": 705, + "end_line": 725, + "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": 727, + "end_line": 772, + "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": 774, + "end_line": 779, + "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": 781, + "end_line": 786, + "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": 788, + "end_line": 802, + "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": 804, + "end_line": 812, + "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": 819, + "end_line": 845, + "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": 847, + "end_line": 869, + "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": 871, + "end_line": 881, + "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": 883, + "end_line": 886, + "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": 888, + "end_line": 890, + "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": 892, + "end_line": 894, + "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": 896, + "end_line": 898, + "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": 904, + "end_line": 906, + "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": 908, + "end_line": 910, + "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": 912, + "end_line": 914, + "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": 916, + "end_line": 918, + "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": 922, + "end_line": 924, + "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": 926, + "end_line": 928, + "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": 930, + "end_line": 931, + "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": 933, + "end_line": 934, + "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": 936, + "end_line": 938, + "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": 940, + "end_line": 942, + "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": 944, + "end_line": 946, + "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": 950, + "end_line": 952, + "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": 954, + "end_line": 956, + "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": 958, + "end_line": 960, + "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": 962, + "end_line": 964, + "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": 966, + "end_line": 968, + "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": 970, + "end_line": 972, + "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": 974, + "end_line": 976, + "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": 978, + "end_line": 980, + "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": 982, + "end_line": 1023, + "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": 1025, + "end_line": 1066, + "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": 1068, + "end_line": 1109, + "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": 1113, + "end_line": 1150, + "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": 1152, + "end_line": 1153, + "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": 1155, + "end_line": 1156, + "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": 1158, + "end_line": 1159, + "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": 1161, + "end_line": 1162, + "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": 1164, + "end_line": 1165, + "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": 1167, + "end_line": 1168, + "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": 1170, + "end_line": 1173, + "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": 1175, + "end_line": 1179, + "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": 1181, + "end_line": 1189, + "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": 1191, + "end_line": 1219, + "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": 1221, + "end_line": 1223, + "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": 1225, + "end_line": 1227, + "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": 1229, + "end_line": 1269, + "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": 1271, + "end_line": 1273, + "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": 1275, + "end_line": 1277, + "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": 1279, + "end_line": 1281, + "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": 1284, + "end_line": 1286, + "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": 1288, + "end_line": 1298, + "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": 1300, + "end_line": 1308, + "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": 1310, + "end_line": 1315, + "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": 1317, + "end_line": 1321, + "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": 1325, + "end_line": 1329, + "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": 1333, + "end_line": 1340, + "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": 1342, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1348, + "end_line": 1349, + "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": 1353, + "end_line": 1354, + "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": 1357, + "end_line": 1366, + "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": 1368, + "end_line": 1370, + "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": 1372, + "end_line": 1374, + "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": 1376, + "end_line": 1382, + "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": 1384, + "end_line": 1388, + "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": 1408, + "end_line": 1410, + "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": 1415, + "end_line": 1430, + "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": 1432, + "end_line": 1450, + "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": 1452, + "end_line": 1471, + "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": 1473, + "end_line": 1477, + "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": 1479, + "end_line": 1483, + "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": 1487, + "end_line": 1489, + "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": 1491, + "end_line": 1499, + "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": 1501, + "end_line": 1509, + "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": 1511, + "end_line": 1519, + "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": 1521, + "end_line": 1536, + "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": 1538, + "end_line": 1541, + "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": 1543, + "end_line": 1547, + "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": 1549, + "end_line": 1552, + "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": 1554, + "end_line": 1557, + "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": 1560, + "end_line": 1563, + "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": 1565, + "end_line": 1582, + "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": 1584, + "end_line": 1588, + "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": 1593, + "end_line": 1700, + "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": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 1724, + "end_line": 1726, + "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": 1727, + "end_line": 1731, + "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": 1722, + "end_line": 1738, + "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": 1740, + "end_line": 1746, + "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": 1748, + "end_line": 1750, + "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": 1752, + "end_line": 1754, + "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": 1756, + "end_line": 1758, + "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": 1760, + "end_line": 1762, + "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": 1764, + "end_line": 1769, + "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": 1771, + "end_line": 1778, + "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": 1780, + "end_line": 1791, + "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": 1793, + "end_line": 1804, + "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": 1806, + "end_line": 1813, + "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": 1815, + "end_line": 1822, + "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": 1824, + "end_line": 1838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1840, + "end_line": 1848, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1850, + "end_line": 1858, + "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": 1861, + "end_line": 1874, + "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": 1876, + "end_line": 1884, + "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": 1886, + "end_line": 1896, + "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": 1898, + "end_line": 1910, + "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": 1912, + "end_line": 1917, + "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": 1919, + "end_line": 1928, + "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": 1932, + "end_line": 1936, + "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": 1938, + "end_line": 1951, + "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": 1953, + "end_line": 1962, + "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": 1964, + "end_line": 1975, + "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": 1981, + "end_line": 1985, + "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": 1987, + "end_line": 2000, + "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": 2002, + "end_line": 2011, + "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": 2013, + "end_line": 2024, + "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": 2028, + "end_line": 2045, + "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": 2047, + "end_line": 2054, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2056, + "end_line": 2063, + "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": 2065, + "end_line": 2073, + "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": 2075, + "end_line": 2089, + "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": 2091, + "end_line": 2093, + "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": 2095, + "end_line": 2101, + "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": 2107, + "end_line": 2108, + "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": 2109, + "end_line": 2110, + "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": 2119, + "end_line": 2120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2126, + "end_line": 2127, + "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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 6, + "complexity": 4, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 305, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "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 , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 328, + "end_line": 329, + "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": 330, + "end_line": 331, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 337, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 349, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 372, + "end_line": 373, + "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": 376, + "end_line": 385, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 387, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 403, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 425, + "end_line": 436, + "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": 438, + "end_line": 441, + "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": 442, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 505, + "end_line": 506, + "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": 508, + "end_line": 509, + "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": 511, + "end_line": 512, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 543, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 626, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 650, + "end_line": 652, + "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": 654, + "end_line": 659, + "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": 661, + "end_line": 670, + "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": 672, + "end_line": 675, + "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": 677, + "end_line": 684, + "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": 686, + "end_line": 689, + "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": 691, + "end_line": 698, + "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": 700, + "end_line": 703, + "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": 705, + "end_line": 725, + "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": 727, + "end_line": 772, + "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": 774, + "end_line": 779, + "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": 781, + "end_line": 786, + "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": 788, + "end_line": 802, + "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": 804, + "end_line": 812, + "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": 819, + "end_line": 845, + "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": 847, + "end_line": 869, + "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": 871, + "end_line": 881, + "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": 883, + "end_line": 886, + "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": 888, + "end_line": 890, + "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": 892, + "end_line": 894, + "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": 896, + "end_line": 898, + "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": 904, + "end_line": 906, + "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": 908, + "end_line": 910, + "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": 912, + "end_line": 914, + "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": 916, + "end_line": 918, + "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": 922, + "end_line": 924, + "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": 926, + "end_line": 928, + "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": 930, + "end_line": 931, + "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": 933, + "end_line": 934, + "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": 936, + "end_line": 938, + "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": 940, + "end_line": 942, + "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": 944, + "end_line": 946, + "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": 950, + "end_line": 952, + "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": 954, + "end_line": 956, + "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": 958, + "end_line": 960, + "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": 962, + "end_line": 964, + "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": 966, + "end_line": 968, + "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": 970, + "end_line": 972, + "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": 974, + "end_line": 976, + "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": 978, + "end_line": 980, + "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": 982, + "end_line": 1023, + "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": 1025, + "end_line": 1066, + "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": 1068, + "end_line": 1109, + "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": 1113, + "end_line": 1150, + "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": 1152, + "end_line": 1153, + "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": 1155, + "end_line": 1156, + "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": 1158, + "end_line": 1159, + "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": 1161, + "end_line": 1162, + "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": 1164, + "end_line": 1165, + "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": 1167, + "end_line": 1168, + "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": 1170, + "end_line": 1173, + "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": 1175, + "end_line": 1179, + "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": 1181, + "end_line": 1189, + "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": 1191, + "end_line": 1219, + "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": 1221, + "end_line": 1223, + "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": 1225, + "end_line": 1227, + "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": 1229, + "end_line": 1269, + "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": 1271, + "end_line": 1273, + "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": 1275, + "end_line": 1277, + "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": 1279, + "end_line": 1281, + "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": 1284, + "end_line": 1286, + "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": 1288, + "end_line": 1298, + "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": 1300, + "end_line": 1308, + "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": 1310, + "end_line": 1315, + "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": 1317, + "end_line": 1321, + "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": 1325, + "end_line": 1329, + "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": 1333, + "end_line": 1340, + "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": 1342, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1348, + "end_line": 1349, + "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": 1353, + "end_line": 1354, + "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": 1357, + "end_line": 1366, + "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": 1368, + "end_line": 1370, + "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": 1372, + "end_line": 1374, + "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": 1376, + "end_line": 1382, + "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": 1384, + "end_line": 1388, + "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": 1408, + "end_line": 1410, + "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": 1415, + "end_line": 1430, + "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": 1432, + "end_line": 1450, + "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": 1452, + "end_line": 1471, + "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": 1473, + "end_line": 1477, + "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": 1479, + "end_line": 1483, + "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": 1487, + "end_line": 1489, + "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": 1491, + "end_line": 1499, + "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": 1501, + "end_line": 1509, + "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": 1511, + "end_line": 1519, + "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": 1521, + "end_line": 1536, + "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": 1538, + "end_line": 1541, + "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": 1543, + "end_line": 1547, + "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": 1549, + "end_line": 1552, + "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": 1554, + "end_line": 1557, + "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": 1560, + "end_line": 1563, + "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": 1565, + "end_line": 1582, + "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": 1584, + "end_line": 1588, + "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": 1593, + "end_line": 1700, + "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": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 1724, + "end_line": 1726, + "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": 1727, + "end_line": 1731, + "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": 1722, + "end_line": 1738, + "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": 1740, + "end_line": 1746, + "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": 1748, + "end_line": 1750, + "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": 1752, + "end_line": 1754, + "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": 1756, + "end_line": 1758, + "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": 1760, + "end_line": 1762, + "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": 1764, + "end_line": 1769, + "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": 1771, + "end_line": 1778, + "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": 1780, + "end_line": 1791, + "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": 1793, + "end_line": 1804, + "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": 1806, + "end_line": 1813, + "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": 1815, + "end_line": 1822, + "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": 1824, + "end_line": 1838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1840, + "end_line": 1848, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1850, + "end_line": 1858, + "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": 1861, + "end_line": 1874, + "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": 1876, + "end_line": 1884, + "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": 1886, + "end_line": 1896, + "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": 1898, + "end_line": 1910, + "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": 1912, + "end_line": 1917, + "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": 1919, + "end_line": 1928, + "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": 1932, + "end_line": 1936, + "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": 1938, + "end_line": 1951, + "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": 1953, + "end_line": 1962, + "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": 1964, + "end_line": 1975, + "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": 1981, + "end_line": 1985, + "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": 1987, + "end_line": 2000, + "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": 2002, + "end_line": 2011, + "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": 2013, + "end_line": 2024, + "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": 2028, + "end_line": 2045, + "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": 2047, + "end_line": 2054, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2056, + "end_line": 2063, + "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": 2065, + "end_line": 2073, + "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": 2075, + "end_line": 2089, + "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": 2091, + "end_line": 2093, + "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": 2095, + "end_line": 2101, + "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": 2107, + "end_line": 2108, + "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": 2109, + "end_line": 2110, + "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": 2119, + "end_line": 2120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2126, + "end_line": 2127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 1692, + "complexity": 463, + "token_count": 11865, + "diff_parsed": { + "added": [ + "nomask = MaskType(0)" + ], + "deleted": [ + "nomask = None # To be changed to MaskType(0)" + ] + } + } + ] + }, + { + "hash": "45475dd140ce5ce8e9f2f9cbd5573e5b288c87dd", + "msg": "take advantage of nomask=False_", + "author": { + "name": "sasha", + "email": "sasha@localhost" + }, + "committer": { + "name": "sasha", + "email": "sasha@localhost" + }, + "author_date": "2006-01-20T03:13:03+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T03:13:03+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b22888655e8136aa3f60932f83d211602206f034" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 7, + "insertions": 4, + "lines": 11, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.6666666666666666, + "modified_files": [ + { + "old_path": "numpy/core/ma.py", + "new_path": "numpy/core/ma.py", + "filename": "ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -160,11 +160,10 @@ def getmaskarray (a):\n def is_mask (m):\n \"\"\"Is m a legal mask? Does not check contents, only type.\n \"\"\"\n- if m is nomask or (isinstance(m, ndarray) and \\\n- m.dtype.type is MaskType):\n- return 1\n- else:\n- return 0\n+ try:\n+ return m.dtype.type is MaskType\n+ except AttributeError:\n+ return False\n \n def make_mask (m, copy=0, flag=0):\n \"\"\"make_mask(m, copy=0, flag=0)\n@@ -1709,10 +1708,8 @@ def where (condition, x, y):\n fc = filled(not_equal(condition,0), 0)\n xv = filled(x)\n xm = getmask(x)\n- if xm is nomask: xm = numeric.False_\n yv = filled(y)\n ym = getmask(y)\n- if ym is nomask: ym = numeric.False_\n d = numeric.choose(fc, (yv, xv))\n md = numeric.choose(fc, (ym, xm))\n m = getmask(condition)\n", + "added_lines": 4, + "deleted_lines": 7, + "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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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 string, types, sys\n\nimport umath\nimport oldnumeric\nfrom numeric import e, pi, newaxis, ndarray, inf\nfrom oldnumeric import typecodes, amax, amin\nfrom numerictypes import *\nimport numeric\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 if m is nomask or (isinstance(m, ndarray) and \\\n m.dtype.type is MaskType):\n return 1\n else:\n return 0\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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 so they\n 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 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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\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 if m is not nomask:\n try:\n shape = result.shape\n except AttributeError:\n pass\n else:\n if m.shape != shape:\n m = mask_or(getmaskarray(a), getmaskarray(b))\n return masked_array(result, m)\n\n def reduce (self, target, axis=0):\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 t = self.f.reduce(filled(t, self.filly), axis)\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)\nnonzero = masked_unary_operation(oldnumeric.nonzero)\naround = masked_unary_operation(oldnumeric.round_)\nfloor = masked_unary_operation(umath.floor)\nceil = masked_unary_operation(umath.ceil)\nsometrue = masked_unary_operation(oldnumeric.sometrue)\nalltrue = masked_unary_operation(oldnumeric.alltrue, 1)\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)\nlogical_or = masked_binary_operation(umath.logical_or)\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, fortran=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, fortran=False, \n mask=nomask, fill_value=None):\n \"\"\"array(data, dtype=None, copy=True, fortran=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, fortran=fortran)\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, fortran=fortran)\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):\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 raise MAError, \\\n \"\"\"Cannot automatically convert masked array to numeric because data\n is masked in one or more locations.\n \"\"\"\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 fills = ufunc_fills[func]\n m = reduce(mask_or, [getmask(a) for a in args])\n if domain is not None:\n m = mask_or(m, domain(*[filled(a,f) for (a,f)\n in zip(args, fills)]))\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_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 if xm is nomask: xm = numeric.False_\n yv = filled(y)\n ym = getmask(y)\n if ym is nomask: ym = numeric.False_\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 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 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 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\narray.clip = _m(not_implemented)\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)\narray.max = _m(maximum)\narray.mean = _m(average)\narray.min = _m(minimum)\narray.nbytes = property(_m(not_implemented))\narray.ndim = _m(not_implemented)\narray.newbyteorder = _m(not_implemented)\narray.nonzero = _m(nonzero)\narray.prod = _m(product)\narray.ptp = _m(not_implemented)\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)\narray.swapaxes = _m(not_implemented)\narray.take = _m(take)\narray.tofile = _m(not_implemented)\narray.trace = _m(not_implemented)\narray.transpose = _m(transpose)\narray.var = _m(not_implemented)\narray.view = _m(not_implemented)\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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 160, + "end_line": 166, + "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": 168, + "end_line": 191, + "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": 193, + "end_line": 197, + "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": 199, + "end_line": 206, + "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": 208, + "end_line": 226, + "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": 228, + "end_line": 237, + "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": 239, + "end_line": 244, + "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": 249, + "end_line": 252, + "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": 254, + "end_line": 258, + "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": 262, + "end_line": 264, + "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": 266, + "end_line": 268, + "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": 272, + "end_line": 274, + "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": 276, + "end_line": 278, + "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": 282, + "end_line": 284, + "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": 286, + "end_line": 288, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 291, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 304, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 322, + "end_line": 323, + "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": 327, + "end_line": 328, + "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": 329, + "end_line": 330, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 336, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 348, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 371, + "end_line": 372, + "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": 375, + "end_line": 384, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 386, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 402, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 424, + "end_line": 435, + "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": 437, + "end_line": 440, + "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": 441, + "end_line": 442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 504, + "end_line": 505, + "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": 507, + "end_line": 508, + "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": 510, + "end_line": 511, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 542, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 608, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 625, + "end_line": 647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 649, + "end_line": 651, + "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": 653, + "end_line": 658, + "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": 660, + "end_line": 669, + "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": 671, + "end_line": 674, + "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": 676, + "end_line": 683, + "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": 685, + "end_line": 688, + "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": 690, + "end_line": 697, + "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": 699, + "end_line": 702, + "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": 704, + "end_line": 724, + "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": 726, + "end_line": 771, + "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": 773, + "end_line": 778, + "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": 780, + "end_line": 785, + "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": 787, + "end_line": 801, + "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": 803, + "end_line": 811, + "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": 818, + "end_line": 844, + "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": 846, + "end_line": 868, + "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": 870, + "end_line": 880, + "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": 882, + "end_line": 885, + "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": 887, + "end_line": 889, + "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": 891, + "end_line": 893, + "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": 895, + "end_line": 897, + "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": 903, + "end_line": 905, + "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": 907, + "end_line": 909, + "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": 911, + "end_line": 913, + "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": 915, + "end_line": 917, + "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": 921, + "end_line": 923, + "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": 925, + "end_line": 927, + "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": 929, + "end_line": 930, + "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": 932, + "end_line": 933, + "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": 935, + "end_line": 937, + "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": 939, + "end_line": 941, + "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": 943, + "end_line": 945, + "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": 949, + "end_line": 951, + "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": 953, + "end_line": 955, + "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": 957, + "end_line": 959, + "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": 961, + "end_line": 963, + "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": 965, + "end_line": 967, + "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": 969, + "end_line": 971, + "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": 973, + "end_line": 975, + "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": 977, + "end_line": 979, + "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": 981, + "end_line": 1022, + "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": 1024, + "end_line": 1065, + "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": 1067, + "end_line": 1108, + "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": 1112, + "end_line": 1149, + "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": 1151, + "end_line": 1152, + "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": 1154, + "end_line": 1155, + "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": 1157, + "end_line": 1158, + "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": 1160, + "end_line": 1161, + "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": 1163, + "end_line": 1164, + "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": 1166, + "end_line": 1167, + "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": 1169, + "end_line": 1172, + "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": 1174, + "end_line": 1178, + "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": 1180, + "end_line": 1188, + "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": 1190, + "end_line": 1218, + "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": 1220, + "end_line": 1222, + "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": 1224, + "end_line": 1226, + "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": 1228, + "end_line": 1268, + "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": 1270, + "end_line": 1272, + "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": 1274, + "end_line": 1276, + "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": 1278, + "end_line": 1280, + "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": 1283, + "end_line": 1285, + "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": 1287, + "end_line": 1297, + "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": 1299, + "end_line": 1307, + "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": 1309, + "end_line": 1314, + "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": 1316, + "end_line": 1320, + "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": 1324, + "end_line": 1328, + "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": 1332, + "end_line": 1339, + "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": 1341, + "end_line": 1345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1347, + "end_line": 1348, + "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": 1352, + "end_line": 1353, + "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": 1356, + "end_line": 1365, + "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": 1367, + "end_line": 1369, + "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": 1371, + "end_line": 1373, + "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": 1375, + "end_line": 1381, + "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": 1383, + "end_line": 1387, + "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": 1407, + "end_line": 1409, + "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": 1414, + "end_line": 1429, + "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": 1431, + "end_line": 1449, + "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": 1451, + "end_line": 1470, + "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": 1472, + "end_line": 1476, + "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": 1478, + "end_line": 1482, + "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": 1486, + "end_line": 1488, + "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": 1490, + "end_line": 1498, + "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": 1500, + "end_line": 1508, + "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": 1510, + "end_line": 1518, + "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": 1520, + "end_line": 1535, + "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": 1537, + "end_line": 1540, + "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": 1542, + "end_line": 1546, + "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": 1548, + "end_line": 1551, + "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": 1553, + "end_line": 1556, + "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": 1559, + "end_line": 1562, + "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": 1564, + "end_line": 1581, + "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": 1583, + "end_line": 1587, + "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": 1592, + "end_line": 1699, + "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": 1701, + "end_line": 1717, + "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": 1721, + "end_line": 1723, + "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": 1724, + "end_line": 1728, + "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": 1719, + "end_line": 1735, + "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": 1737, + "end_line": 1743, + "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": 1745, + "end_line": 1747, + "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": 1749, + "end_line": 1751, + "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": 1753, + "end_line": 1755, + "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": 1757, + "end_line": 1759, + "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": 1761, + "end_line": 1766, + "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": 1768, + "end_line": 1775, + "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": 1777, + "end_line": 1788, + "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": 1790, + "end_line": 1801, + "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": 1803, + "end_line": 1810, + "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": 1812, + "end_line": 1819, + "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": 1821, + "end_line": 1835, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1837, + "end_line": 1845, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1847, + "end_line": 1855, + "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": 1858, + "end_line": 1871, + "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": 1873, + "end_line": 1881, + "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": 1883, + "end_line": 1893, + "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": 1895, + "end_line": 1907, + "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": 1909, + "end_line": 1914, + "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": 1916, + "end_line": 1925, + "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": 1929, + "end_line": 1933, + "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": 1935, + "end_line": 1948, + "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": 1950, + "end_line": 1959, + "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": 1961, + "end_line": 1972, + "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": 1978, + "end_line": 1982, + "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": 1984, + "end_line": 1997, + "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": 1999, + "end_line": 2008, + "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": 2010, + "end_line": 2021, + "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": 2025, + "end_line": 2042, + "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": 2044, + "end_line": 2051, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2053, + "end_line": 2060, + "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": 2062, + "end_line": 2070, + "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": 2072, + "end_line": 2086, + "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": 2088, + "end_line": 2090, + "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": 2092, + "end_line": 2098, + "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": 2104, + "end_line": 2105, + "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": 2106, + "end_line": 2107, + "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": 2116, + "end_line": 2117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2123, + "end_line": 2124, + "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": 29, + "end_line": 31, + "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": 32, + "end_line": 34, + "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": 39, + "end_line": 42, + "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": 44, + "end_line": 46, + "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": 48, + "end_line": 50, + "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": 52, + "end_line": 54, + "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": 56, + "end_line": 58, + "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": 60, + "end_line": 61, + "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": 75, + "end_line": 99, + "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": 101, + "end_line": 116, + "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": 118, + "end_line": 133, + "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": 135, + "end_line": 138, + "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": 140, + "end_line": 147, + "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": 149, + "end_line": 158, + "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": 6, + "complexity": 4, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "aufunc", + "fill", + "domain" + ], + "start_line": 292, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , * args , ** kwargs )", + "filename": "ma.py", + "nloc": 16, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "a", + "args", + "kwargs" + ], + "start_line": 305, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "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 , tolerance = divide_tolerance )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "tolerance" + ], + "start_line": 328, + "end_line": 329, + "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": 330, + "end_line": 331, + "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": 8, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self", + "abfunc", + "domain", + "fillx", + "filly" + ], + "start_line": 337, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , a , b )", + "filename": "ma.py", + "nloc": 21, + "complexity": 5, + "token_count": 147, + "parameters": [ + "self", + "a", + "b" + ], + "start_line": 349, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 372, + "end_line": 373, + "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": 376, + "end_line": 385, + "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": 15, + "complexity": 4, + "token_count": 113, + "parameters": [ + "self", + "a", + "b", + "args", + "kwargs" + ], + "start_line": 387, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "reduce", + "long_name": "reduce( self , target , axis = 0 )", + "filename": "ma.py", + "nloc": 20, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "target", + "axis" + ], + "start_line": 403, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 425, + "end_line": 436, + "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": 438, + "end_line": 441, + "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": 442, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rank", + "long_name": "rank( object )", + "filename": "ma.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "object" + ], + "start_line": 505, + "end_line": 506, + "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": 508, + "end_line": 509, + "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": 511, + "end_line": 512, + "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 , fortran = False , mask = nomask , fill_value = None )", + "filename": "ma.py", + "nloc": 58, + "complexity": 19, + "token_count": 393, + "parameters": [ + "self", + "data", + "dtype", + "copy", + "fortran", + "mask", + "fill_value" + ], + "start_line": 543, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "ma.py", + "nloc": 15, + "complexity": 4, + "token_count": 67, + "parameters": [ + "self", + "t" + ], + "start_line": 609, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__array_wrap__", + "long_name": "__array_wrap__( self , array , context )", + "filename": "ma.py", + "nloc": 17, + "complexity": 8, + "token_count": 142, + "parameters": [ + "self", + "array", + "context" + ], + "start_line": 626, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 650, + "end_line": 652, + "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": 654, + "end_line": 659, + "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": 661, + "end_line": 670, + "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": 672, + "end_line": 675, + "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": 677, + "end_line": 684, + "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": 686, + "end_line": 689, + "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": 691, + "end_line": 698, + "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": 700, + "end_line": 703, + "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": 705, + "end_line": 725, + "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": 727, + "end_line": 772, + "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": 774, + "end_line": 779, + "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": 781, + "end_line": 786, + "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": 788, + "end_line": 802, + "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": 804, + "end_line": 812, + "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": 819, + "end_line": 845, + "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": 847, + "end_line": 869, + "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": 871, + "end_line": 881, + "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": 883, + "end_line": 886, + "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": 888, + "end_line": 890, + "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": 892, + "end_line": 894, + "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": 896, + "end_line": 898, + "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": 904, + "end_line": 906, + "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": 908, + "end_line": 910, + "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": 912, + "end_line": 914, + "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": 916, + "end_line": 918, + "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": 922, + "end_line": 924, + "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": 926, + "end_line": 928, + "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": 930, + "end_line": 931, + "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": 933, + "end_line": 934, + "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": 936, + "end_line": 938, + "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": 940, + "end_line": 942, + "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": 944, + "end_line": 946, + "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": 950, + "end_line": 952, + "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": 954, + "end_line": 956, + "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": 958, + "end_line": 960, + "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": 962, + "end_line": 964, + "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": 966, + "end_line": 968, + "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": 970, + "end_line": 972, + "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": 974, + "end_line": 976, + "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": 978, + "end_line": 980, + "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": 982, + "end_line": 1023, + "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": 1025, + "end_line": 1066, + "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": 1068, + "end_line": 1109, + "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": 1113, + "end_line": 1150, + "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": 1152, + "end_line": 1153, + "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": 1155, + "end_line": 1156, + "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": 1158, + "end_line": 1159, + "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": 1161, + "end_line": 1162, + "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": 1164, + "end_line": 1165, + "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": 1167, + "end_line": 1168, + "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": 1170, + "end_line": 1173, + "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": 1175, + "end_line": 1179, + "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": 1181, + "end_line": 1189, + "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": 1191, + "end_line": 1219, + "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": 1221, + "end_line": 1223, + "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": 1225, + "end_line": 1227, + "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": 1229, + "end_line": 1269, + "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": 1271, + "end_line": 1273, + "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": 1275, + "end_line": 1277, + "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": 1279, + "end_line": 1281, + "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": 1284, + "end_line": 1286, + "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": 1288, + "end_line": 1298, + "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": 1300, + "end_line": 1308, + "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": 1310, + "end_line": 1315, + "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": 1317, + "end_line": 1321, + "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": 1325, + "end_line": 1329, + "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": 1333, + "end_line": 1340, + "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": 1342, + "end_line": 1346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 1348, + "end_line": 1349, + "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": 1353, + "end_line": 1354, + "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": 1357, + "end_line": 1366, + "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": 1368, + "end_line": 1370, + "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": 1372, + "end_line": 1374, + "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": 1376, + "end_line": 1382, + "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": 1384, + "end_line": 1388, + "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": 1408, + "end_line": 1410, + "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": 1415, + "end_line": 1430, + "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": 1432, + "end_line": 1450, + "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": 1452, + "end_line": 1471, + "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": 1473, + "end_line": 1477, + "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": 1479, + "end_line": 1483, + "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": 1487, + "end_line": 1489, + "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": 1491, + "end_line": 1499, + "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": 1501, + "end_line": 1509, + "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": 1511, + "end_line": 1519, + "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": 1521, + "end_line": 1536, + "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": 1538, + "end_line": 1541, + "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": 1543, + "end_line": 1547, + "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": 1549, + "end_line": 1552, + "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": 1554, + "end_line": 1557, + "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": 1560, + "end_line": 1563, + "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": 1565, + "end_line": 1582, + "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": 1584, + "end_line": 1588, + "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": 1593, + "end_line": 1700, + "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": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 1724, + "end_line": 1726, + "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": 1727, + "end_line": 1731, + "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": 1722, + "end_line": 1738, + "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": 1740, + "end_line": 1746, + "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": 1748, + "end_line": 1750, + "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": 1752, + "end_line": 1754, + "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": 1756, + "end_line": 1758, + "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": 1760, + "end_line": 1762, + "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": 1764, + "end_line": 1769, + "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": 1771, + "end_line": 1778, + "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": 1780, + "end_line": 1791, + "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": 1793, + "end_line": 1804, + "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": 1806, + "end_line": 1813, + "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": 1815, + "end_line": 1822, + "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": 1824, + "end_line": 1838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 1840, + "end_line": 1848, + "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": "ma.py", + "nloc": 9, + "complexity": 2, + "token_count": 64, + "parameters": [ + "a", + "axes" + ], + "start_line": 1850, + "end_line": 1858, + "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": 1861, + "end_line": 1874, + "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": 1876, + "end_line": 1884, + "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": 1886, + "end_line": 1896, + "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": 1898, + "end_line": 1910, + "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": 1912, + "end_line": 1917, + "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": 1919, + "end_line": 1928, + "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": 1932, + "end_line": 1936, + "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": 1938, + "end_line": 1951, + "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": 1953, + "end_line": 1962, + "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": 1964, + "end_line": 1975, + "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": 1981, + "end_line": 1985, + "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": 1987, + "end_line": 2000, + "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": 2002, + "end_line": 2011, + "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": 2013, + "end_line": 2024, + "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": 2028, + "end_line": 2045, + "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": 2047, + "end_line": 2054, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 2056, + "end_line": 2063, + "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": 2065, + "end_line": 2073, + "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": 2075, + "end_line": 2089, + "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": 2091, + "end_line": 2093, + "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": 2095, + "end_line": 2101, + "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": 2107, + "end_line": 2108, + "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": 2109, + "end_line": 2110, + "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": 2119, + "end_line": 2120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 2126, + "end_line": 2127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "is_mask", + "long_name": "is_mask( m )", + "filename": "ma.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "m" + ], + "start_line": 160, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "where", + "long_name": "where( condition , x , y )", + "filename": "ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 127, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 1702, + "end_line": 1720, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "nloc": 1689, + "complexity": 459, + "token_count": 11831, + "diff_parsed": { + "added": [ + " try:", + " return m.dtype.type is MaskType", + " except AttributeError:", + " return False" + ], + "deleted": [ + " if m is nomask or (isinstance(m, ndarray) and \\", + " m.dtype.type is MaskType):", + " return 1", + " else:", + " return 0", + " if xm is nomask: xm = numeric.False_", + " if ym is nomask: ym = numeric.False_" + ] + } + } + ] + }, + { + "hash": "502af603c2b1cc85696fc62f4b0a79842887f07b", + "msg": "Fix so that arrays never become scalars using .copy() command", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T03:31:30+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T03:31:30+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "45475dd140ce5ce8e9f2f9cbd5573e5b288c87dd" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/src/arraymethods.c", + "new_path": "numpy/core/src/arraymethods.c", + "filename": "arraymethods.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -641,7 +641,7 @@ array_copy(PyArrayObject *self, PyObject *args)\n \tint fortran=0;\n if (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n \t\n- return _ARET(PyArray_NewCopy(self, fortran));\n+ return PyArray_NewCopy(self, fortran);\n }\n \n static char doc_resize[] = \"self.resize(new_shape). \"\\\n", + "added_lines": 1, + "deleted_lines": 1, + "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\n/* Used to reshape a Fortran Array */\nstatic void\n_reverse_shape(PyArray_Dims *newshape)\n{\n\tint i, n = newshape->len;\n\tintp *ptr = newshape->ptr;\n\tintp *eptr;\n\tintp tmp;\n\tint len = n >> 1;\n\n\teptr = ptr+n-1;\n\tfor(i=0; i) 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\t\\\n\t\t PyType_IsSubtype((PyTypeObject *)otype, \n\t\t\t\t &PyBigArray_Type)) {\n\t\t\treturn _ARET(PyArray_View(self, NULL, \n\t\t\t\t\t\t (PyTypeObject *)otype));\n\t\t}\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 _ARET(PyArray_View(self, type, NULL));\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Min(self, axis);\n}\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 or PyBigArray_Type */\n\tif (!PyArray_CheckExact(self) || !PyBigArray_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 = &PyBigArray_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 == 0 then the result is contiguous (default). \\n\"\\\n\t\"If fortran > 0 then the result has fortran data order. \\n\"\\\n\t\"If fortran < 0 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\tint fortran=0;\n if (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\t\n return PyArray_NewCopy(self, fortran);\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape). \"\\\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) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\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}\n\tret = PyArray_Resize(self, &newshape);\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\tlong 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, fortran, \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()\\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\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\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, (int) 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\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\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_DECREF(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.dtypedescr.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 _ARET(PyArray_View(self,\tnew, 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, 1, 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, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS, 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, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS, 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, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS, 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{\"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\n/* Used to reshape a Fortran Array */\nstatic void\n_reverse_shape(PyArray_Dims *newshape)\n{\n\tint i, n = newshape->len;\n\tintp *ptr = newshape->ptr;\n\tintp *eptr;\n\tintp tmp;\n\tint len = n >> 1;\n\n\teptr = ptr+n-1;\n\tfor(i=0; i) 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\t\\\n\t\t PyType_IsSubtype((PyTypeObject *)otype, \n\t\t\t\t &PyBigArray_Type)) {\n\t\t\treturn _ARET(PyArray_View(self, NULL, \n\t\t\t\t\t\t (PyTypeObject *)otype));\n\t\t}\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 _ARET(PyArray_View(self, type, NULL));\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Min(self, axis);\n}\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 or PyBigArray_Type */\n\tif (!PyArray_CheckExact(self) || !PyBigArray_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 = &PyBigArray_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 == 0 then the result is contiguous (default). \\n\"\\\n\t\"If fortran > 0 then the result has fortran data order. \\n\"\\\n\t\"If fortran < 0 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\tint fortran=0;\n if (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\t\n return _ARET(PyArray_NewCopy(self, fortran));\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape). \"\\\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) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\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}\n\tret = PyArray_Resize(self, &newshape);\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\tlong 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, fortran, \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()\\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\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) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\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\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, (int) 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\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\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_DECREF(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.dtypedescr.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 _ARET(PyArray_View(self,\tnew, 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, 1, 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, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS, 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, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS, 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, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS, 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{\"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": "_reverse_shape", + "long_name": "_reverse_shape( PyArray_Dims * newshape)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 2, + "token_count": 81, + "parameters": [ + "newshape" + ], + "start_line": 72, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 50, + "complexity": 13, + "token_count": 299, + "parameters": [ + "self", + "args" + ], + "start_line": 94, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "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": 152, + "end_line": 156, + "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": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 163, + "end_line": 183, + "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)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 188, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 201, + "end_line": 209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 214, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 241, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 255, + "end_line": 262, + "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": 274, + "end_line": 298, + "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": 301, + "end_line": 313, + "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": 323, + "end_line": 349, + "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": 352, + "end_line": 367, + "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": 374, + "end_line": 421, + "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": 428, + "end_line": 436, + "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": 442, + "end_line": 452, + "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": 458, + "end_line": 462, + "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": 467, + "end_line": 501, + "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": 507, + "end_line": 516, + "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": 523, + "end_line": 537, + "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": 545, + "end_line": 573, + "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": 577, + "end_line": 581, + "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": 8, + "token_count": 224, + "parameters": [ + "self", + "args" + ], + "start_line": 587, + "end_line": 630, + "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": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 639, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 26, + "complexity": 6, + "token_count": 129, + "parameters": [ + "self", + "args" + ], + "start_line": 653, + "end_line": 679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "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": 687, + "end_line": 697, + "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": 707, + "end_line": 722, + "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": 727, + "end_line": 742, + "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": 749, + "end_line": 760, + "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": 771, + "end_line": 778, + "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": 783, + "end_line": 816, + "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": 820, + "end_line": 839, + "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": 842, + "end_line": 860, + "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": 865, + "end_line": 928, + "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": 98, + "complexity": 17, + "token_count": 579, + "parameters": [ + "self", + "args" + ], + "start_line": 946, + "end_line": 1059, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "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": 1063, + "end_line": 1084, + "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": 1088, + "end_line": 1099, + "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": 1105, + "end_line": 1116, + "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": 1121, + "end_line": 1126, + "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": 1132, + "end_line": 1152, + "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": 1170, + "end_line": 1182, + "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": 1209, + "end_line": 1221, + "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": 1227, + "end_line": 1239, + "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": 1244, + "end_line": 1256, + "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": 1262, + "end_line": 1274, + "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)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1280, + "end_line": 1288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1293, + "end_line": 1301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1306, + "end_line": 1318, + "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": 1323, + "end_line": 1335, + "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": 1340, + "end_line": 1351, + "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": 1357, + "end_line": 1362, + "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": 1370, + "end_line": 1383, + "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": 1391, + "end_line": 1401, + "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": 1408, + "end_line": 1414, + "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": 1420, + "end_line": 1430, + "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": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 1435, + "end_line": 1442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 1447, + "end_line": 1454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 1464, + "end_line": 1521, + "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": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 1527, + "end_line": 1539, + "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": "_reverse_shape", + "long_name": "_reverse_shape( PyArray_Dims * newshape)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 2, + "token_count": 81, + "parameters": [ + "newshape" + ], + "start_line": 72, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 50, + "complexity": 13, + "token_count": 299, + "parameters": [ + "self", + "args" + ], + "start_line": 94, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "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": 152, + "end_line": 156, + "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": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 163, + "end_line": 183, + "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)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 188, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 201, + "end_line": 209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 214, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 241, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 255, + "end_line": 262, + "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": 274, + "end_line": 298, + "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": 301, + "end_line": 313, + "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": 323, + "end_line": 349, + "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": 352, + "end_line": 367, + "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": 374, + "end_line": 421, + "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": 428, + "end_line": 436, + "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": 442, + "end_line": 452, + "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": 458, + "end_line": 462, + "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": 467, + "end_line": 501, + "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": 507, + "end_line": 516, + "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": 523, + "end_line": 537, + "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": 545, + "end_line": 573, + "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": 577, + "end_line": 581, + "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": 8, + "token_count": 224, + "parameters": [ + "self", + "args" + ], + "start_line": 587, + "end_line": 630, + "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": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 639, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 26, + "complexity": 6, + "token_count": 129, + "parameters": [ + "self", + "args" + ], + "start_line": 653, + "end_line": 679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "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": 687, + "end_line": 697, + "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": 707, + "end_line": 722, + "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": 727, + "end_line": 742, + "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": 749, + "end_line": 760, + "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": 771, + "end_line": 778, + "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": 783, + "end_line": 816, + "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": 820, + "end_line": 839, + "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": 842, + "end_line": 860, + "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": 865, + "end_line": 928, + "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": 98, + "complexity": 17, + "token_count": 579, + "parameters": [ + "self", + "args" + ], + "start_line": 946, + "end_line": 1059, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "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": 1063, + "end_line": 1084, + "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": 1088, + "end_line": 1099, + "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": 1105, + "end_line": 1116, + "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": 1121, + "end_line": 1126, + "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": 1132, + "end_line": 1152, + "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": 1170, + "end_line": 1182, + "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": 1209, + "end_line": 1221, + "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": 1227, + "end_line": 1239, + "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": 1244, + "end_line": 1256, + "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": 1262, + "end_line": 1274, + "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)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1280, + "end_line": 1288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1293, + "end_line": 1301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 1306, + "end_line": 1318, + "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": 1323, + "end_line": 1335, + "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": 1340, + "end_line": 1351, + "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": 1357, + "end_line": 1362, + "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": 1370, + "end_line": 1383, + "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": 1391, + "end_line": 1401, + "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": 1408, + "end_line": 1414, + "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": 1420, + "end_line": 1430, + "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": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 1435, + "end_line": 1442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 1447, + "end_line": 1454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 1464, + "end_line": 1521, + "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": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 1527, + "end_line": 1539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "array_copy", + "long_name": "array_copy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 639, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "nloc": 1311, + "complexity": 220, + "token_count": 8173, + "diff_parsed": { + "added": [ + " return PyArray_NewCopy(self, fortran);" + ], + "deleted": [ + " return _ARET(PyArray_NewCopy(self, fortran));" + ] + } + } + ] + }, + { + "hash": "e8d618404b33962e896c45c6419c5daabdee4961", + "msg": "Fixed error in no-axis methods for matrices.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T08:47:02+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T08:47:02+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "502af603c2b1cc85696fc62f4b0a79842887f07b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 1, + "insertions": 6, + "lines": 7, + "files": 2, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/core/src/arrayobject.c", + "new_path": "numpy/core/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -3273,7 +3273,7 @@ _check_axis(PyArrayObject *arr, int *axis, int flags)\n \n \tif ((*axis >= MAX_DIMS) || (n==0)) {\n \t\ttemp = PyArray_Ravel(arr,0);\n-\t\t*axis = 0;\n+\t\t*axis = PyArray_NDIM(temp)-1;\n \t\treturn temp;\n \t}\n \telse {\n", + "added_lines": 1, + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*axis = PyArray_NDIM(temp)-1;\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; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*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; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "methods": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3332, + "end_line": 3355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3361, + "end_line": 3377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3381, + "end_line": 3397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3400, + "end_line": 3417, + "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": 3420, + "end_line": 3453, + "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": 3460, + "end_line": 3487, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3496, + "end_line": 3511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3531, + "end_line": 3555, + "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": 3561, + "end_line": 3583, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3587, + "end_line": 3629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3637, + "end_line": 3795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3804, + "end_line": 3902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3908, + "end_line": 3925, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3929, + "end_line": 3971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3974, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4097, + "end_line": 4105, + "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": 4111, + "end_line": 4114, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4117, + "end_line": 4121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4124, + "end_line": 4127, + "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": 4131, + "end_line": 4160, + "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": 4164, + "end_line": 4167, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4170, + "end_line": 4208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4212, + "end_line": 4219, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4222, + "end_line": 4230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4234, + "end_line": 4240, + "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": 4243, + "end_line": 4257, + "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": 4260, + "end_line": 4304, + "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": 4308, + "end_line": 4311, + "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": 4314, + "end_line": 4325, + "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": 4328, + "end_line": 4339, + "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": 4345, + "end_line": 4348, + "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": 4351, + "end_line": 4355, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4369, + "end_line": 4454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4457, + "end_line": 4475, + "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": 4478, + "end_line": 4496, + "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": 4499, + "end_line": 4509, + "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": 4513, + "end_line": 4538, + "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": 4542, + "end_line": 4575, + "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": 4578, + "end_line": 4611, + "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": 4614, + "end_line": 4651, + "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": 4654, + "end_line": 4657, + "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": 4660, + "end_line": 4710, + "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": 4800, + "end_line": 4807, + "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": 4909, + "end_line": 4942, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4945, + "end_line": 4967, + "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": 4974, + "end_line": 5000, + "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": 5006, + "end_line": 5038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5050, + "end_line": 5186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5189, + "end_line": 5212, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5217, + "end_line": 5245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5250, + "end_line": 5314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5321, + "end_line": 5330, + "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": 5336, + "end_line": 5429, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5439, + "end_line": 5485, + "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": 5495, + "end_line": 5548, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5553, + "end_line": 5682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5686, + "end_line": 5794, + "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": 5798, + "end_line": 5838, + "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": 5842, + "end_line": 5980, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5984, + "end_line": 6021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6027, + "end_line": 6103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6108, + "end_line": 6111, + "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": 6118, + "end_line": 6131, + "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": 19, + "complexity": 8, + "token_count": 123, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6177, + "end_line": 6196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6209, + "end_line": 6225, + "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": 6231, + "end_line": 6319, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6324, + "end_line": 6352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6365, + "end_line": 6403, + "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": 6411, + "end_line": 6428, + "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": 6433, + "end_line": 6443, + "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": 6446, + "end_line": 6450, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6453, + "end_line": 6456, + "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": 6460, + "end_line": 6510, + "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": 6513, + "end_line": 6567, + "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": 6571, + "end_line": 6704, + "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": 6708, + "end_line": 6740, + "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": 6743, + "end_line": 6785, + "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": 6788, + "end_line": 6922, + "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": 6935, + "end_line": 6980, + "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": 6985, + "end_line": 6989, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7058, + "end_line": 7074, + "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": 7081, + "end_line": 7150, + "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": 7154, + "end_line": 7191, + "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": 7197, + "end_line": 7241, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7259, + "end_line": 7387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7393, + "end_line": 7465, + "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": 7468, + "end_line": 7594, + "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": 7598, + "end_line": 7607, + "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": 7678, + "end_line": 7727, + "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": 7730, + "end_line": 7775, + "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": 7778, + "end_line": 7797, + "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": 7800, + "end_line": 7807, + "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": 7810, + "end_line": 7820, + "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": 7823, + "end_line": 7833, + "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": 7836, + "end_line": 7839, + "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": 7842, + "end_line": 7854, + "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": 7884, + "end_line": 7891, + "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": 7950, + "end_line": 7959, + "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": 7977, + "end_line": 7999, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8005, + "end_line": 8015, + "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": 8033, + "end_line": 8041, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8044, + "end_line": 8056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8059, + "end_line": 8081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8084, + "end_line": 8103, + "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": 8110, + "end_line": 8117, + "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": 8120, + "end_line": 8127, + "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": 8130, + "end_line": 8137, + "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": 8177, + "end_line": 8229, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8235, + "end_line": 8292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8300, + "end_line": 8342, + "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": 8362, + "end_line": 8428, + "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": 8439, + "end_line": 8447, + "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": 8462, + "end_line": 8507, + "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": 8510, + "end_line": 8519, + "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": 8522, + "end_line": 8532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 166, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3332, + "end_line": 3355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3361, + "end_line": 3377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3381, + "end_line": 3397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3400, + "end_line": 3417, + "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": 3420, + "end_line": 3453, + "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": 3460, + "end_line": 3487, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3496, + "end_line": 3511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3531, + "end_line": 3555, + "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": 3561, + "end_line": 3583, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3587, + "end_line": 3629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3637, + "end_line": 3795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3804, + "end_line": 3902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3908, + "end_line": 3925, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3929, + "end_line": 3971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3974, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4097, + "end_line": 4105, + "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": 4111, + "end_line": 4114, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4117, + "end_line": 4121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4124, + "end_line": 4127, + "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": 4131, + "end_line": 4160, + "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": 4164, + "end_line": 4167, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4170, + "end_line": 4208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4212, + "end_line": 4219, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4222, + "end_line": 4230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4234, + "end_line": 4240, + "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": 4243, + "end_line": 4257, + "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": 4260, + "end_line": 4304, + "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": 4308, + "end_line": 4311, + "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": 4314, + "end_line": 4325, + "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": 4328, + "end_line": 4339, + "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": 4345, + "end_line": 4348, + "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": 4351, + "end_line": 4355, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4369, + "end_line": 4454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4457, + "end_line": 4475, + "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": 4478, + "end_line": 4496, + "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": 4499, + "end_line": 4509, + "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": 4513, + "end_line": 4538, + "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": 4542, + "end_line": 4575, + "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": 4578, + "end_line": 4611, + "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": 4614, + "end_line": 4651, + "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": 4654, + "end_line": 4657, + "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": 4660, + "end_line": 4710, + "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": 4800, + "end_line": 4807, + "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": 4909, + "end_line": 4942, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4945, + "end_line": 4967, + "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": 4974, + "end_line": 5000, + "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": 5006, + "end_line": 5038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5050, + "end_line": 5186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5189, + "end_line": 5212, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5217, + "end_line": 5245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5250, + "end_line": 5314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5321, + "end_line": 5330, + "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": 5336, + "end_line": 5429, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5439, + "end_line": 5485, + "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": 5495, + "end_line": 5548, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5553, + "end_line": 5682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5686, + "end_line": 5794, + "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": 5798, + "end_line": 5838, + "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": 5842, + "end_line": 5980, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5984, + "end_line": 6021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6027, + "end_line": 6103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6108, + "end_line": 6111, + "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": 6118, + "end_line": 6131, + "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": 19, + "complexity": 8, + "token_count": 123, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6177, + "end_line": 6196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6209, + "end_line": 6225, + "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": 6231, + "end_line": 6319, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6324, + "end_line": 6352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6365, + "end_line": 6403, + "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": 6411, + "end_line": 6428, + "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": 6433, + "end_line": 6443, + "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": 6446, + "end_line": 6450, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6453, + "end_line": 6456, + "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": 6460, + "end_line": 6510, + "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": 6513, + "end_line": 6567, + "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": 6571, + "end_line": 6704, + "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": 6708, + "end_line": 6740, + "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": 6743, + "end_line": 6785, + "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": 6788, + "end_line": 6922, + "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": 6935, + "end_line": 6980, + "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": 6985, + "end_line": 6989, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7058, + "end_line": 7074, + "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": 7081, + "end_line": 7150, + "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": 7154, + "end_line": 7191, + "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": 7197, + "end_line": 7241, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7259, + "end_line": 7387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7393, + "end_line": 7465, + "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": 7468, + "end_line": 7594, + "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": 7598, + "end_line": 7607, + "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": 7678, + "end_line": 7727, + "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": 7730, + "end_line": 7775, + "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": 7778, + "end_line": 7797, + "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": 7800, + "end_line": 7807, + "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": 7810, + "end_line": 7820, + "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": 7823, + "end_line": 7833, + "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": 7836, + "end_line": 7839, + "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": 7842, + "end_line": 7854, + "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": 7884, + "end_line": 7891, + "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": 7950, + "end_line": 7959, + "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": 7977, + "end_line": 7999, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8005, + "end_line": 8015, + "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": 8033, + "end_line": 8041, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8044, + "end_line": 8056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8059, + "end_line": 8081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8084, + "end_line": 8103, + "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": 8110, + "end_line": 8117, + "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": 8120, + "end_line": 8127, + "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": 8130, + "end_line": 8137, + "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": 8177, + "end_line": 8229, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8235, + "end_line": 8292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8300, + "end_line": 8342, + "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": 8362, + "end_line": 8428, + "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": 8439, + "end_line": 8447, + "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": 8462, + "end_line": 8507, + "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": 8510, + "end_line": 8519, + "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": 8522, + "end_line": 8532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "nloc": 6809, + "complexity": 1457, + "token_count": 40023, + "diff_parsed": { + "added": [ + "\t\t*axis = PyArray_NDIM(temp)-1;" + ], + "deleted": [ + "\t\t*axis = 0;" + ] + } + }, + { + "old_path": "numpy/core/tests/test_defmatrix.py", + "new_path": "numpy/core/tests/test_defmatrix.py", + "filename": "test_defmatrix.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -74,6 +74,11 @@ def check_asmatrix(self):\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n \n+ def check_noaxis(self):\n+ A = matrix([[1,0],[0,1]])\n+\tassert A.sum() == matrix(2)\n+\tassert A.mean() == matrix(0.5)\n+\n class test_autocasting(ScipyTestCase):\n def check_basic(self):\n A = arange(100).reshape(10,10)\n", + "added_lines": 5, + "deleted_lines": 0, + "source_code": "\nfrom numpy.testing import *\nset_package_path()\nimport numpy.core;reload(numpy.core)\nfrom numpy.core import *\nrestore_path()\n\nclass test_ctor(ScipyTestCase):\n def check_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def check_basic(self):\n import numpy.linalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def check_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def check_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\n def check_noaxis(self):\n A = matrix([[1,0],[0,1]])\n\tassert A.sum() == matrix(2)\n\tassert A.mean() == matrix(0.5)\n\nclass test_autocasting(ScipyTestCase):\n def check_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype.type == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype.type == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def check_basic(self):\n import numpy.linalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\nfrom numpy.testing import *\nset_package_path()\nimport numpy.core;reload(numpy.core)\nfrom numpy.core import *\nrestore_path()\n\nclass test_ctor(ScipyTestCase):\n def check_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def check_basic(self):\n import numpy.linalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def check_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def check_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\nclass test_autocasting(ScipyTestCase):\n def check_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype.type == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype.type == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def check_basic(self):\n import numpy.linalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_comparisons", + "long_name": "check_comparisons( self )", + "filename": "test_defmatrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_asmatrix", + "long_name": "check_asmatrix( self )", + "filename": "test_defmatrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_noaxis", + "long_name": "check_noaxis( self )", + "filename": "test_defmatrix.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_comparisons", + "long_name": "check_comparisons( self )", + "filename": "test_defmatrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_asmatrix", + "long_name": "check_asmatrix( self )", + "filename": "test_defmatrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_defmatrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_noaxis", + "long_name": "check_noaxis( self )", + "filename": "test_defmatrix.py", + "nloc": 4, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "nloc": 102, + "complexity": 9, + "token_count": 949, + "diff_parsed": { + "added": [ + " def check_noaxis(self):", + " A = matrix([[1,0],[0,1]])", + "\tassert A.sum() == matrix(2)", + "\tassert A.mean() == matrix(0.5)", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "9ccdfb64beb215ca845e07aa469d13a968dc8676", + "msg": "Change order of descriptor functions to match required vs. non-required.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T10:20:33+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T10:20:33+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "e8d618404b33962e896c45c6419c5daabdee4961" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 17, + "insertions": 37, + "lines": 54, + "files": 3, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/code_generators/generate_array_api.py", + "new_path": "numpy/core/code_generators/generate_array_api.py", + "filename": "generate_array_api.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -64,9 +64,9 @@\n if (PyArray_API == NULL) return -1;\n /* Perform runtime check of C API version */\n if (NDARRAY_VERSION != PyArray_GetNDArrayCVersion()) {\n- PyErr_Format(PyExc_RuntimeError, \"numpy C-API mismatch: module \"\\\n- \"compiled against version %%X but this version of numpy is %%X\", \\\n- (uint) PyArray_GetNDArrayCVersion(), (uint) NDARRAY_VERSION);\n+ PyErr_Format(PyExc_RuntimeError, \"module compiled against \"\\\n+ \"version %%x of C-API but this version of numpy is %%x\", \\\n+ (int) PyArray_GetNDArrayCVersion(), (int) NDARRAY_VERSION);\n return -1;\n }\n return 0;\n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "import os\nimport genapi\n\ntypes = ['Generic','Number','Integer','SignedInteger','UnsignedInteger',\n 'Inexact',\n 'Floating', 'ComplexFloating', 'Flexible', 'Character',\n 'Bool','Byte','Short','Int', 'Long', 'LongLong', 'UByte', 'UShort',\n 'UInt', 'ULong', 'ULongLong', 'Float', 'Double', 'LongDouble',\n 'CFloat', 'CDouble', 'CLongDouble', 'Object', 'String', 'Unicode',\n 'Void']\n\nh_template = r\"\"\"\n#ifdef _MULTIARRAYMODULE\n\nstatic PyTypeObject PyBigArray_Type;\nstatic PyTypeObject PyArray_Type;\nstatic PyTypeObject PyArrayDescr_Type;\nstatic PyTypeObject PyArrayIter_Type;\nstatic PyTypeObject PyArrayMapIter_Type;\nstatic PyTypeObject PyArrayMultiIter_Type;\nstatic int PyArray_NUMUSERTYPES=0;\n\n%s\n\n#else\n\n#if defined(PY_ARRAY_UNIQUE_SYMBOL)\n#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL\n#endif\n\n#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)\nextern void **PyArray_API;\n#else\n#if defined(PY_ARRAY_UNIQUE_SYMBOL)\nvoid **PyArray_API;\n#else\nstatic void **PyArray_API=NULL;\n#endif\n#endif\n\n#define PyBigArray_Type (*(PyTypeObject *)PyArray_API[0])\n#define PyArray_Type (*(PyTypeObject *)PyArray_API[1])\n#define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[2])\n#define PyArrayIter_Type (*(PyTypeObject *)PyArray_API[3])\n#define PyArrayMultiIter_Type (*(PyTypeObject *)PyArray_API[4])\n#define PyArray_NUMUSERTYPES (*(int *)PyArray_API[5])\n\n%s\n\n#if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT)\nstatic int\nimport_array(void)\n{\n PyObject *numpy = PyImport_ImportModule(\"numpy.core.multiarray\");\n PyObject *c_api = NULL;\n if (numpy == NULL) return -1;\n c_api = PyObject_GetAttrString(numpy, \"_ARRAY_API\");\n if (c_api == NULL) {Py_DECREF(numpy); return -1;}\n if (PyCObject_Check(c_api)) {\n PyArray_API = (void **)PyCObject_AsVoidPtr(c_api);\n }\n Py_DECREF(c_api);\n Py_DECREF(numpy);\n if (PyArray_API == NULL) return -1;\n /* Perform runtime check of C API version */\n if (NDARRAY_VERSION != PyArray_GetNDArrayCVersion()) {\n PyErr_Format(PyExc_RuntimeError, \"module compiled against \"\\\n \"version %%x of C-API but this version of numpy is %%x\", \\\n (int) PyArray_GetNDArrayCVersion(), (int) NDARRAY_VERSION);\n return -1;\n }\n return 0;\n}\n#endif\n\n#endif\n\"\"\"\n\n\nc_template = r\"\"\"\n/* These pointers will be stored in the C-object for use in other\n extension modules\n*/\n\nvoid *PyArray_API[] = {\n (void *) &PyBigArray_Type,\n (void *) &PyArray_Type,\n (void *) &PyArrayDescr_Type,\n (void *) &PyArrayIter_Type,\n (void *) &PyArrayMultiIter_Type,\n (int *) &PyArray_NUMUSERTYPES, \n%s\n};\n\"\"\"\n\ndef generate_api(output_dir):\n objectapi_list = genapi.get_api_functions('OBJECT_API',\n 'array_api_order.txt')\n multiapi_list = genapi.get_api_functions('MULTIARRAY_API',\n 'multiarray_api_order.txt')\n # API fixes for __arrayobject_api.h\n\n fixed = 6\n numtypes = len(types) + fixed\n numobject = len(objectapi_list) + numtypes\n nummulti = len(multiapi_list)\n numtotal = numobject + nummulti\n\n module_list = []\n extension_list = []\n init_list = []\n\n # setup types\n for k, atype in enumerate(types):\n num = fixed + k\n astr = \" (void *) &Py%sArrType_Type,\" % types[k]\n init_list.append(astr)\n astr = \"static PyTypeObject Py%sArrType_Type;\" % types[k]\n module_list.append(astr)\n astr = \"#define Py%sArrType_Type (*(PyTypeObject *)PyArray_API[%d])\" % \\\n (types[k], num)\n extension_list.append(astr)\n\n #setup object API\n genapi.add_api_list(numtypes, 'PyArray_API', objectapi_list,\n module_list, extension_list, init_list)\n\n # setup multiarray module API\n genapi.add_api_list(numobject, 'PyArray_API', multiapi_list,\n module_list, extension_list, init_list)\n\n\n # Write to header\n fid = open(os.path.join(output_dir, '__multiarray_api.h'),'w')\n s = h_template % ('\\n'.join(module_list), '\\n'.join(extension_list))\n fid.write(s)\n fid.close()\n\n # Write to c-code\n fid = open(os.path.join(output_dir,'__multiarray_api.c'),'w')\n s = c_template % '\\n'.join(init_list)\n fid.write(s)\n fid.close()\n", + "source_code_before": "import os\nimport genapi\n\ntypes = ['Generic','Number','Integer','SignedInteger','UnsignedInteger',\n 'Inexact',\n 'Floating', 'ComplexFloating', 'Flexible', 'Character',\n 'Bool','Byte','Short','Int', 'Long', 'LongLong', 'UByte', 'UShort',\n 'UInt', 'ULong', 'ULongLong', 'Float', 'Double', 'LongDouble',\n 'CFloat', 'CDouble', 'CLongDouble', 'Object', 'String', 'Unicode',\n 'Void']\n\nh_template = r\"\"\"\n#ifdef _MULTIARRAYMODULE\n\nstatic PyTypeObject PyBigArray_Type;\nstatic PyTypeObject PyArray_Type;\nstatic PyTypeObject PyArrayDescr_Type;\nstatic PyTypeObject PyArrayIter_Type;\nstatic PyTypeObject PyArrayMapIter_Type;\nstatic PyTypeObject PyArrayMultiIter_Type;\nstatic int PyArray_NUMUSERTYPES=0;\n\n%s\n\n#else\n\n#if defined(PY_ARRAY_UNIQUE_SYMBOL)\n#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL\n#endif\n\n#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)\nextern void **PyArray_API;\n#else\n#if defined(PY_ARRAY_UNIQUE_SYMBOL)\nvoid **PyArray_API;\n#else\nstatic void **PyArray_API=NULL;\n#endif\n#endif\n\n#define PyBigArray_Type (*(PyTypeObject *)PyArray_API[0])\n#define PyArray_Type (*(PyTypeObject *)PyArray_API[1])\n#define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[2])\n#define PyArrayIter_Type (*(PyTypeObject *)PyArray_API[3])\n#define PyArrayMultiIter_Type (*(PyTypeObject *)PyArray_API[4])\n#define PyArray_NUMUSERTYPES (*(int *)PyArray_API[5])\n\n%s\n\n#if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT)\nstatic int\nimport_array(void)\n{\n PyObject *numpy = PyImport_ImportModule(\"numpy.core.multiarray\");\n PyObject *c_api = NULL;\n if (numpy == NULL) return -1;\n c_api = PyObject_GetAttrString(numpy, \"_ARRAY_API\");\n if (c_api == NULL) {Py_DECREF(numpy); return -1;}\n if (PyCObject_Check(c_api)) {\n PyArray_API = (void **)PyCObject_AsVoidPtr(c_api);\n }\n Py_DECREF(c_api);\n Py_DECREF(numpy);\n if (PyArray_API == NULL) return -1;\n /* Perform runtime check of C API version */\n if (NDARRAY_VERSION != PyArray_GetNDArrayCVersion()) {\n PyErr_Format(PyExc_RuntimeError, \"numpy C-API mismatch: module \"\\\n \"compiled against version %%X but this version of numpy is %%X\", \\\n (uint) PyArray_GetNDArrayCVersion(), (uint) NDARRAY_VERSION);\n return -1;\n }\n return 0;\n}\n#endif\n\n#endif\n\"\"\"\n\n\nc_template = r\"\"\"\n/* These pointers will be stored in the C-object for use in other\n extension modules\n*/\n\nvoid *PyArray_API[] = {\n (void *) &PyBigArray_Type,\n (void *) &PyArray_Type,\n (void *) &PyArrayDescr_Type,\n (void *) &PyArrayIter_Type,\n (void *) &PyArrayMultiIter_Type,\n (int *) &PyArray_NUMUSERTYPES, \n%s\n};\n\"\"\"\n\ndef generate_api(output_dir):\n objectapi_list = genapi.get_api_functions('OBJECT_API',\n 'array_api_order.txt')\n multiapi_list = genapi.get_api_functions('MULTIARRAY_API',\n 'multiarray_api_order.txt')\n # API fixes for __arrayobject_api.h\n\n fixed = 6\n numtypes = len(types) + fixed\n numobject = len(objectapi_list) + numtypes\n nummulti = len(multiapi_list)\n numtotal = numobject + nummulti\n\n module_list = []\n extension_list = []\n init_list = []\n\n # setup types\n for k, atype in enumerate(types):\n num = fixed + k\n astr = \" (void *) &Py%sArrType_Type,\" % types[k]\n init_list.append(astr)\n astr = \"static PyTypeObject Py%sArrType_Type;\" % types[k]\n module_list.append(astr)\n astr = \"#define Py%sArrType_Type (*(PyTypeObject *)PyArray_API[%d])\" % \\\n (types[k], num)\n extension_list.append(astr)\n\n #setup object API\n genapi.add_api_list(numtypes, 'PyArray_API', objectapi_list,\n module_list, extension_list, init_list)\n\n # setup multiarray module API\n genapi.add_api_list(numobject, 'PyArray_API', multiapi_list,\n module_list, extension_list, init_list)\n\n\n # Write to header\n fid = open(os.path.join(output_dir, '__multiarray_api.h'),'w')\n s = h_template % ('\\n'.join(module_list), '\\n'.join(extension_list))\n fid.write(s)\n fid.close()\n\n # Write to c-code\n fid = open(os.path.join(output_dir,'__multiarray_api.c'),'w')\n s = c_template % '\\n'.join(init_list)\n fid.write(s)\n fid.close()\n", + "methods": [ + { + "name": "generate_api", + "long_name": "generate_api( output_dir )", + "filename": "generate_array_api.py", + "nloc": 34, + "complexity": 2, + "token_count": 246, + "parameters": [ + "output_dir" + ], + "start_line": 96, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "generate_api", + "long_name": "generate_api( output_dir )", + "filename": "generate_array_api.py", + "nloc": 34, + "complexity": 2, + "token_count": 246, + "parameters": [ + "output_dir" + ], + "start_line": 96, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 124, + "complexity": 2, + "token_count": 324, + "diff_parsed": { + "added": [ + " PyErr_Format(PyExc_RuntimeError, \"module compiled against \"\\", + " \"version %%x of C-API but this version of numpy is %%x\", \\", + " (int) PyArray_GetNDArrayCVersion(), (int) NDARRAY_VERSION);" + ], + "deleted": [ + " PyErr_Format(PyExc_RuntimeError, \"numpy C-API mismatch: module \"\\", + " \"compiled against version %%X but this version of numpy is %%X\", \\", + " (uint) PyArray_GetNDArrayCVersion(), (uint) NDARRAY_VERSION);" + ] + } + }, + { + "old_path": "numpy/core/include/numpy/arrayobject.h", + "new_path": "numpy/core/include/numpy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -74,7 +74,7 @@ extern \"C\" {\n #define PY_SUCCEED 1\n \n \t/* Helpful to distinguish what is installed */\n-#define NDARRAY_VERSION 0x000904\n+#define NDARRAY_VERSION 0x00090401\n \n \t/* Some platforms don't define bool, long long, or long double.\n \t Handle that here.\n@@ -803,6 +803,11 @@ typedef struct {\n \tPyArray_GetItemFunc *getitem;\n \tPyArray_SetItemFunc *setitem;\n \n+\t/* Copy and/or swap data. Memory areas may not overlap */\n+\t/* Use memmove first if they might */\n+\tPyArray_CopySwapNFunc *copyswapn;\n+ PyArray_CopySwapFunc *copyswap;\n+\n \t/* Function to compare items */\n \tPyArray_CompareFunc *compare;\n \n@@ -816,10 +821,6 @@ typedef struct {\n \t place a single value plus possible separator */\n \tPyArray_ScanFunc *scanfunc;\n \n-\t/* Copy and/or swap data. Memory areas may not overlap */\n-\t/* Use memmove first if they might */\n-\tPyArray_CopySwapNFunc *copyswapn;\n- PyArray_CopySwapFunc *copyswap;\n \t\n \t/* Function to determine if data is zero or not */\n \tPyArray_NonzeroFunc *nonzero;\n@@ -1010,14 +1011,33 @@ typedef struct {\n \tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n }\n \n-\n+#define _PyArray_ITER_NEXT1(it) {\t\t\\\n+\t\tit->dataptr += it->strides[0];\t\\\n+\t\tit->coordinates[0]++;\t\t\\\n+\t}\n+\t\n+#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n+\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n+\t\t\tit->coordinates[1]++;\t\t\t\t\\\n+\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t\telse {\t\t\t\t\t\t\t\\\n+\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n+\t\t\tit->coordinates[0]++;\t\t\t\t\\\n+\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n+\t\t\t\tit->backstrides[1];\t\t\t\\\n+\t\t}\t\t\t\t\t\t\t\\\n+\t}\n+\t\n #define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n \tit->index++;\t\t\t\t\t\t \\\n- if (it->nd_m1 == 0) { \\\n- it->dataptr += it->strides[0]; \\\n- it->coordinates[0]++; \\\n- } \\\n+ if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n+\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\t\\\n \telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n+\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n+\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\t\\\n \telse {\t\t\t\t\t\t\t\t\\\n \t\tint _i_;\t\t\t\t\t\t\\\n \t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n", + "added_lines": 30, + "deleted_lines": 10, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x00090401\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n#define _PyArray_ITER_NEXT1(it) {\t\t\\\n\t\tit->dataptr += it->strides[0];\t\\\n\t\tit->coordinates[0]++;\t\t\\\n\t}\n\t\n#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n\t\t\tit->coordinates[1]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n\t\t\tit->coordinates[0]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n\t\t\t\tit->backstrides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\t\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x000904\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) { \\\n it->dataptr += it->strides[0]; \\\n it->coordinates[0]++; \\\n } \\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 281, + "complexity": 0, + "token_count": 1305, + "diff_parsed": { + "added": [ + "#define NDARRAY_VERSION 0x00090401", + "\t/* Copy and/or swap data. Memory areas may not overlap */", + "\t/* Use memmove first if they might */", + "\tPyArray_CopySwapNFunc *copyswapn;", + " PyArray_CopySwapFunc *copyswap;", + "", + "#define _PyArray_ITER_NEXT1(it) {\t\t\\", + "\t\tit->dataptr += it->strides[0];\t\\", + "\t\tit->coordinates[0]++;\t\t\\", + "\t}", + "", + "#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\", + "\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\", + "\t\t\tit->coordinates[1]++;\t\t\t\t\\", + "\t\t\tit->dataptr += it->strides[1];\t\t\t\\", + "\t\t}\t\t\t\t\t\t\t\\", + "\t\telse {\t\t\t\t\t\t\t\\", + "\t\t\tit->coordinates[1] = 0;\t\t\t\t\\", + "\t\t\tit->coordinates[0]++;\t\t\t\t\\", + "\t\t\tit->dataptr += it->strides[0] -\t\t\t\\", + "\t\t\t\tit->backstrides[1];\t\t\t\\", + "\t\t}\t\t\t\t\t\t\t\\", + "\t}", + "", + " if (it->nd_m1 == 0) {\t\t\t\t\t\t\\", + "\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\", + "\t}\t\t\t\t\t\t\t\t\\", + "\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\", + "\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\", + "\t}\t\t\t\t\t\t\t\t\\" + ], + "deleted": [ + "#define NDARRAY_VERSION 0x000904", + "\t/* Copy and/or swap data. Memory areas may not overlap */", + "\t/* Use memmove first if they might */", + "\tPyArray_CopySwapNFunc *copyswapn;", + " PyArray_CopySwapFunc *copyswap;", + "", + " if (it->nd_m1 == 0) { \\", + " it->dataptr += it->strides[0]; \\", + " it->coordinates[0]++; \\", + " } \\" + ] + } + }, + { + "old_path": "numpy/core/src/arraytypes.inc.src", + "new_path": "numpy/core/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -1616,12 +1616,12 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n \t},\n \t(PyArray_GetItemFunc*)@from@_getitem, \n \t(PyArray_SetItemFunc*)@from@_setitem,\n+\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n+\t(PyArray_CopySwapFunc*)@from@_copyswap,\n \t(PyArray_CompareFunc*)@from@_compare, \n \t(PyArray_ArgFunc*)@from@_argmax,\n \t(PyArray_DotFunc*)NULL, \n \t(PyArray_ScanFunc*)@from@_scan,\n-\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n-\t(PyArray_CopySwapFunc*)@from@_copyswap,\n \t(PyArray_NonzeroFunc*)@from@_nonzero,\n \t(PyArray_FillFunc*)NULL,\n \t{\n@@ -1684,12 +1684,12 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n \t},\n \t(PyArray_GetItemFunc*)@from@_getitem, \n \t(PyArray_SetItemFunc*)@from@_setitem,\n+\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n+\t(PyArray_CopySwapFunc*)@from@_copyswap,\n \t(PyArray_CompareFunc*)@from@_compare, \n \t(PyArray_ArgFunc*)@from@_argmax,\n \t(PyArray_DotFunc*)@from@_dot, \n \t(PyArray_ScanFunc*)@from@_scan,\n-\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n-\t(PyArray_CopySwapFunc*)@from@_copyswap,\n \t(PyArray_NonzeroFunc*)@from@_nonzero,\n \t(PyArray_FillFunc*)@from@_fill,\n \t{\n", + "added_lines": 4, + "deleted_lines": 4, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "\t(PyArray_CopySwapNFunc*)@from@_copyswapn,", + "\t(PyArray_CopySwapFunc*)@from@_copyswap,", + "\t(PyArray_CopySwapNFunc*)@from@_copyswapn,", + "\t(PyArray_CopySwapFunc*)@from@_copyswap," + ], + "deleted": [ + "\t(PyArray_CopySwapNFunc*)@from@_copyswapn,", + "\t(PyArray_CopySwapFunc*)@from@_copyswap,", + "\t(PyArray_CopySwapNFunc*)@from@_copyswapn,", + "\t(PyArray_CopySwapFunc*)@from@_copyswap," + ] + } + } + ] + }, + { + "hash": "e966fd194660c6e1a3f560a70415fa986fc84309", + "msg": "Remove unnecessary check.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T10:43:42+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T10:43:42+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "9ccdfb64beb215ca845e07aa469d13a968dc8676" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 3, + "insertions": 0, + "lines": 3, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "numpy/core/src/arrayobject.c", + "new_path": "numpy/core/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -6177,9 +6177,6 @@ static PyObject *\n PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n int max_depth, int requires, PyObject *context) \n {\n-\tif (requires & ENSURECOPY) {\n-\t\trequires |= DEFAULT_FLAGS;\n-\t}\n \tif (requires & NOTSWAPPED) {\n \t\tif (!descr && PyArray_Check(op) && \\\n \t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n", + "added_lines": 0, + "deleted_lines": 3, + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*axis = PyArray_NDIM(temp)-1;\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; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*axis = PyArray_NDIM(temp)-1;\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; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "methods": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3332, + "end_line": 3355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3361, + "end_line": 3377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3381, + "end_line": 3397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3400, + "end_line": 3417, + "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": 3420, + "end_line": 3453, + "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": 3460, + "end_line": 3487, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3496, + "end_line": 3511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3531, + "end_line": 3555, + "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": 3561, + "end_line": 3583, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3587, + "end_line": 3629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3637, + "end_line": 3795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3804, + "end_line": 3902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3908, + "end_line": 3925, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3929, + "end_line": 3971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3974, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4097, + "end_line": 4105, + "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": 4111, + "end_line": 4114, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4117, + "end_line": 4121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4124, + "end_line": 4127, + "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": 4131, + "end_line": 4160, + "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": 4164, + "end_line": 4167, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4170, + "end_line": 4208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4212, + "end_line": 4219, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4222, + "end_line": 4230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4234, + "end_line": 4240, + "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": 4243, + "end_line": 4257, + "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": 4260, + "end_line": 4304, + "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": 4308, + "end_line": 4311, + "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": 4314, + "end_line": 4325, + "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": 4328, + "end_line": 4339, + "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": 4345, + "end_line": 4348, + "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": 4351, + "end_line": 4355, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4369, + "end_line": 4454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4457, + "end_line": 4475, + "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": 4478, + "end_line": 4496, + "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": 4499, + "end_line": 4509, + "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": 4513, + "end_line": 4538, + "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": 4542, + "end_line": 4575, + "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": 4578, + "end_line": 4611, + "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": 4614, + "end_line": 4651, + "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": 4654, + "end_line": 4657, + "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": 4660, + "end_line": 4710, + "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": 4800, + "end_line": 4807, + "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": 4909, + "end_line": 4942, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4945, + "end_line": 4967, + "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": 4974, + "end_line": 5000, + "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": 5006, + "end_line": 5038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5050, + "end_line": 5186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5189, + "end_line": 5212, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5217, + "end_line": 5245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5250, + "end_line": 5314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5321, + "end_line": 5330, + "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": 5336, + "end_line": 5429, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5439, + "end_line": 5485, + "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": 5495, + "end_line": 5548, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5553, + "end_line": 5682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5686, + "end_line": 5794, + "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": 5798, + "end_line": 5838, + "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": 5842, + "end_line": 5980, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5984, + "end_line": 6021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6027, + "end_line": 6103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6108, + "end_line": 6111, + "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": 6118, + "end_line": 6131, + "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": 6177, + "end_line": 6193, + "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": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6206, + "end_line": 6222, + "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": 6228, + "end_line": 6316, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6321, + "end_line": 6349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6362, + "end_line": 6400, + "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": 6408, + "end_line": 6425, + "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": 6430, + "end_line": 6440, + "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": 6443, + "end_line": 6447, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6450, + "end_line": 6453, + "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": 6457, + "end_line": 6507, + "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": 6510, + "end_line": 6564, + "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": 6568, + "end_line": 6701, + "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": 6705, + "end_line": 6737, + "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": 6740, + "end_line": 6782, + "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": 6785, + "end_line": 6919, + "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": 6932, + "end_line": 6977, + "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": 6982, + "end_line": 6986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7055, + "end_line": 7071, + "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": 7078, + "end_line": 7147, + "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": 7151, + "end_line": 7188, + "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": 7194, + "end_line": 7238, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7256, + "end_line": 7384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7390, + "end_line": 7462, + "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": 7465, + "end_line": 7591, + "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": 7595, + "end_line": 7604, + "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": 7675, + "end_line": 7724, + "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": 7727, + "end_line": 7772, + "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": 7775, + "end_line": 7794, + "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": 7797, + "end_line": 7804, + "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": 7807, + "end_line": 7817, + "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": 7820, + "end_line": 7830, + "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": 7833, + "end_line": 7836, + "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": 7839, + "end_line": 7851, + "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": 7881, + "end_line": 7888, + "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": 7947, + "end_line": 7956, + "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": 7974, + "end_line": 7996, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8002, + "end_line": 8012, + "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": 8030, + "end_line": 8038, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8041, + "end_line": 8053, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8056, + "end_line": 8078, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8081, + "end_line": 8100, + "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": 8107, + "end_line": 8114, + "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": 8117, + "end_line": 8124, + "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": 8127, + "end_line": 8134, + "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": 8174, + "end_line": 8226, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8232, + "end_line": 8289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8297, + "end_line": 8339, + "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": 8359, + "end_line": 8425, + "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": 8436, + "end_line": 8444, + "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": 8459, + "end_line": 8504, + "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": 8507, + "end_line": 8516, + "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": 8519, + "end_line": 8529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3332, + "end_line": 3355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3361, + "end_line": 3377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3381, + "end_line": 3397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3400, + "end_line": 3417, + "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": 3420, + "end_line": 3453, + "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": 3460, + "end_line": 3487, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3496, + "end_line": 3511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3531, + "end_line": 3555, + "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": 3561, + "end_line": 3583, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3587, + "end_line": 3629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3637, + "end_line": 3795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3804, + "end_line": 3902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3908, + "end_line": 3925, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3929, + "end_line": 3971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3974, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4097, + "end_line": 4105, + "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": 4111, + "end_line": 4114, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4117, + "end_line": 4121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4124, + "end_line": 4127, + "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": 4131, + "end_line": 4160, + "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": 4164, + "end_line": 4167, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4170, + "end_line": 4208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4212, + "end_line": 4219, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4222, + "end_line": 4230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4234, + "end_line": 4240, + "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": 4243, + "end_line": 4257, + "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": 4260, + "end_line": 4304, + "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": 4308, + "end_line": 4311, + "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": 4314, + "end_line": 4325, + "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": 4328, + "end_line": 4339, + "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": 4345, + "end_line": 4348, + "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": 4351, + "end_line": 4355, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4369, + "end_line": 4454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4457, + "end_line": 4475, + "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": 4478, + "end_line": 4496, + "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": 4499, + "end_line": 4509, + "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": 4513, + "end_line": 4538, + "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": 4542, + "end_line": 4575, + "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": 4578, + "end_line": 4611, + "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": 4614, + "end_line": 4651, + "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": 4654, + "end_line": 4657, + "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": 4660, + "end_line": 4710, + "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": 4800, + "end_line": 4807, + "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": 4909, + "end_line": 4942, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4945, + "end_line": 4967, + "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": 4974, + "end_line": 5000, + "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": 5006, + "end_line": 5038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5050, + "end_line": 5186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5189, + "end_line": 5212, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5217, + "end_line": 5245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5250, + "end_line": 5314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5321, + "end_line": 5330, + "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": 5336, + "end_line": 5429, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5439, + "end_line": 5485, + "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": 5495, + "end_line": 5548, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5553, + "end_line": 5682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5686, + "end_line": 5794, + "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": 5798, + "end_line": 5838, + "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": 5842, + "end_line": 5980, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5984, + "end_line": 6021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6027, + "end_line": 6103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6108, + "end_line": 6111, + "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": 6118, + "end_line": 6131, + "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": 19, + "complexity": 8, + "token_count": 123, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6177, + "end_line": 6196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6209, + "end_line": 6225, + "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": 6231, + "end_line": 6319, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6324, + "end_line": 6352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6365, + "end_line": 6403, + "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": 6411, + "end_line": 6428, + "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": 6433, + "end_line": 6443, + "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": 6446, + "end_line": 6450, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6453, + "end_line": 6456, + "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": 6460, + "end_line": 6510, + "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": 6513, + "end_line": 6567, + "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": 6571, + "end_line": 6704, + "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": 6708, + "end_line": 6740, + "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": 6743, + "end_line": 6785, + "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": 6788, + "end_line": 6922, + "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": 6935, + "end_line": 6980, + "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": 6985, + "end_line": 6989, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7058, + "end_line": 7074, + "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": 7081, + "end_line": 7150, + "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": 7154, + "end_line": 7191, + "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": 7197, + "end_line": 7241, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7259, + "end_line": 7387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7393, + "end_line": 7465, + "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": 7468, + "end_line": 7594, + "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": 7598, + "end_line": 7607, + "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": 7678, + "end_line": 7727, + "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": 7730, + "end_line": 7775, + "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": 7778, + "end_line": 7797, + "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": 7800, + "end_line": 7807, + "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": 7810, + "end_line": 7820, + "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": 7823, + "end_line": 7833, + "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": 7836, + "end_line": 7839, + "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": 7842, + "end_line": 7854, + "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": 7884, + "end_line": 7891, + "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": 7950, + "end_line": 7959, + "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": 7977, + "end_line": 7999, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8005, + "end_line": 8015, + "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": 8033, + "end_line": 8041, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8044, + "end_line": 8056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8059, + "end_line": 8081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8084, + "end_line": 8103, + "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": 8110, + "end_line": 8117, + "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": 8120, + "end_line": 8127, + "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": 8130, + "end_line": 8137, + "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": 8177, + "end_line": 8229, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8235, + "end_line": 8292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8300, + "end_line": 8342, + "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": 8362, + "end_line": 8428, + "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": 8439, + "end_line": 8447, + "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": 8462, + "end_line": 8507, + "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": 8510, + "end_line": 8519, + "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": 8522, + "end_line": 8532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "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": 19, + "complexity": 8, + "token_count": 123, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires", + "context" + ], + "start_line": 6177, + "end_line": 6196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "nloc": 6806, + "complexity": 1456, + "token_count": 40011, + "diff_parsed": { + "added": [], + "deleted": [ + "\tif (requires & ENSURECOPY) {", + "\t\trequires |= DEFAULT_FLAGS;", + "\t}" + ] + } + } + ] + }, + { + "hash": "e45d0eb3dd55af9e1347bf39307be5695c67bd7b", + "msg": "Change License text to NumPy License (permission granted by Pearu)", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T21:59:32+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T21:59:32+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "e966fd194660c6e1a3f560a70415fa986fc84309" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 22, + "insertions": 21, + "lines": 43, + "files": 17, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/f2py/auxfuncs.py", + "new_path": "numpy/f2py/auxfuncs.py", + "filename": "auxfuncs.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,8 @@\n Copyright 1999,2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy (BSD style) LICENSE. \n+\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/07/24 19:01:55 $\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nAuxiliary functions for f2py2e.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy (BSD style) LICENSE. \n\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/07/24 19:01:55 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.65 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,os\nimport cfuncs\n\n\nerrmess=sys.stderr.write\n#outmess=sys.stdout.write\nshow=pprint.pprint\n\noptions={}\ndebugoptions=[]\nwrapfuncs = 1\n\ndef outmess(t):\n if options.get('verbose',1):\n sys.stdout.write(t)\n\ndef debugcapi(var): return 'capi' in debugoptions\ndef _isstring(var):\n return var.has_key('typespec') and var['typespec']=='character' and (not isexternal(var))\ndef isstring(var):\n return _isstring(var) and not isarray(var)\ndef ischaracter(var):\n return isstring(var) and not (var.has_key('charselector'))\ndef isstringarray(var):\n return isarray(var) and _isstring(var)\ndef isarrayofstrings(var):\n # leaving out '*' for now so that\n # `character*(*) a(m)` and `character a(m,*)`\n # are treated differently. Luckily `character**` is illegal.\n return isstringarray(var) and var['dimension'][-1]=='(*)'\ndef isarray(var): return var.has_key('dimension') and (not isexternal(var))\ndef isscalar(var): return not (isarray(var) or isstring(var) or isexternal(var))\ndef iscomplex(var):\n return isscalar(var) and var.get('typespec') in ['complex','double complex']\ndef islogical(var):\n return isscalar(var) and var.get('typespec')=='logical'\ndef isinteger(var):\n return isscalar(var) and var.get('typespec')=='integer'\ndef isreal(var):\n return isscalar(var) and var.get('typespec')=='real'\ndef get_kind(var):\n try: return var['kindselector']['*']\n except KeyError:\n try: return var['kindselector']['kind']\n except KeyError: pass\ndef islong_long(var):\n if not isscalar(var): return 0\n if var.get('typespec') not in ['integer','logical']: return 0\n return get_kind(var)=='8'\ndef isunsigned_char(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-1'\ndef isunsigned_short(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-2'\ndef isunsigned(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-4'\ndef isunsigned_long_long(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-8'\ndef isdouble(var):\n if not isscalar(var): return 0\n if not var.get('typespec')=='real': return 0\n return get_kind(var)=='8'\ndef islong_double(var):\n if not isscalar(var): return 0\n if not var.get('typespec')=='real': return 0\n return get_kind(var)=='16'\ndef islong_complex(var):\n if not iscomplex(var): return 0\n return get_kind(var)=='32'\n\ndef iscomplexarray(var): return isarray(var) and var.get('typespec') in ['complex','double complex']\ndef isint1array(var): return isarray(var) and var.get('typespec')=='integer' \\\n and get_kind(var)=='1'\ndef isunsigned_chararray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-1'\ndef isunsigned_shortarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-2'\ndef isunsignedarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-4'\ndef isunsigned_long_longarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-8'\ndef isallocatable(var):\n return var.has_key('attrspec') and 'allocatable' in var['attrspec']\ndef ismutable(var): return not (not var.has_key('dimension') or isstring(var))\ndef ismoduleroutine(rout): return rout.has_key('modulename')\ndef ismodule(rout): return (rout.has_key('block') and 'module'==rout['block'])\ndef isfunction(rout): return (rout.has_key('block') and 'function'==rout['block'])\n#def isfunction_wrap(rout):\n# return wrapfuncs and (iscomplexfunction(rout) or isstringfunction(rout)) and (not isexternal(rout))\ndef isfunction_wrap(rout):\n if isintent_c(rout): return 0\n return wrapfuncs and isfunction(rout) and (not isexternal(rout))\ndef issubroutine(rout): return (rout.has_key('block') and 'subroutine'==rout['block'])\ndef isroutine(rout): return isfunction(rout) or issubroutine(rout)\ndef islogicalfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islogical(rout['vars'][a])\n return 0\ndef islong_longfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islong_long(rout['vars'][a])\n return 0\ndef islong_doublefunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islong_double(rout['vars'][a])\n return 0\ndef iscomplexfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return iscomplex(rout['vars'][a])\n return 0\ndef iscomplexfunction_warn(rout):\n if iscomplexfunction(rout):\n outmess(\"\"\"\\\n **************************************************************\n Warning: code with a function returning complex value\n may not work correctly with your Fortran compiler.\n Run the following test before using it in your applications:\n $(f2py install dir)/test-site/{b/runme_scalar,e/runme}\n When using GNU gcc/g77 compilers, codes should work correctly.\n **************************************************************\\n\"\"\")\n return 1\n return 0\ndef isstringfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return isstring(rout['vars'][a])\n return 0\ndef hasexternals(rout): return rout.has_key('externals') and rout['externals']\ndef isthreadsafe(rout): return rout.has_key('f2pyenhancements') and rout['f2pyenhancements'].has_key('threadsafe')\ndef hasvariables(rout): return rout.has_key('vars') and rout['vars']\ndef isoptional(var): return (var.has_key('attrspec') and 'optional' in var['attrspec'] and 'required' not in var['attrspec']) and isintent_nothide(var)\ndef isexternal(var): return (var.has_key('attrspec') and 'external' in var['attrspec'])\ndef isrequired(var): return not isoptional(var) and isintent_nothide(var)\ndef isintent_in(var):\n if not var.has_key('intent'): return 1\n if 'hide' in var['intent']: return 0\n if 'inplace' in var['intent']: return 0\n if 'in' in var['intent']: return 1\n if 'out' in var['intent']: return 0\n if 'inout' in var['intent']: return 0\n if 'outin' in var['intent']: return 0\n return 1\ndef isintent_inout(var): return var.has_key('intent') and ('inout' in var['intent'] or 'outin' in var['intent']) and 'in' not in var['intent'] and 'hide' not in var['intent'] and 'inplace' not in var['intent']\ndef isintent_out(var):\n return 'out' in var.get('intent',[])\ndef isintent_hide(var): return (var.has_key('intent') and ('hide' in var['intent'] or ('out' in var['intent'] and 'in' not in var['intent'] and (not l_or(isintent_inout,isintent_inplace)(var)))))\ndef isintent_nothide(var): return not isintent_hide(var)\ndef isintent_c(var):\n return 'c' in var.get('intent',[])\n# def isintent_f(var):\n# return not isintent_c(var)\ndef isintent_cache(var):\n return 'cache' in var.get('intent',[])\ndef isintent_copy(var):\n return 'copy' in var.get('intent',[])\ndef isintent_overwrite(var):\n return 'overwrite' in var.get('intent',[])\ndef isintent_callback(var):\n return 'callback' in var.get('intent',[])\ndef isintent_inplace(var):\n return 'inplace' in var.get('intent',[])\ndef isintent_aux(var):\n return 'aux' in var.get('intent',[])\n\nisintent_dict = {isintent_in:'INTENT_IN',isintent_inout:'INTENT_INOUT',\n isintent_out:'INTENT_OUT',isintent_hide:'INTENT_HIDE',\n isintent_cache:'INTENT_CACHE',\n isintent_c:'INTENT_C',isoptional:'OPTIONAL',\n isintent_inplace:'INTENT_INPLACE'\n }\n\ndef isprivate(var):\n return var.has_key('attrspec') and 'private' in var['attrspec']\n\ndef hasinitvalue(var): return var.has_key('=')\ndef hasinitvalueasstring(var):\n if not hasinitvalue(var): return 0\n return var['='][0] in ['\"',\"'\"]\ndef hasnote(var):\n return var.has_key('note')\ndef hasresultnote(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return hasnote(rout['vars'][a])\n return 0\ndef hascommon(rout):\n return rout.has_key('common')\ndef containscommon(rout):\n if hascommon(rout): return 1\n if hasbody(rout):\n for b in rout['body']:\n if containscommon(b): return 1\n return 0\ndef containsmodule(block):\n if ismodule(block): return 1\n if not hasbody(block): return 0\n ret = []\n for b in block['body']:\n if containsmodule(b): return 1\n return 0\ndef hasbody(rout):\n return rout.has_key('body')\ndef hascallstatement(rout):\n return getcallstatement(rout) is not None\n\ndef istrue(var): return 1\ndef isfalse(var): return 0\n\nclass F2PYError(Exception):\n pass\n\nclass throw_error:\n def __init__(self,mess):\n self.mess = mess\n def __call__(self,var):\n mess = '\\n\\n var = %s\\n Message: %s\\n' % (var,self.mess)\n raise F2PYError,mess\n\ndef l_and(*f):\n l,l2='lambda v',[]\n for i in range(len(f)):\n l='%s,f%d=f[%d]'%(l,i,i)\n l2.append('f%d(v)'%(i))\n return eval('%s:%s'%(l,string.join(l2,' and ')))\ndef l_or(*f):\n l,l2='lambda v',[]\n for i in range(len(f)):\n l='%s,f%d=f[%d]'%(l,i,i)\n l2.append('f%d(v)'%(i))\n return eval('%s:%s'%(l,string.join(l2,' or ')))\ndef l_not(f):\n return eval('lambda v,f=f:not f(v)')\n\ndef isdummyroutine(rout):\n try:\n return rout['f2pyenhancements']['fortranname']==''\n except KeyError:\n return 0\n\ndef getfortranname(rout):\n try:\n name = rout['f2pyenhancements']['fortranname']\n if name=='':\n raise KeyError\n if not name:\n errmess('Failed to use fortranname from %s\\n'%(rout['f2pyenhancements']))\n raise KeyError\n except KeyError:\n name = rout['name']\n return name\n\ndef getmultilineblock(rout,blockname,comment=1,counter=0):\n try:\n r = rout['f2pyenhancements'].get(blockname)\n except KeyError:\n return\n if not r: return\n if counter>0 and type(r) is type(''):\n return\n if type(r) is type([]):\n if counter>=len(r): return\n r = r[counter]\n if r[:3]==\"'''\":\n if comment:\n r = '\\t/* start ' + blockname + ' multiline ('+`counter`+') */\\n' + r[3:]\n else:\n r = r[3:]\n if r[-3:]==\"'''\":\n if comment:\n r = r[:-3] + '\\n\\t/* end multiline ('+`counter`+')*/'\n else:\n r = r[:-3]\n else:\n errmess(\"%s multiline block should end with `'''`: %s\\n\" \\\n % (blockname,repr(r)))\n return r\n\ndef getcallstatement(rout):\n return getmultilineblock(rout,'callstatement')\n\ndef getcallprotoargument(rout,cb_map={}):\n r = getmultilineblock(rout,'callprotoargument',comment=0)\n if r: return r\n if hascallstatement(rout):\n outmess('warning: callstatement is defined without callprotoargument\\n')\n return\n from capi_maps import getctype\n arg_types,arg_types2 = [],[]\n if l_and(isstringfunction,l_not(isfunction_wrap))(rout):\n arg_types.extend(['char*','size_t'])\n for n in rout['args']:\n var = rout['vars'][n]\n if isintent_callback(var):\n continue\n if cb_map.has_key(n):\n ctype = cb_map[n]+'_typedef'\n else:\n ctype = getctype(var)\n if l_and(isintent_c,l_or(isscalar,iscomplex))(var):\n pass\n elif isstring(var):\n pass\n #ctype = 'void*'\n else:\n ctype = ctype+'*'\n if isstring(var) or isarrayofstrings(var):\n arg_types2.append('size_t')\n arg_types.append(ctype)\n\n proto_args = string.join(arg_types+arg_types2,',')\n if not proto_args:\n proto_args = 'void'\n #print proto_args\n return proto_args\n\ndef getusercode(rout):\n return getmultilineblock(rout,'usercode')\ndef getusercode1(rout):\n return getmultilineblock(rout,'usercode',counter=1)\n\ndef getpymethoddef(rout):\n return getmultilineblock(rout,'pymethoddef')\n\ndef getargs(rout):\n sortargs,args=[],[]\n if rout.has_key('args'):\n args=rout['args']\n if rout.has_key('sortvars'):\n for a in rout['sortvars']:\n if a in args: sortargs.append(a)\n for a in args:\n if a not in sortargs:\n sortargs.append(a)\n else: sortargs=rout['args']\n return args,sortargs\n\ndef getargs2(rout):\n sortargs,args=[],rout.get('args',[])\n auxvars = [a for a in rout['vars'].keys() if isintent_aux(rout['vars'][a])\\\n and a not in args]\n args = auxvars + args\n if rout.has_key('sortvars'):\n for a in rout['sortvars']:\n if a in args: sortargs.append(a)\n for a in args:\n if a not in sortargs:\n sortargs.append(a)\n else: sortargs=auxvars + rout['args']\n return args,sortargs\n\ndef getrestdoc(rout):\n if not rout.has_key('f2pymultilines'):\n return None\n k = None\n if rout['block']=='python module':\n k = rout['block'],rout['name']\n return rout['f2pymultilines'].get(k,None)\n\ndef gentitle(name):\n l=(80-len(name)-6)/2\n return '/*%s %s %s*/'%(l*'*',name,l*'*')\ndef flatlist(l):\n if type(l)==types.ListType:\n return reduce(lambda x,y,f=flatlist:x+f(y),l,[])\n return [l]\ndef stripcomma(s):\n if s and s[-1]==',': return s[:-1]\n return s\ndef replace(str,dict,defaultsep=''):\n if type(dict)==types.ListType:\n return map(lambda d,f=replace,sep=defaultsep,s=str:f(s,d,sep),dict)\n if type(str)==types.ListType:\n return map(lambda s,f=replace,sep=defaultsep,d=dict:f(s,d,sep),str)\n for k in 2*dict.keys():\n if k=='separatorsfor': continue\n if dict.has_key('separatorsfor') and dict['separatorsfor'].has_key(k):\n sep=dict['separatorsfor'][k]\n else:\n sep=defaultsep\n if type(dict[k])==types.ListType:\n str=string.replace(str,'#%s#'%(k),string.join(flatlist(dict[k]),sep))\n else:\n str=string.replace(str,'#%s#'%(k),dict[k])\n return str\n\ndef dictappend(rd,ar):\n if type(ar)==types.ListType:\n for a in ar: rd=dictappend(rd,a)\n return rd\n for k in ar.keys():\n if k[0]=='_': continue\n if rd.has_key(k):\n if type(rd[k])==types.StringType: rd[k]=[rd[k]]\n if type(rd[k])==types.ListType:\n if type(ar[k])==types.ListType: rd[k]=rd[k]+ar[k]\n else: rd[k].append(ar[k])\n elif type(rd[k])==types.DictType:\n if type(ar[k])==types.DictType:\n if k=='separatorsfor':\n for k1 in ar[k].keys():\n if not rd[k].has_key(k1): rd[k][k1]=ar[k][k1]\n else: rd[k]=dictappend(rd[k],ar[k])\n else: rd[k]=ar[k]\n return rd\n\ndef applyrules(rules,dict,var={}):\n ret={}\n if type(rules)==types.ListType:\n for r in rules:\n rr=applyrules(r,dict,var)\n ret=dictappend(ret,rr)\n if rr.has_key('_break'): break\n return ret\n if rules.has_key('_check') and (not rules['_check'](var)): return ret\n if rules.has_key('need'):\n res = applyrules({'needs':rules['need']},dict,var)\n if res.has_key('needs'):\n cfuncs.append_needs(res['needs'])\n\n for k in rules.keys():\n if k=='separatorsfor': ret[k]=rules[k]; continue\n if type(rules[k])==types.StringType:\n ret[k]=replace(rules[k],dict)\n elif type(rules[k])==types.ListType:\n ret[k]=[]\n for i in rules[k]:\n ar=applyrules({k:i},dict,var)\n if ar.has_key(k): ret[k].append(ar[k])\n elif k[0]=='_':\n continue\n elif type(rules[k])==types.DictType:\n ret[k]=[]\n for k1 in rules[k].keys():\n if type(k1)==types.FunctionType and k1(var):\n if type(rules[k][k1])==types.ListType:\n for i in rules[k][k1]:\n if type(i)==types.DictType:\n res=applyrules({'supertext':i},dict,var)\n if res.has_key('supertext'): i=res['supertext']\n else: i=''\n ret[k].append(replace(i,dict))\n else:\n i=rules[k][k1]\n if type(i)==types.DictType:\n res=applyrules({'supertext':i},dict)\n if res.has_key('supertext'): i=res['supertext']\n else: i=''\n ret[k].append(replace(i,dict))\n else:\n errmess('applyrules: ignoring rule %s.\\n'%`rules[k]`)\n if type(ret[k])==types.ListType:\n if len(ret[k])==1: ret[k]=ret[k][0]\n if ret[k]==[]: del ret[k]\n return ret\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nAuxiliary functions for f2py2e.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/07/24 19:01:55 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.65 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,os\nimport cfuncs\n\n\nerrmess=sys.stderr.write\n#outmess=sys.stdout.write\nshow=pprint.pprint\n\noptions={}\ndebugoptions=[]\nwrapfuncs = 1\n\ndef outmess(t):\n if options.get('verbose',1):\n sys.stdout.write(t)\n\ndef debugcapi(var): return 'capi' in debugoptions\ndef _isstring(var):\n return var.has_key('typespec') and var['typespec']=='character' and (not isexternal(var))\ndef isstring(var):\n return _isstring(var) and not isarray(var)\ndef ischaracter(var):\n return isstring(var) and not (var.has_key('charselector'))\ndef isstringarray(var):\n return isarray(var) and _isstring(var)\ndef isarrayofstrings(var):\n # leaving out '*' for now so that\n # `character*(*) a(m)` and `character a(m,*)`\n # are treated differently. Luckily `character**` is illegal.\n return isstringarray(var) and var['dimension'][-1]=='(*)'\ndef isarray(var): return var.has_key('dimension') and (not isexternal(var))\ndef isscalar(var): return not (isarray(var) or isstring(var) or isexternal(var))\ndef iscomplex(var):\n return isscalar(var) and var.get('typespec') in ['complex','double complex']\ndef islogical(var):\n return isscalar(var) and var.get('typespec')=='logical'\ndef isinteger(var):\n return isscalar(var) and var.get('typespec')=='integer'\ndef isreal(var):\n return isscalar(var) and var.get('typespec')=='real'\ndef get_kind(var):\n try: return var['kindselector']['*']\n except KeyError:\n try: return var['kindselector']['kind']\n except KeyError: pass\ndef islong_long(var):\n if not isscalar(var): return 0\n if var.get('typespec') not in ['integer','logical']: return 0\n return get_kind(var)=='8'\ndef isunsigned_char(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-1'\ndef isunsigned_short(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-2'\ndef isunsigned(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-4'\ndef isunsigned_long_long(var):\n if not isscalar(var): return 0\n if var.get('typespec') != 'integer': return 0\n return get_kind(var)=='-8'\ndef isdouble(var):\n if not isscalar(var): return 0\n if not var.get('typespec')=='real': return 0\n return get_kind(var)=='8'\ndef islong_double(var):\n if not isscalar(var): return 0\n if not var.get('typespec')=='real': return 0\n return get_kind(var)=='16'\ndef islong_complex(var):\n if not iscomplex(var): return 0\n return get_kind(var)=='32'\n\ndef iscomplexarray(var): return isarray(var) and var.get('typespec') in ['complex','double complex']\ndef isint1array(var): return isarray(var) and var.get('typespec')=='integer' \\\n and get_kind(var)=='1'\ndef isunsigned_chararray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-1'\ndef isunsigned_shortarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-2'\ndef isunsignedarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-4'\ndef isunsigned_long_longarray(var): return isarray(var) and var.get('typespec')=='integer' and get_kind(var)=='-8'\ndef isallocatable(var):\n return var.has_key('attrspec') and 'allocatable' in var['attrspec']\ndef ismutable(var): return not (not var.has_key('dimension') or isstring(var))\ndef ismoduleroutine(rout): return rout.has_key('modulename')\ndef ismodule(rout): return (rout.has_key('block') and 'module'==rout['block'])\ndef isfunction(rout): return (rout.has_key('block') and 'function'==rout['block'])\n#def isfunction_wrap(rout):\n# return wrapfuncs and (iscomplexfunction(rout) or isstringfunction(rout)) and (not isexternal(rout))\ndef isfunction_wrap(rout):\n if isintent_c(rout): return 0\n return wrapfuncs and isfunction(rout) and (not isexternal(rout))\ndef issubroutine(rout): return (rout.has_key('block') and 'subroutine'==rout['block'])\ndef isroutine(rout): return isfunction(rout) or issubroutine(rout)\ndef islogicalfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islogical(rout['vars'][a])\n return 0\ndef islong_longfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islong_long(rout['vars'][a])\n return 0\ndef islong_doublefunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return islong_double(rout['vars'][a])\n return 0\ndef iscomplexfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return iscomplex(rout['vars'][a])\n return 0\ndef iscomplexfunction_warn(rout):\n if iscomplexfunction(rout):\n outmess(\"\"\"\\\n **************************************************************\n Warning: code with a function returning complex value\n may not work correctly with your Fortran compiler.\n Run the following test before using it in your applications:\n $(f2py install dir)/test-site/{b/runme_scalar,e/runme}\n When using GNU gcc/g77 compilers, codes should work correctly.\n **************************************************************\\n\"\"\")\n return 1\n return 0\ndef isstringfunction(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return isstring(rout['vars'][a])\n return 0\ndef hasexternals(rout): return rout.has_key('externals') and rout['externals']\ndef isthreadsafe(rout): return rout.has_key('f2pyenhancements') and rout['f2pyenhancements'].has_key('threadsafe')\ndef hasvariables(rout): return rout.has_key('vars') and rout['vars']\ndef isoptional(var): return (var.has_key('attrspec') and 'optional' in var['attrspec'] and 'required' not in var['attrspec']) and isintent_nothide(var)\ndef isexternal(var): return (var.has_key('attrspec') and 'external' in var['attrspec'])\ndef isrequired(var): return not isoptional(var) and isintent_nothide(var)\ndef isintent_in(var):\n if not var.has_key('intent'): return 1\n if 'hide' in var['intent']: return 0\n if 'inplace' in var['intent']: return 0\n if 'in' in var['intent']: return 1\n if 'out' in var['intent']: return 0\n if 'inout' in var['intent']: return 0\n if 'outin' in var['intent']: return 0\n return 1\ndef isintent_inout(var): return var.has_key('intent') and ('inout' in var['intent'] or 'outin' in var['intent']) and 'in' not in var['intent'] and 'hide' not in var['intent'] and 'inplace' not in var['intent']\ndef isintent_out(var):\n return 'out' in var.get('intent',[])\ndef isintent_hide(var): return (var.has_key('intent') and ('hide' in var['intent'] or ('out' in var['intent'] and 'in' not in var['intent'] and (not l_or(isintent_inout,isintent_inplace)(var)))))\ndef isintent_nothide(var): return not isintent_hide(var)\ndef isintent_c(var):\n return 'c' in var.get('intent',[])\n# def isintent_f(var):\n# return not isintent_c(var)\ndef isintent_cache(var):\n return 'cache' in var.get('intent',[])\ndef isintent_copy(var):\n return 'copy' in var.get('intent',[])\ndef isintent_overwrite(var):\n return 'overwrite' in var.get('intent',[])\ndef isintent_callback(var):\n return 'callback' in var.get('intent',[])\ndef isintent_inplace(var):\n return 'inplace' in var.get('intent',[])\ndef isintent_aux(var):\n return 'aux' in var.get('intent',[])\n\nisintent_dict = {isintent_in:'INTENT_IN',isintent_inout:'INTENT_INOUT',\n isintent_out:'INTENT_OUT',isintent_hide:'INTENT_HIDE',\n isintent_cache:'INTENT_CACHE',\n isintent_c:'INTENT_C',isoptional:'OPTIONAL',\n isintent_inplace:'INTENT_INPLACE'\n }\n\ndef isprivate(var):\n return var.has_key('attrspec') and 'private' in var['attrspec']\n\ndef hasinitvalue(var): return var.has_key('=')\ndef hasinitvalueasstring(var):\n if not hasinitvalue(var): return 0\n return var['='][0] in ['\"',\"'\"]\ndef hasnote(var):\n return var.has_key('note')\ndef hasresultnote(rout):\n if not isfunction(rout): return 0\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if rout['vars'].has_key(a): return hasnote(rout['vars'][a])\n return 0\ndef hascommon(rout):\n return rout.has_key('common')\ndef containscommon(rout):\n if hascommon(rout): return 1\n if hasbody(rout):\n for b in rout['body']:\n if containscommon(b): return 1\n return 0\ndef containsmodule(block):\n if ismodule(block): return 1\n if not hasbody(block): return 0\n ret = []\n for b in block['body']:\n if containsmodule(b): return 1\n return 0\ndef hasbody(rout):\n return rout.has_key('body')\ndef hascallstatement(rout):\n return getcallstatement(rout) is not None\n\ndef istrue(var): return 1\ndef isfalse(var): return 0\n\nclass F2PYError(Exception):\n pass\n\nclass throw_error:\n def __init__(self,mess):\n self.mess = mess\n def __call__(self,var):\n mess = '\\n\\n var = %s\\n Message: %s\\n' % (var,self.mess)\n raise F2PYError,mess\n\ndef l_and(*f):\n l,l2='lambda v',[]\n for i in range(len(f)):\n l='%s,f%d=f[%d]'%(l,i,i)\n l2.append('f%d(v)'%(i))\n return eval('%s:%s'%(l,string.join(l2,' and ')))\ndef l_or(*f):\n l,l2='lambda v',[]\n for i in range(len(f)):\n l='%s,f%d=f[%d]'%(l,i,i)\n l2.append('f%d(v)'%(i))\n return eval('%s:%s'%(l,string.join(l2,' or ')))\ndef l_not(f):\n return eval('lambda v,f=f:not f(v)')\n\ndef isdummyroutine(rout):\n try:\n return rout['f2pyenhancements']['fortranname']==''\n except KeyError:\n return 0\n\ndef getfortranname(rout):\n try:\n name = rout['f2pyenhancements']['fortranname']\n if name=='':\n raise KeyError\n if not name:\n errmess('Failed to use fortranname from %s\\n'%(rout['f2pyenhancements']))\n raise KeyError\n except KeyError:\n name = rout['name']\n return name\n\ndef getmultilineblock(rout,blockname,comment=1,counter=0):\n try:\n r = rout['f2pyenhancements'].get(blockname)\n except KeyError:\n return\n if not r: return\n if counter>0 and type(r) is type(''):\n return\n if type(r) is type([]):\n if counter>=len(r): return\n r = r[counter]\n if r[:3]==\"'''\":\n if comment:\n r = '\\t/* start ' + blockname + ' multiline ('+`counter`+') */\\n' + r[3:]\n else:\n r = r[3:]\n if r[-3:]==\"'''\":\n if comment:\n r = r[:-3] + '\\n\\t/* end multiline ('+`counter`+')*/'\n else:\n r = r[:-3]\n else:\n errmess(\"%s multiline block should end with `'''`: %s\\n\" \\\n % (blockname,repr(r)))\n return r\n\ndef getcallstatement(rout):\n return getmultilineblock(rout,'callstatement')\n\ndef getcallprotoargument(rout,cb_map={}):\n r = getmultilineblock(rout,'callprotoargument',comment=0)\n if r: return r\n if hascallstatement(rout):\n outmess('warning: callstatement is defined without callprotoargument\\n')\n return\n from capi_maps import getctype\n arg_types,arg_types2 = [],[]\n if l_and(isstringfunction,l_not(isfunction_wrap))(rout):\n arg_types.extend(['char*','size_t'])\n for n in rout['args']:\n var = rout['vars'][n]\n if isintent_callback(var):\n continue\n if cb_map.has_key(n):\n ctype = cb_map[n]+'_typedef'\n else:\n ctype = getctype(var)\n if l_and(isintent_c,l_or(isscalar,iscomplex))(var):\n pass\n elif isstring(var):\n pass\n #ctype = 'void*'\n else:\n ctype = ctype+'*'\n if isstring(var) or isarrayofstrings(var):\n arg_types2.append('size_t')\n arg_types.append(ctype)\n\n proto_args = string.join(arg_types+arg_types2,',')\n if not proto_args:\n proto_args = 'void'\n #print proto_args\n return proto_args\n\ndef getusercode(rout):\n return getmultilineblock(rout,'usercode')\ndef getusercode1(rout):\n return getmultilineblock(rout,'usercode',counter=1)\n\ndef getpymethoddef(rout):\n return getmultilineblock(rout,'pymethoddef')\n\ndef getargs(rout):\n sortargs,args=[],[]\n if rout.has_key('args'):\n args=rout['args']\n if rout.has_key('sortvars'):\n for a in rout['sortvars']:\n if a in args: sortargs.append(a)\n for a in args:\n if a not in sortargs:\n sortargs.append(a)\n else: sortargs=rout['args']\n return args,sortargs\n\ndef getargs2(rout):\n sortargs,args=[],rout.get('args',[])\n auxvars = [a for a in rout['vars'].keys() if isintent_aux(rout['vars'][a])\\\n and a not in args]\n args = auxvars + args\n if rout.has_key('sortvars'):\n for a in rout['sortvars']:\n if a in args: sortargs.append(a)\n for a in args:\n if a not in sortargs:\n sortargs.append(a)\n else: sortargs=auxvars + rout['args']\n return args,sortargs\n\ndef getrestdoc(rout):\n if not rout.has_key('f2pymultilines'):\n return None\n k = None\n if rout['block']=='python module':\n k = rout['block'],rout['name']\n return rout['f2pymultilines'].get(k,None)\n\ndef gentitle(name):\n l=(80-len(name)-6)/2\n return '/*%s %s %s*/'%(l*'*',name,l*'*')\ndef flatlist(l):\n if type(l)==types.ListType:\n return reduce(lambda x,y,f=flatlist:x+f(y),l,[])\n return [l]\ndef stripcomma(s):\n if s and s[-1]==',': return s[:-1]\n return s\ndef replace(str,dict,defaultsep=''):\n if type(dict)==types.ListType:\n return map(lambda d,f=replace,sep=defaultsep,s=str:f(s,d,sep),dict)\n if type(str)==types.ListType:\n return map(lambda s,f=replace,sep=defaultsep,d=dict:f(s,d,sep),str)\n for k in 2*dict.keys():\n if k=='separatorsfor': continue\n if dict.has_key('separatorsfor') and dict['separatorsfor'].has_key(k):\n sep=dict['separatorsfor'][k]\n else:\n sep=defaultsep\n if type(dict[k])==types.ListType:\n str=string.replace(str,'#%s#'%(k),string.join(flatlist(dict[k]),sep))\n else:\n str=string.replace(str,'#%s#'%(k),dict[k])\n return str\n\ndef dictappend(rd,ar):\n if type(ar)==types.ListType:\n for a in ar: rd=dictappend(rd,a)\n return rd\n for k in ar.keys():\n if k[0]=='_': continue\n if rd.has_key(k):\n if type(rd[k])==types.StringType: rd[k]=[rd[k]]\n if type(rd[k])==types.ListType:\n if type(ar[k])==types.ListType: rd[k]=rd[k]+ar[k]\n else: rd[k].append(ar[k])\n elif type(rd[k])==types.DictType:\n if type(ar[k])==types.DictType:\n if k=='separatorsfor':\n for k1 in ar[k].keys():\n if not rd[k].has_key(k1): rd[k][k1]=ar[k][k1]\n else: rd[k]=dictappend(rd[k],ar[k])\n else: rd[k]=ar[k]\n return rd\n\ndef applyrules(rules,dict,var={}):\n ret={}\n if type(rules)==types.ListType:\n for r in rules:\n rr=applyrules(r,dict,var)\n ret=dictappend(ret,rr)\n if rr.has_key('_break'): break\n return ret\n if rules.has_key('_check') and (not rules['_check'](var)): return ret\n if rules.has_key('need'):\n res = applyrules({'needs':rules['need']},dict,var)\n if res.has_key('needs'):\n cfuncs.append_needs(res['needs'])\n\n for k in rules.keys():\n if k=='separatorsfor': ret[k]=rules[k]; continue\n if type(rules[k])==types.StringType:\n ret[k]=replace(rules[k],dict)\n elif type(rules[k])==types.ListType:\n ret[k]=[]\n for i in rules[k]:\n ar=applyrules({k:i},dict,var)\n if ar.has_key(k): ret[k].append(ar[k])\n elif k[0]=='_':\n continue\n elif type(rules[k])==types.DictType:\n ret[k]=[]\n for k1 in rules[k].keys():\n if type(k1)==types.FunctionType and k1(var):\n if type(rules[k][k1])==types.ListType:\n for i in rules[k][k1]:\n if type(i)==types.DictType:\n res=applyrules({'supertext':i},dict,var)\n if res.has_key('supertext'): i=res['supertext']\n else: i=''\n ret[k].append(replace(i,dict))\n else:\n i=rules[k][k1]\n if type(i)==types.DictType:\n res=applyrules({'supertext':i},dict)\n if res.has_key('supertext'): i=res['supertext']\n else: i=''\n ret[k].append(replace(i,dict))\n else:\n errmess('applyrules: ignoring rule %s.\\n'%`rules[k]`)\n if type(ret[k])==types.ListType:\n if len(ret[k])==1: ret[k]=ret[k][0]\n if ret[k]==[]: del ret[k]\n return ret\n\n\n", + "methods": [ + { + "name": "outmess", + "long_name": "outmess( t )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "t" + ], + "start_line": 34, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_isstring", + "long_name": "_isstring( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 3, + "token_count": 27, + "parameters": [ + "var" + ], + "start_line": 39, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isstring", + "long_name": "isstring( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 16, + "parameters": [ + "var" + ], + "start_line": 41, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "ischaracter", + "long_name": "ischaracter( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 20, + "parameters": [ + "var" + ], + "start_line": 43, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isstringarray", + "long_name": "isstringarray( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 15, + "parameters": [ + "var" + ], + "start_line": 45, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isarrayofstrings", + "long_name": "isarrayofstrings( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 21, + "parameters": [ + "var" + ], + "start_line": 47, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iscomplex", + "long_name": "iscomplex( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 23, + "parameters": [ + "var" + ], + "start_line": 54, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "islogical", + "long_name": "islogical( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 56, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isinteger", + "long_name": "isinteger( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 58, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isreal", + "long_name": "isreal( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 60, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_kind", + "long_name": "get_kind( var )", + "filename": "auxfuncs.py", + "nloc": 5, + "complexity": 3, + "token_count": 32, + "parameters": [ + "var" + ], + "start_line": 62, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "islong_long", + "long_name": "islong_long( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 38, + "parameters": [ + "var" + ], + "start_line": 67, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_char", + "long_name": "isunsigned_char( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 71, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_short", + "long_name": "isunsigned_short( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 75, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned", + "long_name": "isunsigned( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 79, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_long_long", + "long_name": "isunsigned_long_long( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 83, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isdouble", + "long_name": "isdouble( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 34, + "parameters": [ + "var" + ], + "start_line": 87, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "islong_double", + "long_name": "islong_double( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 34, + "parameters": [ + "var" + ], + "start_line": 91, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "islong_complex", + "long_name": "islong_complex( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "var" + ], + "start_line": 95, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "isallocatable", + "long_name": "isallocatable( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isfunction_wrap", + "long_name": "isfunction_wrap( rout )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 4, + "token_count": 28, + "parameters": [ + "rout" + ], + "start_line": 114, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "islogicalfunction", + "long_name": "islogicalfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 119, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "islong_longfunction", + "long_name": "islong_longfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 125, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "islong_doublefunction", + "long_name": "islong_doublefunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 131, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "iscomplexfunction", + "long_name": "iscomplexfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 137, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "iscomplexfunction_warn", + "long_name": "iscomplexfunction_warn( rout )", + "filename": "auxfuncs.py", + "nloc": 12, + "complexity": 2, + "token_count": 19, + "parameters": [ + "rout" + ], + "start_line": 143, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "isstringfunction", + "long_name": "isstringfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 155, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "isintent_in", + "long_name": "isintent_in( var )", + "filename": "auxfuncs.py", + "nloc": 9, + "complexity": 8, + "token_count": 78, + "parameters": [ + "var" + ], + "start_line": 167, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isintent_out", + "long_name": "isintent_out( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 177, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_c", + "long_name": "isintent_c( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 181, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_cache", + "long_name": "isintent_cache( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 185, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_copy", + "long_name": "isintent_copy( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_overwrite", + "long_name": "isintent_overwrite( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_callback", + "long_name": "isintent_callback( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 191, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_inplace", + "long_name": "isintent_inplace( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 193, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_aux", + "long_name": "isintent_aux( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 195, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isprivate", + "long_name": "isprivate( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 205, + "end_line": 206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hasinitvalueasstring", + "long_name": "hasinitvalueasstring( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 28, + "parameters": [ + "var" + ], + "start_line": 209, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "hasnote", + "long_name": "hasnote( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "var" + ], + "start_line": 212, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hasresultnote", + "long_name": "hasresultnote( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 214, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "hascommon", + "long_name": "hascommon( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 220, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "containscommon", + "long_name": "containscommon( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 5, + "token_count": 37, + "parameters": [ + "rout" + ], + "start_line": 222, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "containsmodule", + "long_name": "containsmodule( block )", + "filename": "auxfuncs.py", + "nloc": 7, + "complexity": 5, + "token_count": 44, + "parameters": [ + "block" + ], + "start_line": 228, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "hasbody", + "long_name": "hasbody( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 235, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hascallstatement", + "long_name": "hascallstatement( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "rout" + ], + "start_line": 237, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isfalse", + "long_name": "isfalse( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 14, + "parameters": [ + "var" + ], + "start_line": 241, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , mess )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "mess" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "var" + ], + "start_line": 249, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "l_and", + "long_name": "l_and( * f )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 2, + "token_count": 64, + "parameters": [ + "f" + ], + "start_line": 253, + "end_line": 258, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "l_or", + "long_name": "l_or( * f )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 2, + "token_count": 64, + "parameters": [ + "f" + ], + "start_line": 259, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "l_not", + "long_name": "l_not( f )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "f" + ], + "start_line": 265, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isdummyroutine", + "long_name": "isdummyroutine( rout )", + "filename": "auxfuncs.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "rout" + ], + "start_line": 268, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "getfortranname", + "long_name": "getfortranname( rout )", + "filename": "auxfuncs.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [ + "rout" + ], + "start_line": 274, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "getmultilineblock", + "long_name": "getmultilineblock( rout , blockname , comment = 1 , counter = 0 )", + "filename": "auxfuncs.py", + "nloc": 25, + "complexity": 11, + "token_count": 177, + "parameters": [ + "rout", + "blockname", + "comment", + "counter" + ], + "start_line": 286, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "getcallstatement", + "long_name": "getcallstatement( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 312, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getcallprotoargument", + "long_name": "getcallprotoargument( rout , cb_map = { } )", + "filename": "auxfuncs.py", + "nloc": 31, + "complexity": 12, + "token_count": 198, + "parameters": [ + "rout", + "cb_map" + ], + "start_line": 315, + "end_line": 348, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "getusercode", + "long_name": "getusercode( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 350, + "end_line": 351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getusercode1", + "long_name": "getusercode1( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "rout" + ], + "start_line": 352, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getpymethoddef", + "long_name": "getpymethoddef( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 355, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getargs", + "long_name": "getargs( rout )", + "filename": "auxfuncs.py", + "nloc": 12, + "complexity": 7, + "token_count": 84, + "parameters": [ + "rout" + ], + "start_line": 358, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "getargs2", + "long_name": "getargs2( rout )", + "filename": "auxfuncs.py", + "nloc": 13, + "complexity": 9, + "token_count": 117, + "parameters": [ + "rout" + ], + "start_line": 371, + "end_line": 383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "getrestdoc", + "long_name": "getrestdoc( rout )", + "filename": "auxfuncs.py", + "nloc": 7, + "complexity": 3, + "token_count": 50, + "parameters": [ + "rout" + ], + "start_line": 385, + "end_line": 391, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "gentitle", + "long_name": "gentitle( name )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "name" + ], + "start_line": 393, + "end_line": 395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "flatlist", + "long_name": "flatlist( l )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 2, + "token_count": 43, + "parameters": [ + "l" + ], + "start_line": 396, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "stripcomma", + "long_name": "stripcomma( s )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 3, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 400, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "replace", + "long_name": "replace( str , dict , defaultsep = '' )", + "filename": "auxfuncs.py", + "nloc": 16, + "complexity": 8, + "token_count": 203, + "parameters": [ + "str", + "dict", + "defaultsep" + ], + "start_line": 403, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "dictappend", + "long_name": "dictappend( rd , ar )", + "filename": "auxfuncs.py", + "nloc": 19, + "complexity": 14, + "token_count": 238, + "parameters": [ + "rd", + "ar" + ], + "start_line": 420, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "applyrules", + "long_name": "applyrules( rules , dict , var = { } )", + "filename": "auxfuncs.py", + "nloc": 48, + "complexity": 28, + "token_count": 508, + "parameters": [ + "rules", + "dict", + "var" + ], + "start_line": 440, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "outmess", + "long_name": "outmess( t )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "t" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_isstring", + "long_name": "_isstring( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 3, + "token_count": 27, + "parameters": [ + "var" + ], + "start_line": 38, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isstring", + "long_name": "isstring( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 16, + "parameters": [ + "var" + ], + "start_line": 40, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "ischaracter", + "long_name": "ischaracter( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 20, + "parameters": [ + "var" + ], + "start_line": 42, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isstringarray", + "long_name": "isstringarray( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 15, + "parameters": [ + "var" + ], + "start_line": 44, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isarrayofstrings", + "long_name": "isarrayofstrings( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 21, + "parameters": [ + "var" + ], + "start_line": 46, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iscomplex", + "long_name": "iscomplex( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 23, + "parameters": [ + "var" + ], + "start_line": 53, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "islogical", + "long_name": "islogical( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 55, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isinteger", + "long_name": "isinteger( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 57, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isreal", + "long_name": "isreal( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 59, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_kind", + "long_name": "get_kind( var )", + "filename": "auxfuncs.py", + "nloc": 5, + "complexity": 3, + "token_count": 32, + "parameters": [ + "var" + ], + "start_line": 61, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "islong_long", + "long_name": "islong_long( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 38, + "parameters": [ + "var" + ], + "start_line": 66, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_char", + "long_name": "isunsigned_char( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 70, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_short", + "long_name": "isunsigned_short( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 74, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned", + "long_name": "isunsigned( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 78, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isunsigned_long_long", + "long_name": "isunsigned_long_long( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 33, + "parameters": [ + "var" + ], + "start_line": 82, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isdouble", + "long_name": "isdouble( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 34, + "parameters": [ + "var" + ], + "start_line": 86, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "islong_double", + "long_name": "islong_double( var )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 3, + "token_count": 34, + "parameters": [ + "var" + ], + "start_line": 90, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "islong_complex", + "long_name": "islong_complex( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "var" + ], + "start_line": 94, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "isallocatable", + "long_name": "isallocatable( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 105, + "end_line": 106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isfunction_wrap", + "long_name": "isfunction_wrap( rout )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 4, + "token_count": 28, + "parameters": [ + "rout" + ], + "start_line": 113, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "islogicalfunction", + "long_name": "islogicalfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 118, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "islong_longfunction", + "long_name": "islong_longfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 124, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "islong_doublefunction", + "long_name": "islong_doublefunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 130, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "iscomplexfunction", + "long_name": "iscomplexfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 136, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "iscomplexfunction_warn", + "long_name": "iscomplexfunction_warn( rout )", + "filename": "auxfuncs.py", + "nloc": 12, + "complexity": 2, + "token_count": 19, + "parameters": [ + "rout" + ], + "start_line": 142, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "isstringfunction", + "long_name": "isstringfunction( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 154, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "isintent_in", + "long_name": "isintent_in( var )", + "filename": "auxfuncs.py", + "nloc": 9, + "complexity": 8, + "token_count": 78, + "parameters": [ + "var" + ], + "start_line": 166, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isintent_out", + "long_name": "isintent_out( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 176, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_c", + "long_name": "isintent_c( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 180, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_cache", + "long_name": "isintent_cache( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_copy", + "long_name": "isintent_copy( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_overwrite", + "long_name": "isintent_overwrite( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 188, + "end_line": 189, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_callback", + "long_name": "isintent_callback( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 190, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_inplace", + "long_name": "isintent_inplace( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 192, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isintent_aux", + "long_name": "isintent_aux( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "var" + ], + "start_line": 194, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isprivate", + "long_name": "isprivate( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 2, + "token_count": 19, + "parameters": [ + "var" + ], + "start_line": 204, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hasinitvalueasstring", + "long_name": "hasinitvalueasstring( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 2, + "token_count": 28, + "parameters": [ + "var" + ], + "start_line": 208, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "hasnote", + "long_name": "hasnote( var )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "var" + ], + "start_line": 211, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hasresultnote", + "long_name": "hasresultnote( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 4, + "token_count": 60, + "parameters": [ + "rout" + ], + "start_line": 213, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "hascommon", + "long_name": "hascommon( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 219, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "containscommon", + "long_name": "containscommon( rout )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 5, + "token_count": 37, + "parameters": [ + "rout" + ], + "start_line": 221, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "containsmodule", + "long_name": "containsmodule( block )", + "filename": "auxfuncs.py", + "nloc": 7, + "complexity": 5, + "token_count": 44, + "parameters": [ + "block" + ], + "start_line": 227, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "hasbody", + "long_name": "hasbody( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 234, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hascallstatement", + "long_name": "hascallstatement( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "rout" + ], + "start_line": 236, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isfalse", + "long_name": "isfalse( var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 14, + "parameters": [ + "var" + ], + "start_line": 240, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , mess )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "mess" + ], + "start_line": 246, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , var )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "var" + ], + "start_line": 248, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "l_and", + "long_name": "l_and( * f )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 2, + "token_count": 64, + "parameters": [ + "f" + ], + "start_line": 252, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "l_or", + "long_name": "l_or( * f )", + "filename": "auxfuncs.py", + "nloc": 6, + "complexity": 2, + "token_count": 64, + "parameters": [ + "f" + ], + "start_line": 258, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "l_not", + "long_name": "l_not( f )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "f" + ], + "start_line": 264, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isdummyroutine", + "long_name": "isdummyroutine( rout )", + "filename": "auxfuncs.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "rout" + ], + "start_line": 267, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "getfortranname", + "long_name": "getfortranname( rout )", + "filename": "auxfuncs.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [ + "rout" + ], + "start_line": 273, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "getmultilineblock", + "long_name": "getmultilineblock( rout , blockname , comment = 1 , counter = 0 )", + "filename": "auxfuncs.py", + "nloc": 25, + "complexity": 11, + "token_count": 177, + "parameters": [ + "rout", + "blockname", + "comment", + "counter" + ], + "start_line": 285, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "getcallstatement", + "long_name": "getcallstatement( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 311, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getcallprotoargument", + "long_name": "getcallprotoargument( rout , cb_map = { } )", + "filename": "auxfuncs.py", + "nloc": 31, + "complexity": 12, + "token_count": 198, + "parameters": [ + "rout", + "cb_map" + ], + "start_line": 314, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "getusercode", + "long_name": "getusercode( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 349, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getusercode1", + "long_name": "getusercode1( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "rout" + ], + "start_line": 351, + "end_line": 352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getpymethoddef", + "long_name": "getpymethoddef( rout )", + "filename": "auxfuncs.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "rout" + ], + "start_line": 354, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "getargs", + "long_name": "getargs( rout )", + "filename": "auxfuncs.py", + "nloc": 12, + "complexity": 7, + "token_count": 84, + "parameters": [ + "rout" + ], + "start_line": 357, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "getargs2", + "long_name": "getargs2( rout )", + "filename": "auxfuncs.py", + "nloc": 13, + "complexity": 9, + "token_count": 117, + "parameters": [ + "rout" + ], + "start_line": 370, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "getrestdoc", + "long_name": "getrestdoc( rout )", + "filename": "auxfuncs.py", + "nloc": 7, + "complexity": 3, + "token_count": 50, + "parameters": [ + "rout" + ], + "start_line": 384, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "gentitle", + "long_name": "gentitle( name )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "name" + ], + "start_line": 392, + "end_line": 394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "flatlist", + "long_name": "flatlist( l )", + "filename": "auxfuncs.py", + "nloc": 4, + "complexity": 2, + "token_count": 43, + "parameters": [ + "l" + ], + "start_line": 395, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "stripcomma", + "long_name": "stripcomma( s )", + "filename": "auxfuncs.py", + "nloc": 3, + "complexity": 3, + "token_count": 25, + "parameters": [ + "s" + ], + "start_line": 399, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "replace", + "long_name": "replace( str , dict , defaultsep = '' )", + "filename": "auxfuncs.py", + "nloc": 16, + "complexity": 8, + "token_count": 203, + "parameters": [ + "str", + "dict", + "defaultsep" + ], + "start_line": 402, + "end_line": 417, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "dictappend", + "long_name": "dictappend( rd , ar )", + "filename": "auxfuncs.py", + "nloc": 19, + "complexity": 14, + "token_count": 238, + "parameters": [ + "rd", + "ar" + ], + "start_line": 419, + "end_line": 437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "applyrules", + "long_name": "applyrules( rules , dict , var = { } )", + "filename": "auxfuncs.py", + "nloc": 48, + "complexity": 28, + "token_count": 508, + "parameters": [ + "rules", + "dict", + "var" + ], + "start_line": 439, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 447, + "complexity": 229, + "token_count": 4062, + "diff_parsed": { + "added": [ + "terms of the NumPy (BSD style) LICENSE.", + "" + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/capi_maps.py", + "new_path": "numpy/f2py/capi_maps.py", + "filename": "capi_maps.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,7 +4,7 @@\n Copyright 1999,2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/05/06 10:57:33 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 10:57:33 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.60 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport string,copy,re,os\nfrom auxfuncs import *\nfrom crackfortran import markoutercomma\nimport cb_rules\n\n# Numarray and Numeric users should set this False\nusing_newcore = True\n\ndepargs=[]\nlcb_map={}\nlcb2_map={}\n# forced casting: mainly caused by the fact that Python or Numeric\n# C/APIs do not support the corresponding C types.\nc2py_map={'double':'float',\n 'float':'float', # forced casting\n 'long_double':'float', # forced casting\n 'char':'int', # forced casting\n 'signed_char':'int', # forced casting\n 'unsigned_char':'int', # forced casting\n 'short':'int', # forced casting\n 'unsigned_short':'int', # forced casting\n 'int':'int', # (forced casting)\n 'long':'int',\n 'long_long':'long',\n 'unsigned':'int', # forced casting\n 'complex_float':'complex', # forced casting\n 'complex_double':'complex',\n 'complex_long_double':'complex', # forced casting\n 'string':'string',\n }\nc2capi_map={'double':'PyArray_DOUBLE',\n 'float':'PyArray_FLOAT',\n 'long_double':'PyArray_DOUBLE', # forced casting\n 'char':'PyArray_CHAR',\n 'unsigned_char':'PyArray_UBYTE',\n 'signed_char':'PyArray_SBYTE',\n 'short':'PyArray_SHORT',\n 'unsigned_short':'PyArray_USHORT',\n 'int':'PyArray_INT',\n 'unsigned':'PyArray_UINT',\n 'long':'PyArray_LONG',\n 'long_long':'PyArray_LONG', # forced casting\n 'complex_float':'PyArray_CFLOAT',\n 'complex_double':'PyArray_CDOUBLE',\n 'complex_long_double':'PyArray_CDOUBLE', # forced casting\n 'string':'PyArray_CHAR'}\n\n#These new maps aren't used anyhere yet, but should be by default\n# unless building numeric or numarray extensions.\nif using_newcore:\n c2capi_map={'double':'PyArray_DOUBLE',\n 'float':'PyArray_FLOAT',\n 'long_double':'PyArray_LONGDOUBLE', \n 'char':'PyArray_BYTE',\n 'unsigned_char':'PyArray_UBYTE',\n 'signed_char':'PyArray_BYTE',\n 'short':'PyArray_SHORT',\n 'unsigned_short':'PyArray_USHORT',\n 'int':'PyArray_INT',\n 'unsigned':'PyArray_UINT',\n 'long':'PyArray_LONG',\n 'unsigned_long':'PyArray_ULONG',\n 'long_long':'PyArray_LONGLONG', \n 'unsigned_long_long':'Pyarray_ULONGLONG',\n 'complex_float':'PyArray_CFLOAT',\n 'complex_double':'PyArray_CDOUBLE',\n 'complex_long_double':'PyArray_CDOUBLE', \n 'string':'PyArray_STRING'}\nc2pycode_map={'double':'d',\n 'float':'f',\n 'long_double':'d', # forced casting\n 'char':'1',\n 'signed_char':'1',\n 'unsigned_char':'b',\n 'short':'s',\n 'unsigned_short':'w',\n 'int':'i',\n 'unsigned':'u',\n 'long':'l',\n 'long_long':'L',\n 'complex_float':'F',\n 'complex_double':'D',\n 'complex_long_double':'D', # forced casting\n 'string':'c'\n }\nif using_newcore:\n c2pycode_map={'double':'d',\n 'float':'f',\n 'long_double':'g', \n 'char':'b',\n 'unsigned_char':'B',\n 'signed_char':'b',\n 'short':'h',\n 'unsigned_short':'H',\n 'int':'i',\n 'unsigned':'I',\n 'long':'l',\n 'unsigned_long':'L',\n 'long_long':'q', \n 'unsigned_long_long':'Q',\n 'complex_float':'F',\n 'complex_double':'D',\n 'complex_long_double':'G', \n 'string':'S'}\nc2buildvalue_map={'double':'d',\n 'float':'f',\n 'char':'b',\n 'signed_char':'b',\n 'short':'h',\n 'int':'i',\n 'long':'l',\n 'long_long':'L',\n 'complex_float':'N',\n 'complex_double':'N',\n 'complex_long_double':'N',\n 'string':'z'}\nif using_newcore:\n #c2buildvalue_map=???\n pass\n\nf2cmap_all={'real':{'':'float','4':'float','8':'double','12':'long_double','16':'long_double'},\n 'integer':{'':'int','1':'signed_char','2':'short','4':'int','8':'long_long',\n '-1':'unsigned_char','-2':'unsigned_short','-4':'unsigned',\n '-8':'unsigned_long_long'},\n 'complex':{'':'complex_float','8':'complex_float',\n '16':'complex_double','24':'complex_long_double',\n '32':'complex_long_double'},\n 'complexkind':{'':'complex_float','4':'complex_float',\n '8':'complex_double','12':'complex_long_double',\n '16':'complex_long_double'},\n 'logical':{'':'int','1':'char','2':'short','4':'int','8':'long_long'},\n 'double complex':{'':'complex_double'},\n 'double precision':{'':'double'},\n 'byte':{'':'char'},\n 'character':{'':'string'}\n }\n\nif os.path.isfile('.f2py_f2cmap'):\n # User defined additions to f2cmap_all.\n # .f2py_f2cmap must contain a dictionary of dictionaries, only.\n # For example, {'real':{'low':'float'}} means that Fortran 'real(low)' is\n # interpreted as C 'float'.\n # This feature is useful for F90/95 users if they use PARAMETERSs\n # in type specifications.\n try:\n outmess('Reading .f2py_f2cmap ...\\n')\n f = open('.f2py_f2cmap','r')\n d = eval(f.read(),{},{})\n f.close()\n for k,d1 in d.items():\n for k1 in d1.keys():\n d1[string.lower(k1)] = d1[k1]\n d[string.lower(k)] = d[k]\n for k in d.keys():\n if not f2cmap_all.has_key(k): f2cmap_all[k]={}\n for k1 in d[k].keys():\n if c2py_map.has_key(d[k][k1]):\n if f2cmap_all[k].has_key(k1):\n outmess(\"\\tWarning: redefinition of {'%s':{'%s':'%s'->'%s'}}\\n\"%(k,k1,f2cmap_all[k][k1],d[k][k1]))\n f2cmap_all[k][k1] = d[k][k1]\n outmess('\\tMapping \"%s(kind=%s)\" to \"%s\"\\n' % (k,k1,d[k][k1]))\n else:\n errmess(\"\\tIgnoring map {'%s':{'%s':'%s'}}: '%s' must be in %s\\n\"%(k,k1,d[k][k1],d[k][k1],c2py_map.keys()))\n outmess('Succesfully applied user defined changes from .f2py_f2cmap\\n')\n except:\n errmess('Failed to apply user defined changes from .f2py_f2cmap. Skipping.\\n')\ncformat_map={'double':'%g',\n 'float':'%g',\n 'long_double':'%Lg',\n 'char':'%d',\n 'signed_char':'%d',\n 'unsigned_char':'%hhu',\n 'short':'%hd',\n 'unsigned_short':'%hu',\n 'int':'%d',\n 'unsigned':'%u',\n 'long':'%ld',\n 'unsigned_long':'%lu',\n 'long_long':'%ld',\n 'complex_float':'(%g,%g)',\n 'complex_double':'(%g,%g)',\n 'complex_long_double':'(%Lg,%Lg)',\n 'string':'%s',\n }\n\n############### Auxiliary functions \ndef getctype(var):\n \"\"\"\n Determines C type\n \"\"\"\n ctype='void'\n if isfunction(var):\n if var.has_key('result'): a=var['result']\n else: a=var['name']\n if var['vars'].has_key(a): return getctype(var['vars'][a])\n else: errmess('getctype: function %s has no return value?!\\n'%a)\n elif issubroutine(var):\n return ctype\n elif var.has_key('typespec') and f2cmap_all.has_key(string.lower(var['typespec'])):\n typespec = string.lower(var['typespec'])\n f2cmap=f2cmap_all[typespec]\n ctype=f2cmap[''] # default type\n if var.has_key('kindselector'):\n if var['kindselector'].has_key('*'):\n try:\n ctype=f2cmap[var['kindselector']['*']]\n except KeyError:\n errmess('getctype: \"%s %s %s\" not supported.\\n'%(var['typespec'],'*',var['kindselector']['*']))\n elif var['kindselector'].has_key('kind'):\n if f2cmap_all.has_key(typespec+'kind'):\n f2cmap=f2cmap_all[typespec+'kind']\n try:\n ctype=f2cmap[var['kindselector']['kind']]\n except KeyError:\n if f2cmap_all.has_key(typespec):\n f2cmap=f2cmap_all[typespec]\n try:\n ctype=f2cmap[str(var['kindselector']['kind'])]\n except KeyError:\n errmess('getctype: \"%s(kind=%s)\" not supported (use .f2py_f2cmap).\\n'\\\n %(typespec,var['kindselector']['kind']))\n\n else:\n if not isexternal(var):\n errmess('getctype: No C-type found in \"%s\", assuming void.\\n'%var)\n return ctype\ndef getstrlength(var):\n if isstringfunction(var):\n if var.has_key('result'): a=var['result']\n else: a=var['name']\n if var['vars'].has_key(a): return getstrlength(var['vars'][a])\n else: errmess('getstrlength: function %s has no return value?!\\n'%a)\n if not isstring(var):\n errmess('getstrlength: expected a signature of a string but got: %s\\n'%(`var`))\n len='1'\n if var.has_key('charselector'):\n a=var['charselector']\n if a.has_key('*'): len=a['*']\n elif a.has_key('len'): len=a['len']\n if re.match(r'\\(\\s*([*]|[:])\\s*\\)',len) or re.match(r'([*]|[:])',len): \n #if len in ['(*)','*','(:)',':']:\n if isintent_hide(var):\n errmess('getstrlength:intent(hide): expected a string with defined length but got: %s\\n'%(`var`))\n len='-1'\n return len\ndef getarrdims(a,var,verbose=0):\n global depargs\n ret={}\n if isstring(var) and not isarray(var):\n ret['dims']=getstrlength(var)\n ret['size']=ret['dims']\n ret['rank']='1'\n elif isscalar(var):\n ret['size']='1'\n ret['rank']='0'\n ret['dims']=''\n elif isarray(var):\n# if not isintent_c(var):\n# var['dimension'].reverse()\n dim=copy.copy(var['dimension'])\n ret['size']=string.join(dim,'*')\n try: ret['size']=`eval(ret['size'])`\n except: pass\n ret['dims']=string.join(dim,',')\n ret['rank']=`len(dim)`\n ret['rank*[-1]']=`len(dim)*[-1]`[1:-1]\n for i in range(len(dim)): # solve dim for dependecies\n v=[]\n if dim[i] in depargs: v=[dim[i]]\n else:\n for va in depargs:\n if re.match(r'.*?\\b%s\\b.*'%va,dim[i]):\n v.append(va)\n for va in v:\n if depargs.index(va)>depargs.index(a):\n dim[i]='*'\n break\n ret['setdims'],i='',-1\n for d in dim:\n i=i+1\n if d not in ['*',':','(*)','(:)']:\n ret['setdims']='%s#varname#_Dims[%d]=%s,'%(ret['setdims'],i,d)\n if ret['setdims']: ret['setdims']=ret['setdims'][:-1]\n ret['cbsetdims'],i='',-1\n for d in var['dimension']:\n i=i+1\n if d not in ['*',':','(*)','(:)']:\n ret['cbsetdims']='%s#varname#_Dims[%d]=%s,'%(ret['cbsetdims'],i,d)\n elif verbose :\n errmess('getarrdims: If in call-back function: array argument %s must have bounded dimensions: got %s\\n'%(`a`,`d`))\n if ret['cbsetdims']: ret['cbsetdims']=ret['cbsetdims'][:-1]\n# if not isintent_c(var):\n# var['dimension'].reverse()\n return ret\ndef getpydocsign(a,var):\n global lcb_map\n if isfunction(var):\n if var.has_key('result'): af=var['result']\n else: af=var['name']\n if var['vars'].has_key(af): return getpydocsign(af,var['vars'][af])\n else: errmess('getctype: function %s has no return value?!\\n'%af)\n return '',''\n sig,sigout=a,a\n opt=''\n if isintent_in(var): opt='input'\n elif isintent_inout(var): opt='in/output'\n out_a = a\n if isintent_out(var):\n for k in var['intent']:\n if k[:4]=='out=':\n out_a = k[4:]\n break\n init=''\n ctype=getctype(var)\n \n if hasinitvalue(var):\n init,showinit=getinit(a,var)\n init='= %s'%(showinit)\n if isscalar(var):\n if isintent_inout(var):\n sig='%s :%s %s rank-0 array(%s,\\'%s\\')'%(a,init,opt,c2py_map[ctype],\n c2pycode_map[ctype],)\n else:\n sig='%s :%s %s %s'%(a,init,opt,c2py_map[ctype])\n sigout='%s : %s'%(out_a,c2py_map[ctype])\n elif isstring(var):\n if isintent_inout(var):\n sig='%s :%s %s rank-0 array(string(len=%s),\\'c\\')'%(a,init,opt,getstrlength(var))\n else:\n sig='%s :%s %s string(len=%s)'%(a,init,opt,getstrlength(var))\n sigout='%s : string(len=%s)'%(out_a,getstrlength(var))\n elif isarray(var):\n dim=var['dimension']\n rank=`len(dim)`\n sig='%s :%s %s rank-%s array(\\'%s\\') with bounds (%s)'%(a,init,opt,rank,\n c2pycode_map[ctype],\n string.join(dim,','))\n if a==out_a:\n sigout='%s : rank-%s array(\\'%s\\') with bounds (%s)'\\\n %(a,rank,c2pycode_map[ctype],string.join(dim,','))\n else:\n sigout='%s : rank-%s array(\\'%s\\') with bounds (%s) and %s storage'\\\n %(out_a,rank,c2pycode_map[ctype],string.join(dim,','),a)\n elif isexternal(var):\n ua=''\n if lcb_map.has_key(a) and lcb2_map.has_key(lcb_map[a]) and lcb2_map[lcb_map[a]].has_key('argname'):\n ua=lcb2_map[lcb_map[a]]['argname']\n if not ua==a: ua=' => %s'%ua\n else: ua=''\n sig='%s : call-back function%s'%(a,ua)\n sigout=sig\n else:\n errmess('getpydocsign: Could not resolve docsignature for \"%s\".\\\\n'%a)\n return sig,sigout\ndef getarrdocsign(a,var):\n ctype=getctype(var)\n if isstring(var) and (not isarray(var)):\n sig='%s : rank-0 array(string(len=%s),\\'c\\')'%(a,getstrlength(var))\n elif isscalar(var):\n sig='%s : rank-0 array(%s,\\'%s\\')'%(a,c2py_map[ctype],\n c2pycode_map[ctype],)\n elif isarray(var):\n dim=var['dimension']\n rank=`len(dim)`\n sig='%s : rank-%s array(\\'%s\\') with bounds (%s)'%(a,rank,\n c2pycode_map[ctype],\n string.join(dim,','))\n return sig\n\ndef getinit(a,var):\n if isstring(var): init,showinit='\"\"',\"''\"\n else: init,showinit='',''\n if hasinitvalue(var):\n init=var['=']\n showinit=init\n if iscomplex(var) or iscomplexarray(var):\n\t ret={}\n \n try:\n v = var[\"=\"]\n if ',' in v:\n ret['init.r'],ret['init.i']=string.split(markoutercomma(v[1:-1]),'@,@')\n else:\n v = eval(v,{},{})\n ret['init.r'],ret['init.i']=str(v.real),str(v.imag)\n except: raise 'sign2map: expected complex number `(r,i)\\' but got `%s\\' as initial value of %s.'%(init,`a`)\n if isarray(var):\n init='(capi_c.r=%s,capi_c.i=%s,capi_c)'%(ret['init.r'],ret['init.i'])\n elif isstring(var):\n if not init: init,showinit='\"\"',\"''\"\n if init[0]==\"'\":\n init='\"%s\"'%(string.replace(init[1:-1],'\"','\\\\\"'))\n if init[0]=='\"': showinit=\"'%s'\"%(init[1:-1])\n return init,showinit\n\ndef sign2map(a,var):\n \"\"\"\n varname,ctype,atype\n init,init.r,init.i,pytype\n vardebuginfo,vardebugshowvalue,varshowvalue\n varrfromat\n intent\n \"\"\"\n global lcb_map,cb_map\n out_a = a\n if isintent_out(var):\n for k in var['intent']:\n if k[:4]=='out=':\n out_a = k[4:]\n break\n ret={'varname':a,'outvarname':out_a}\n ret['ctype']=getctype(var)\n intent_flags = []\n for f,s in isintent_dict.items():\n if f(var): intent_flags.append('F2PY_%s'%s)\n if intent_flags:\n #XXX: Evaluate intent_flags here.\n ret['intent'] = string.join(intent_flags,'|')\n else:\n ret['intent'] = 'F2PY_INTENT_IN'\n if isarray(var): ret['varrformat']='N'\n elif c2buildvalue_map.has_key(ret['ctype']):\n ret['varrformat']=c2buildvalue_map[ret['ctype']]\n else: ret['varrformat']='O'\n ret['init'],ret['showinit']=getinit(a,var)\n if hasinitvalue(var) and iscomplex(var) and not isarray(var):\n\tret['init.r'],ret['init.i'] = string.split(markoutercomma(ret['init'][1:-1]),'@,@')\n if isexternal(var):\n ret['cbnamekey']=a\n if lcb_map.has_key(a):\n ret['cbname']=lcb_map[a]\n ret['maxnofargs']=lcb2_map[lcb_map[a]]['maxnofargs']\n ret['nofoptargs']=lcb2_map[lcb_map[a]]['nofoptargs']\n ret['cbdocstr']=lcb2_map[lcb_map[a]]['docstr']\n ret['cblatexdocstr']=lcb2_map[lcb_map[a]]['latexdocstr']\n else:\n ret['cbname']=a\n errmess('sign2map: Confused: external %s is not in lcb_map%s.\\n'%(a,lcb_map.keys()))\n if isstring(var):\n ret['length']=getstrlength(var)\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n dim=copy.copy(var['dimension'])\n if c2capi_map.has_key(ret['ctype']): ret['atype']=c2capi_map[ret['ctype']]\n # Debug info\n if debugcapi(var):\n il=[isintent_in,'input',isintent_out,'output',\n isintent_inout,'inoutput',isrequired,'required',\n isoptional,'optional',isintent_hide,'hidden',\n iscomplex,'complex scalar',\n l_and(isscalar,l_not(iscomplex)),'scalar',\n isstring,'string',isarray,'array',\n iscomplexarray,'complex array',isstringarray,'string array',\n iscomplexfunction,'complex function',\n l_and(isfunction,l_not(iscomplexfunction)),'function',\n isexternal,'callback',\n isintent_callback,'callback',\n isintent_aux,'auxiliary',\n #ismutable,'mutable',l_not(ismutable),'immutable',\n ]\n rl=[]\n for i in range(0,len(il),2):\n if il[i](var): rl.append(il[i+1])\n if isstring(var):\n rl.append('slen(%s)=%s'%(a,ret['length']))\n if isarray(var):\n# if not isintent_c(var):\n# var['dimension'].reverse()\n ddim=string.join(map(lambda x,y:'%s|%s'%(x,y),var['dimension'],dim),',')\n rl.append('dims(%s)'%ddim)\n# if not isintent_c(var):\n# var['dimension'].reverse()\n if isexternal(var):\n ret['vardebuginfo']='debug-capi:%s=>%s:%s'%(a,ret['cbname'],string.join(rl,','))\n else:\n ret['vardebuginfo']='debug-capi:%s %s=%s:%s'%(ret['ctype'],a,ret['showinit'],string.join(rl,','))\n if isscalar(var):\n if cformat_map.has_key(ret['ctype']):\n ret['vardebugshowvalue']='debug-capi:%s=%s'%(a,cformat_map[ret['ctype']])\n if isstring(var):\n ret['vardebugshowvalue']='debug-capi:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n if isexternal(var):\n ret['vardebugshowvalue']='debug-capi:%s=%%p'%(a)\n if cformat_map.has_key(ret['ctype']):\n ret['varshowvalue']='#name#:%s=%s'%(a,cformat_map[ret['ctype']])\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isstring(var):\n ret['varshowvalue']='#name#:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n return ret\n\ndef routsign2map(rout):\n \"\"\"\n name,NAME,begintitle,endtitle\n rname,ctype,rformat\n routdebugshowvalue\n \"\"\"\n global lcb_map\n name = rout['name']\n fname = getfortranname(rout)\n ret={'name':name,\n 'texname':string.replace(name,'_','\\\\_'),\n 'name_lower':string.lower(name),\n 'NAME':string.upper(name),\n 'begintitle':gentitle(name),\n 'endtitle':gentitle('end of %s'%name),\n 'fortranname':fname,\n 'FORTRANNAME':string.upper(fname),\n 'callstatement':getcallstatement(rout) or '',\n 'usercode':getusercode(rout) or '',\n 'usercode1':getusercode1(rout) or '',\n }\n if '_' in fname:\n ret['F_FUNC'] = 'F_FUNC_US'\n else:\n ret['F_FUNC'] = 'F_FUNC'\n if '_' in name:\n ret['F_WRAPPEDFUNC'] = 'F_WRAPPEDFUNC_US'\n else:\n ret['F_WRAPPEDFUNC'] = 'F_WRAPPEDFUNC'\n lcb_map={}\n if rout.has_key('use'):\n for u in rout['use'].keys():\n if cb_rules.cb_map.has_key(u):\n for un in cb_rules.cb_map[u]:\n ln=un[0]\n if rout['use'][u].has_key('map'):\n for k in rout['use'][u]['map'].keys():\n if rout['use'][u]['map'][k]==un[0]: ln=k;break\n lcb_map[ln]=un[1]\n #else:\n # errmess('routsign2map: cb_map does not contain module \"%s\" used in \"use\" statement.\\n'%(u))\n elif rout.has_key('externals') and rout['externals']:\n errmess('routsign2map: Confused: function %s has externals %s but no \"use\" statement.\\n'%(ret['name'],`rout['externals']`))\n ret['callprotoargument'] = getcallprotoargument(rout,lcb_map) or ''\n if isfunction(rout):\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n ret['rname']=a\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,rout)\n ret['ctype']=getctype(rout['vars'][a])\n if hasresultnote(rout):\n ret['resultnote']=rout['vars'][a]['note']\n rout['vars'][a]['note']=['See elsewhere.']\n if c2buildvalue_map.has_key(ret['ctype']):\n ret['rformat']=c2buildvalue_map[ret['ctype']]\n else: \n ret['rformat']='O'\n errmess('routsign2map: no c2buildvalue key for type %s\\n'%(`ret['ctype']`))\n if debugcapi(rout):\n if cformat_map.has_key(ret['ctype']):\n ret['routdebugshowvalue']='debug-capi:%s=%s'%(a,cformat_map[ret['ctype']])\n if isstringfunction(rout):\n ret['routdebugshowvalue']='debug-capi:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n if isstringfunction(rout):\n ret['rlength']=getstrlength(rout['vars'][a])\n if ret['rlength']=='-1':\n errmess('routsign2map: expected explicit specification of the length of the string returned by the fortran function %s; taking 10.\\n'%(`rout['name']`))\n ret['rlength']='10'\n if hasnote(rout):\n ret['note']=rout['note']\n rout['note']=['See elsewhere.']\n return ret\n\ndef modsign2map(m):\n \"\"\"\n modulename\n \"\"\"\n if ismodule(m):\n ret={'f90modulename':m['name'],\n 'F90MODULENAME':string.upper(m['name']),\n 'texf90modulename':string.replace(m['name'],'_','\\\\_')}\n else:\n ret={'modulename':m['name'],\n 'MODULENAME':string.upper(m['name']),\n 'texmodulename':string.replace(m['name'],'_','\\\\_')}\n ret['restdoc'] = getrestdoc(m) or []\n if hasnote(m):\n ret['note']=m['note']\n #m['note']=['See elsewhere.']\n ret['usercode'] = getusercode(m) or ''\n ret['usercode1'] = getusercode1(m) or ''\n if m['body']:\n ret['interface_usercode'] = getusercode(m['body'][0]) or ''\n else:\n ret['interface_usercode'] = ''\n ret['pymethoddef'] = getpymethoddef(m) or ''\n return ret\n\ndef cb_sign2map(a,var):\n ret={'varname':a}\n ret['ctype']=getctype(var)\n if c2capi_map.has_key(ret['ctype']):\n ret['atype']=c2capi_map[ret['ctype']]\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n var['note']=['See elsewhere.']\n return ret\n\ndef cb_routsign2map(rout,um):\n \"\"\"\n name,begintitle,endtitle,argname\n ctype,rctype,maxnofargs,nofoptargs,returncptr\n \"\"\"\n ret={'name':'cb_%s_in_%s'%(rout['name'],um),\n 'returncptr':''}\n if isintent_callback(rout):\n if '_' in rout['name']:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n ret['callbackname'] = '%s(%s,%s)' \\\n % (F_FUNC,\n rout['name'].lower(),\n rout['name'].upper(),\n )\n ret['static'] = 'extern'\n else:\n ret['callbackname'] = ret['name']\n ret['static'] = 'static'\n ret['argname']=rout['name']\n ret['begintitle']=gentitle(ret['name'])\n ret['endtitle']=gentitle('end of %s'%ret['name'])\n ret['ctype']=getctype(rout)\n ret['rctype']='void'\n if ret['ctype']=='string': ret['rctype']='void'\n else:\n ret['rctype']=ret['ctype']\n if ret['rctype']!='void':\n if iscomplexfunction(rout):\n ret['returncptr'] = \"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\nreturn_value=\n#endif\n\"\"\"\n else:\n ret['returncptr'] = 'return_value='\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isstringfunction(rout):\n ret['strlength']=getstrlength(rout)\n if isfunction(rout):\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if hasnote(rout['vars'][a]):\n ret['note']=rout['vars'][a]['note']\n rout['vars'][a]['note']=['See elsewhere.']\n ret['rname']=a\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,rout)\n if iscomplexfunction(rout):\n ret['rctype']=\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n#ctype# \n#else\nvoid\n#endif\n\"\"\"\n else:\n if hasnote(rout):\n ret['note']=rout['note']\n rout['note']=['See elsewhere.']\n nofargs=0\n nofoptargs=0\n if rout.has_key('args') and rout.has_key('vars'):\n for a in rout['args']:\n var=rout['vars'][a]\n if l_or(isintent_in,isintent_inout)(var):\n nofargs=nofargs+1\n if isoptional(var):\n nofoptargs=nofoptargs+1\n ret['maxnofargs']=`nofargs`\n ret['nofoptargs']=`nofoptargs`\n if hasnote(rout) and isfunction(rout) and rout.has_key('result'):\n ret['routnote']=rout['note']\n rout['note']=['See elsewhere.']\n return ret\n\ndef common_sign2map(a,var): # obsolute\n ret={'varname':a}\n ret['ctype']=getctype(var)\n if isstringarray(var): ret['ctype']='char'\n if c2capi_map.has_key(ret['ctype']):\n ret['atype']=c2capi_map[ret['ctype']]\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n elif isstring(var):\n ret['size']=getstrlength(var)\n ret['rank']='1'\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n var['note']=['See elsewhere.']\n ret['arrdocstr']=getarrdocsign(a,var) # for strings this returns 0-rank but actually is 1-rank\n return ret\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 10:57:33 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.60 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport string,copy,re,os\nfrom auxfuncs import *\nfrom crackfortran import markoutercomma\nimport cb_rules\n\n# Numarray and Numeric users should set this False\nusing_newcore = True\n\ndepargs=[]\nlcb_map={}\nlcb2_map={}\n# forced casting: mainly caused by the fact that Python or Numeric\n# C/APIs do not support the corresponding C types.\nc2py_map={'double':'float',\n 'float':'float', # forced casting\n 'long_double':'float', # forced casting\n 'char':'int', # forced casting\n 'signed_char':'int', # forced casting\n 'unsigned_char':'int', # forced casting\n 'short':'int', # forced casting\n 'unsigned_short':'int', # forced casting\n 'int':'int', # (forced casting)\n 'long':'int',\n 'long_long':'long',\n 'unsigned':'int', # forced casting\n 'complex_float':'complex', # forced casting\n 'complex_double':'complex',\n 'complex_long_double':'complex', # forced casting\n 'string':'string',\n }\nc2capi_map={'double':'PyArray_DOUBLE',\n 'float':'PyArray_FLOAT',\n 'long_double':'PyArray_DOUBLE', # forced casting\n 'char':'PyArray_CHAR',\n 'unsigned_char':'PyArray_UBYTE',\n 'signed_char':'PyArray_SBYTE',\n 'short':'PyArray_SHORT',\n 'unsigned_short':'PyArray_USHORT',\n 'int':'PyArray_INT',\n 'unsigned':'PyArray_UINT',\n 'long':'PyArray_LONG',\n 'long_long':'PyArray_LONG', # forced casting\n 'complex_float':'PyArray_CFLOAT',\n 'complex_double':'PyArray_CDOUBLE',\n 'complex_long_double':'PyArray_CDOUBLE', # forced casting\n 'string':'PyArray_CHAR'}\n\n#These new maps aren't used anyhere yet, but should be by default\n# unless building numeric or numarray extensions.\nif using_newcore:\n c2capi_map={'double':'PyArray_DOUBLE',\n 'float':'PyArray_FLOAT',\n 'long_double':'PyArray_LONGDOUBLE', \n 'char':'PyArray_BYTE',\n 'unsigned_char':'PyArray_UBYTE',\n 'signed_char':'PyArray_BYTE',\n 'short':'PyArray_SHORT',\n 'unsigned_short':'PyArray_USHORT',\n 'int':'PyArray_INT',\n 'unsigned':'PyArray_UINT',\n 'long':'PyArray_LONG',\n 'unsigned_long':'PyArray_ULONG',\n 'long_long':'PyArray_LONGLONG', \n 'unsigned_long_long':'Pyarray_ULONGLONG',\n 'complex_float':'PyArray_CFLOAT',\n 'complex_double':'PyArray_CDOUBLE',\n 'complex_long_double':'PyArray_CDOUBLE', \n 'string':'PyArray_STRING'}\nc2pycode_map={'double':'d',\n 'float':'f',\n 'long_double':'d', # forced casting\n 'char':'1',\n 'signed_char':'1',\n 'unsigned_char':'b',\n 'short':'s',\n 'unsigned_short':'w',\n 'int':'i',\n 'unsigned':'u',\n 'long':'l',\n 'long_long':'L',\n 'complex_float':'F',\n 'complex_double':'D',\n 'complex_long_double':'D', # forced casting\n 'string':'c'\n }\nif using_newcore:\n c2pycode_map={'double':'d',\n 'float':'f',\n 'long_double':'g', \n 'char':'b',\n 'unsigned_char':'B',\n 'signed_char':'b',\n 'short':'h',\n 'unsigned_short':'H',\n 'int':'i',\n 'unsigned':'I',\n 'long':'l',\n 'unsigned_long':'L',\n 'long_long':'q', \n 'unsigned_long_long':'Q',\n 'complex_float':'F',\n 'complex_double':'D',\n 'complex_long_double':'G', \n 'string':'S'}\nc2buildvalue_map={'double':'d',\n 'float':'f',\n 'char':'b',\n 'signed_char':'b',\n 'short':'h',\n 'int':'i',\n 'long':'l',\n 'long_long':'L',\n 'complex_float':'N',\n 'complex_double':'N',\n 'complex_long_double':'N',\n 'string':'z'}\nif using_newcore:\n #c2buildvalue_map=???\n pass\n\nf2cmap_all={'real':{'':'float','4':'float','8':'double','12':'long_double','16':'long_double'},\n 'integer':{'':'int','1':'signed_char','2':'short','4':'int','8':'long_long',\n '-1':'unsigned_char','-2':'unsigned_short','-4':'unsigned',\n '-8':'unsigned_long_long'},\n 'complex':{'':'complex_float','8':'complex_float',\n '16':'complex_double','24':'complex_long_double',\n '32':'complex_long_double'},\n 'complexkind':{'':'complex_float','4':'complex_float',\n '8':'complex_double','12':'complex_long_double',\n '16':'complex_long_double'},\n 'logical':{'':'int','1':'char','2':'short','4':'int','8':'long_long'},\n 'double complex':{'':'complex_double'},\n 'double precision':{'':'double'},\n 'byte':{'':'char'},\n 'character':{'':'string'}\n }\n\nif os.path.isfile('.f2py_f2cmap'):\n # User defined additions to f2cmap_all.\n # .f2py_f2cmap must contain a dictionary of dictionaries, only.\n # For example, {'real':{'low':'float'}} means that Fortran 'real(low)' is\n # interpreted as C 'float'.\n # This feature is useful for F90/95 users if they use PARAMETERSs\n # in type specifications.\n try:\n outmess('Reading .f2py_f2cmap ...\\n')\n f = open('.f2py_f2cmap','r')\n d = eval(f.read(),{},{})\n f.close()\n for k,d1 in d.items():\n for k1 in d1.keys():\n d1[string.lower(k1)] = d1[k1]\n d[string.lower(k)] = d[k]\n for k in d.keys():\n if not f2cmap_all.has_key(k): f2cmap_all[k]={}\n for k1 in d[k].keys():\n if c2py_map.has_key(d[k][k1]):\n if f2cmap_all[k].has_key(k1):\n outmess(\"\\tWarning: redefinition of {'%s':{'%s':'%s'->'%s'}}\\n\"%(k,k1,f2cmap_all[k][k1],d[k][k1]))\n f2cmap_all[k][k1] = d[k][k1]\n outmess('\\tMapping \"%s(kind=%s)\" to \"%s\"\\n' % (k,k1,d[k][k1]))\n else:\n errmess(\"\\tIgnoring map {'%s':{'%s':'%s'}}: '%s' must be in %s\\n\"%(k,k1,d[k][k1],d[k][k1],c2py_map.keys()))\n outmess('Succesfully applied user defined changes from .f2py_f2cmap\\n')\n except:\n errmess('Failed to apply user defined changes from .f2py_f2cmap. Skipping.\\n')\ncformat_map={'double':'%g',\n 'float':'%g',\n 'long_double':'%Lg',\n 'char':'%d',\n 'signed_char':'%d',\n 'unsigned_char':'%hhu',\n 'short':'%hd',\n 'unsigned_short':'%hu',\n 'int':'%d',\n 'unsigned':'%u',\n 'long':'%ld',\n 'unsigned_long':'%lu',\n 'long_long':'%ld',\n 'complex_float':'(%g,%g)',\n 'complex_double':'(%g,%g)',\n 'complex_long_double':'(%Lg,%Lg)',\n 'string':'%s',\n }\n\n############### Auxiliary functions \ndef getctype(var):\n \"\"\"\n Determines C type\n \"\"\"\n ctype='void'\n if isfunction(var):\n if var.has_key('result'): a=var['result']\n else: a=var['name']\n if var['vars'].has_key(a): return getctype(var['vars'][a])\n else: errmess('getctype: function %s has no return value?!\\n'%a)\n elif issubroutine(var):\n return ctype\n elif var.has_key('typespec') and f2cmap_all.has_key(string.lower(var['typespec'])):\n typespec = string.lower(var['typespec'])\n f2cmap=f2cmap_all[typespec]\n ctype=f2cmap[''] # default type\n if var.has_key('kindselector'):\n if var['kindselector'].has_key('*'):\n try:\n ctype=f2cmap[var['kindselector']['*']]\n except KeyError:\n errmess('getctype: \"%s %s %s\" not supported.\\n'%(var['typespec'],'*',var['kindselector']['*']))\n elif var['kindselector'].has_key('kind'):\n if f2cmap_all.has_key(typespec+'kind'):\n f2cmap=f2cmap_all[typespec+'kind']\n try:\n ctype=f2cmap[var['kindselector']['kind']]\n except KeyError:\n if f2cmap_all.has_key(typespec):\n f2cmap=f2cmap_all[typespec]\n try:\n ctype=f2cmap[str(var['kindselector']['kind'])]\n except KeyError:\n errmess('getctype: \"%s(kind=%s)\" not supported (use .f2py_f2cmap).\\n'\\\n %(typespec,var['kindselector']['kind']))\n\n else:\n if not isexternal(var):\n errmess('getctype: No C-type found in \"%s\", assuming void.\\n'%var)\n return ctype\ndef getstrlength(var):\n if isstringfunction(var):\n if var.has_key('result'): a=var['result']\n else: a=var['name']\n if var['vars'].has_key(a): return getstrlength(var['vars'][a])\n else: errmess('getstrlength: function %s has no return value?!\\n'%a)\n if not isstring(var):\n errmess('getstrlength: expected a signature of a string but got: %s\\n'%(`var`))\n len='1'\n if var.has_key('charselector'):\n a=var['charselector']\n if a.has_key('*'): len=a['*']\n elif a.has_key('len'): len=a['len']\n if re.match(r'\\(\\s*([*]|[:])\\s*\\)',len) or re.match(r'([*]|[:])',len): \n #if len in ['(*)','*','(:)',':']:\n if isintent_hide(var):\n errmess('getstrlength:intent(hide): expected a string with defined length but got: %s\\n'%(`var`))\n len='-1'\n return len\ndef getarrdims(a,var,verbose=0):\n global depargs\n ret={}\n if isstring(var) and not isarray(var):\n ret['dims']=getstrlength(var)\n ret['size']=ret['dims']\n ret['rank']='1'\n elif isscalar(var):\n ret['size']='1'\n ret['rank']='0'\n ret['dims']=''\n elif isarray(var):\n# if not isintent_c(var):\n# var['dimension'].reverse()\n dim=copy.copy(var['dimension'])\n ret['size']=string.join(dim,'*')\n try: ret['size']=`eval(ret['size'])`\n except: pass\n ret['dims']=string.join(dim,',')\n ret['rank']=`len(dim)`\n ret['rank*[-1]']=`len(dim)*[-1]`[1:-1]\n for i in range(len(dim)): # solve dim for dependecies\n v=[]\n if dim[i] in depargs: v=[dim[i]]\n else:\n for va in depargs:\n if re.match(r'.*?\\b%s\\b.*'%va,dim[i]):\n v.append(va)\n for va in v:\n if depargs.index(va)>depargs.index(a):\n dim[i]='*'\n break\n ret['setdims'],i='',-1\n for d in dim:\n i=i+1\n if d not in ['*',':','(*)','(:)']:\n ret['setdims']='%s#varname#_Dims[%d]=%s,'%(ret['setdims'],i,d)\n if ret['setdims']: ret['setdims']=ret['setdims'][:-1]\n ret['cbsetdims'],i='',-1\n for d in var['dimension']:\n i=i+1\n if d not in ['*',':','(*)','(:)']:\n ret['cbsetdims']='%s#varname#_Dims[%d]=%s,'%(ret['cbsetdims'],i,d)\n elif verbose :\n errmess('getarrdims: If in call-back function: array argument %s must have bounded dimensions: got %s\\n'%(`a`,`d`))\n if ret['cbsetdims']: ret['cbsetdims']=ret['cbsetdims'][:-1]\n# if not isintent_c(var):\n# var['dimension'].reverse()\n return ret\ndef getpydocsign(a,var):\n global lcb_map\n if isfunction(var):\n if var.has_key('result'): af=var['result']\n else: af=var['name']\n if var['vars'].has_key(af): return getpydocsign(af,var['vars'][af])\n else: errmess('getctype: function %s has no return value?!\\n'%af)\n return '',''\n sig,sigout=a,a\n opt=''\n if isintent_in(var): opt='input'\n elif isintent_inout(var): opt='in/output'\n out_a = a\n if isintent_out(var):\n for k in var['intent']:\n if k[:4]=='out=':\n out_a = k[4:]\n break\n init=''\n ctype=getctype(var)\n \n if hasinitvalue(var):\n init,showinit=getinit(a,var)\n init='= %s'%(showinit)\n if isscalar(var):\n if isintent_inout(var):\n sig='%s :%s %s rank-0 array(%s,\\'%s\\')'%(a,init,opt,c2py_map[ctype],\n c2pycode_map[ctype],)\n else:\n sig='%s :%s %s %s'%(a,init,opt,c2py_map[ctype])\n sigout='%s : %s'%(out_a,c2py_map[ctype])\n elif isstring(var):\n if isintent_inout(var):\n sig='%s :%s %s rank-0 array(string(len=%s),\\'c\\')'%(a,init,opt,getstrlength(var))\n else:\n sig='%s :%s %s string(len=%s)'%(a,init,opt,getstrlength(var))\n sigout='%s : string(len=%s)'%(out_a,getstrlength(var))\n elif isarray(var):\n dim=var['dimension']\n rank=`len(dim)`\n sig='%s :%s %s rank-%s array(\\'%s\\') with bounds (%s)'%(a,init,opt,rank,\n c2pycode_map[ctype],\n string.join(dim,','))\n if a==out_a:\n sigout='%s : rank-%s array(\\'%s\\') with bounds (%s)'\\\n %(a,rank,c2pycode_map[ctype],string.join(dim,','))\n else:\n sigout='%s : rank-%s array(\\'%s\\') with bounds (%s) and %s storage'\\\n %(out_a,rank,c2pycode_map[ctype],string.join(dim,','),a)\n elif isexternal(var):\n ua=''\n if lcb_map.has_key(a) and lcb2_map.has_key(lcb_map[a]) and lcb2_map[lcb_map[a]].has_key('argname'):\n ua=lcb2_map[lcb_map[a]]['argname']\n if not ua==a: ua=' => %s'%ua\n else: ua=''\n sig='%s : call-back function%s'%(a,ua)\n sigout=sig\n else:\n errmess('getpydocsign: Could not resolve docsignature for \"%s\".\\\\n'%a)\n return sig,sigout\ndef getarrdocsign(a,var):\n ctype=getctype(var)\n if isstring(var) and (not isarray(var)):\n sig='%s : rank-0 array(string(len=%s),\\'c\\')'%(a,getstrlength(var))\n elif isscalar(var):\n sig='%s : rank-0 array(%s,\\'%s\\')'%(a,c2py_map[ctype],\n c2pycode_map[ctype],)\n elif isarray(var):\n dim=var['dimension']\n rank=`len(dim)`\n sig='%s : rank-%s array(\\'%s\\') with bounds (%s)'%(a,rank,\n c2pycode_map[ctype],\n string.join(dim,','))\n return sig\n\ndef getinit(a,var):\n if isstring(var): init,showinit='\"\"',\"''\"\n else: init,showinit='',''\n if hasinitvalue(var):\n init=var['=']\n showinit=init\n if iscomplex(var) or iscomplexarray(var):\n\t ret={}\n \n try:\n v = var[\"=\"]\n if ',' in v:\n ret['init.r'],ret['init.i']=string.split(markoutercomma(v[1:-1]),'@,@')\n else:\n v = eval(v,{},{})\n ret['init.r'],ret['init.i']=str(v.real),str(v.imag)\n except: raise 'sign2map: expected complex number `(r,i)\\' but got `%s\\' as initial value of %s.'%(init,`a`)\n if isarray(var):\n init='(capi_c.r=%s,capi_c.i=%s,capi_c)'%(ret['init.r'],ret['init.i'])\n elif isstring(var):\n if not init: init,showinit='\"\"',\"''\"\n if init[0]==\"'\":\n init='\"%s\"'%(string.replace(init[1:-1],'\"','\\\\\"'))\n if init[0]=='\"': showinit=\"'%s'\"%(init[1:-1])\n return init,showinit\n\ndef sign2map(a,var):\n \"\"\"\n varname,ctype,atype\n init,init.r,init.i,pytype\n vardebuginfo,vardebugshowvalue,varshowvalue\n varrfromat\n intent\n \"\"\"\n global lcb_map,cb_map\n out_a = a\n if isintent_out(var):\n for k in var['intent']:\n if k[:4]=='out=':\n out_a = k[4:]\n break\n ret={'varname':a,'outvarname':out_a}\n ret['ctype']=getctype(var)\n intent_flags = []\n for f,s in isintent_dict.items():\n if f(var): intent_flags.append('F2PY_%s'%s)\n if intent_flags:\n #XXX: Evaluate intent_flags here.\n ret['intent'] = string.join(intent_flags,'|')\n else:\n ret['intent'] = 'F2PY_INTENT_IN'\n if isarray(var): ret['varrformat']='N'\n elif c2buildvalue_map.has_key(ret['ctype']):\n ret['varrformat']=c2buildvalue_map[ret['ctype']]\n else: ret['varrformat']='O'\n ret['init'],ret['showinit']=getinit(a,var)\n if hasinitvalue(var) and iscomplex(var) and not isarray(var):\n\tret['init.r'],ret['init.i'] = string.split(markoutercomma(ret['init'][1:-1]),'@,@')\n if isexternal(var):\n ret['cbnamekey']=a\n if lcb_map.has_key(a):\n ret['cbname']=lcb_map[a]\n ret['maxnofargs']=lcb2_map[lcb_map[a]]['maxnofargs']\n ret['nofoptargs']=lcb2_map[lcb_map[a]]['nofoptargs']\n ret['cbdocstr']=lcb2_map[lcb_map[a]]['docstr']\n ret['cblatexdocstr']=lcb2_map[lcb_map[a]]['latexdocstr']\n else:\n ret['cbname']=a\n errmess('sign2map: Confused: external %s is not in lcb_map%s.\\n'%(a,lcb_map.keys()))\n if isstring(var):\n ret['length']=getstrlength(var)\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n dim=copy.copy(var['dimension'])\n if c2capi_map.has_key(ret['ctype']): ret['atype']=c2capi_map[ret['ctype']]\n # Debug info\n if debugcapi(var):\n il=[isintent_in,'input',isintent_out,'output',\n isintent_inout,'inoutput',isrequired,'required',\n isoptional,'optional',isintent_hide,'hidden',\n iscomplex,'complex scalar',\n l_and(isscalar,l_not(iscomplex)),'scalar',\n isstring,'string',isarray,'array',\n iscomplexarray,'complex array',isstringarray,'string array',\n iscomplexfunction,'complex function',\n l_and(isfunction,l_not(iscomplexfunction)),'function',\n isexternal,'callback',\n isintent_callback,'callback',\n isintent_aux,'auxiliary',\n #ismutable,'mutable',l_not(ismutable),'immutable',\n ]\n rl=[]\n for i in range(0,len(il),2):\n if il[i](var): rl.append(il[i+1])\n if isstring(var):\n rl.append('slen(%s)=%s'%(a,ret['length']))\n if isarray(var):\n# if not isintent_c(var):\n# var['dimension'].reverse()\n ddim=string.join(map(lambda x,y:'%s|%s'%(x,y),var['dimension'],dim),',')\n rl.append('dims(%s)'%ddim)\n# if not isintent_c(var):\n# var['dimension'].reverse()\n if isexternal(var):\n ret['vardebuginfo']='debug-capi:%s=>%s:%s'%(a,ret['cbname'],string.join(rl,','))\n else:\n ret['vardebuginfo']='debug-capi:%s %s=%s:%s'%(ret['ctype'],a,ret['showinit'],string.join(rl,','))\n if isscalar(var):\n if cformat_map.has_key(ret['ctype']):\n ret['vardebugshowvalue']='debug-capi:%s=%s'%(a,cformat_map[ret['ctype']])\n if isstring(var):\n ret['vardebugshowvalue']='debug-capi:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n if isexternal(var):\n ret['vardebugshowvalue']='debug-capi:%s=%%p'%(a)\n if cformat_map.has_key(ret['ctype']):\n ret['varshowvalue']='#name#:%s=%s'%(a,cformat_map[ret['ctype']])\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isstring(var):\n ret['varshowvalue']='#name#:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n return ret\n\ndef routsign2map(rout):\n \"\"\"\n name,NAME,begintitle,endtitle\n rname,ctype,rformat\n routdebugshowvalue\n \"\"\"\n global lcb_map\n name = rout['name']\n fname = getfortranname(rout)\n ret={'name':name,\n 'texname':string.replace(name,'_','\\\\_'),\n 'name_lower':string.lower(name),\n 'NAME':string.upper(name),\n 'begintitle':gentitle(name),\n 'endtitle':gentitle('end of %s'%name),\n 'fortranname':fname,\n 'FORTRANNAME':string.upper(fname),\n 'callstatement':getcallstatement(rout) or '',\n 'usercode':getusercode(rout) or '',\n 'usercode1':getusercode1(rout) or '',\n }\n if '_' in fname:\n ret['F_FUNC'] = 'F_FUNC_US'\n else:\n ret['F_FUNC'] = 'F_FUNC'\n if '_' in name:\n ret['F_WRAPPEDFUNC'] = 'F_WRAPPEDFUNC_US'\n else:\n ret['F_WRAPPEDFUNC'] = 'F_WRAPPEDFUNC'\n lcb_map={}\n if rout.has_key('use'):\n for u in rout['use'].keys():\n if cb_rules.cb_map.has_key(u):\n for un in cb_rules.cb_map[u]:\n ln=un[0]\n if rout['use'][u].has_key('map'):\n for k in rout['use'][u]['map'].keys():\n if rout['use'][u]['map'][k]==un[0]: ln=k;break\n lcb_map[ln]=un[1]\n #else:\n # errmess('routsign2map: cb_map does not contain module \"%s\" used in \"use\" statement.\\n'%(u))\n elif rout.has_key('externals') and rout['externals']:\n errmess('routsign2map: Confused: function %s has externals %s but no \"use\" statement.\\n'%(ret['name'],`rout['externals']`))\n ret['callprotoargument'] = getcallprotoargument(rout,lcb_map) or ''\n if isfunction(rout):\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n ret['rname']=a\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,rout)\n ret['ctype']=getctype(rout['vars'][a])\n if hasresultnote(rout):\n ret['resultnote']=rout['vars'][a]['note']\n rout['vars'][a]['note']=['See elsewhere.']\n if c2buildvalue_map.has_key(ret['ctype']):\n ret['rformat']=c2buildvalue_map[ret['ctype']]\n else: \n ret['rformat']='O'\n errmess('routsign2map: no c2buildvalue key for type %s\\n'%(`ret['ctype']`))\n if debugcapi(rout):\n if cformat_map.has_key(ret['ctype']):\n ret['routdebugshowvalue']='debug-capi:%s=%s'%(a,cformat_map[ret['ctype']])\n if isstringfunction(rout):\n ret['routdebugshowvalue']='debug-capi:slen(%s)=%%d %s=\\\\\"%%s\\\\\"'%(a,a)\n if isstringfunction(rout):\n ret['rlength']=getstrlength(rout['vars'][a])\n if ret['rlength']=='-1':\n errmess('routsign2map: expected explicit specification of the length of the string returned by the fortran function %s; taking 10.\\n'%(`rout['name']`))\n ret['rlength']='10'\n if hasnote(rout):\n ret['note']=rout['note']\n rout['note']=['See elsewhere.']\n return ret\n\ndef modsign2map(m):\n \"\"\"\n modulename\n \"\"\"\n if ismodule(m):\n ret={'f90modulename':m['name'],\n 'F90MODULENAME':string.upper(m['name']),\n 'texf90modulename':string.replace(m['name'],'_','\\\\_')}\n else:\n ret={'modulename':m['name'],\n 'MODULENAME':string.upper(m['name']),\n 'texmodulename':string.replace(m['name'],'_','\\\\_')}\n ret['restdoc'] = getrestdoc(m) or []\n if hasnote(m):\n ret['note']=m['note']\n #m['note']=['See elsewhere.']\n ret['usercode'] = getusercode(m) or ''\n ret['usercode1'] = getusercode1(m) or ''\n if m['body']:\n ret['interface_usercode'] = getusercode(m['body'][0]) or ''\n else:\n ret['interface_usercode'] = ''\n ret['pymethoddef'] = getpymethoddef(m) or ''\n return ret\n\ndef cb_sign2map(a,var):\n ret={'varname':a}\n ret['ctype']=getctype(var)\n if c2capi_map.has_key(ret['ctype']):\n ret['atype']=c2capi_map[ret['ctype']]\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n var['note']=['See elsewhere.']\n return ret\n\ndef cb_routsign2map(rout,um):\n \"\"\"\n name,begintitle,endtitle,argname\n ctype,rctype,maxnofargs,nofoptargs,returncptr\n \"\"\"\n ret={'name':'cb_%s_in_%s'%(rout['name'],um),\n 'returncptr':''}\n if isintent_callback(rout):\n if '_' in rout['name']:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n ret['callbackname'] = '%s(%s,%s)' \\\n % (F_FUNC,\n rout['name'].lower(),\n rout['name'].upper(),\n )\n ret['static'] = 'extern'\n else:\n ret['callbackname'] = ret['name']\n ret['static'] = 'static'\n ret['argname']=rout['name']\n ret['begintitle']=gentitle(ret['name'])\n ret['endtitle']=gentitle('end of %s'%ret['name'])\n ret['ctype']=getctype(rout)\n ret['rctype']='void'\n if ret['ctype']=='string': ret['rctype']='void'\n else:\n ret['rctype']=ret['ctype']\n if ret['rctype']!='void':\n if iscomplexfunction(rout):\n ret['returncptr'] = \"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\nreturn_value=\n#endif\n\"\"\"\n else:\n ret['returncptr'] = 'return_value='\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isstringfunction(rout):\n ret['strlength']=getstrlength(rout)\n if isfunction(rout):\n if rout.has_key('result'): a=rout['result']\n else: a=rout['name']\n if hasnote(rout['vars'][a]):\n ret['note']=rout['vars'][a]['note']\n rout['vars'][a]['note']=['See elsewhere.']\n ret['rname']=a\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,rout)\n if iscomplexfunction(rout):\n ret['rctype']=\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n#ctype# \n#else\nvoid\n#endif\n\"\"\"\n else:\n if hasnote(rout):\n ret['note']=rout['note']\n rout['note']=['See elsewhere.']\n nofargs=0\n nofoptargs=0\n if rout.has_key('args') and rout.has_key('vars'):\n for a in rout['args']:\n var=rout['vars'][a]\n if l_or(isintent_in,isintent_inout)(var):\n nofargs=nofargs+1\n if isoptional(var):\n nofoptargs=nofoptargs+1\n ret['maxnofargs']=`nofargs`\n ret['nofoptargs']=`nofoptargs`\n if hasnote(rout) and isfunction(rout) and rout.has_key('result'):\n ret['routnote']=rout['note']\n rout['note']=['See elsewhere.']\n return ret\n\ndef common_sign2map(a,var): # obsolute\n ret={'varname':a}\n ret['ctype']=getctype(var)\n if isstringarray(var): ret['ctype']='char'\n if c2capi_map.has_key(ret['ctype']):\n ret['atype']=c2capi_map[ret['ctype']]\n if cformat_map.has_key(ret['ctype']):\n ret['showvalueformat']='%s'%(cformat_map[ret['ctype']])\n if isarray(var):\n ret=dictappend(ret,getarrdims(a,var))\n elif isstring(var):\n ret['size']=getstrlength(var)\n ret['rank']='1'\n ret['pydocsign'],ret['pydocsignout']=getpydocsign(a,var)\n if hasnote(var):\n ret['note']=var['note']\n var['note']=['See elsewhere.']\n ret['arrdocstr']=getarrdocsign(a,var) # for strings this returns 0-rank but actually is 1-rank\n return ret\n\n\n", + "methods": [ + { + "name": "getctype", + "long_name": "getctype( var )", + "filename": "capi_maps.py", + "nloc": 36, + "complexity": 16, + "token_count": 292, + "parameters": [ + "var" + ], + "start_line": 205, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "getstrlength", + "long_name": "getstrlength( var )", + "filename": "capi_maps.py", + "nloc": 18, + "complexity": 11, + "token_count": 167, + "parameters": [ + "var" + ], + "start_line": 245, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "getarrdims", + "long_name": "getarrdims( a , var , verbose = 0 )", + "filename": "capi_maps.py", + "nloc": 45, + "complexity": 19, + "token_count": 425, + "parameters": [ + "a", + "var", + "verbose" + ], + "start_line": 264, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "getpydocsign", + "long_name": "getpydocsign( a , var )", + "filename": "capi_maps.py", + "nloc": 59, + "complexity": 21, + "token_count": 485, + "parameters": [ + "a", + "var" + ], + "start_line": 313, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "getarrdocsign", + "long_name": "getarrdocsign( a , var )", + "filename": "capi_maps.py", + "nloc": 14, + "complexity": 5, + "token_count": 108, + "parameters": [ + "a", + "var" + ], + "start_line": 373, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "getinit", + "long_name": "getinit( a , var )", + "filename": "capi_maps.py", + "nloc": 24, + "complexity": 12, + "token_count": 241, + "parameters": [ + "a", + "var" + ], + "start_line": 388, + "end_line": 412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "sign2map", + "long_name": "sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 83, + "complexity": 30, + "token_count": 829, + "parameters": [ + "a", + "var" + ], + "start_line": 414, + "end_line": 510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 97, + "top_nesting_level": 0 + }, + { + "name": "routsign2map", + "long_name": "routsign2map( rout )", + "filename": "capi_maps.py", + "nloc": 65, + "complexity": 26, + "token_count": 583, + "parameters": [ + "rout" + ], + "start_line": 512, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "modsign2map", + "long_name": "modsign2map( m )", + "filename": "capi_maps.py", + "nloc": 20, + "complexity": 9, + "token_count": 183, + "parameters": [ + "m" + ], + "start_line": 585, + "end_line": 608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "cb_sign2map", + "long_name": "cb_sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 14, + "complexity": 5, + "token_count": 133, + "parameters": [ + "a", + "var" + ], + "start_line": 610, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "cb_routsign2map", + "long_name": "cb_routsign2map( rout , um )", + "filename": "capi_maps.py", + "nloc": 73, + "complexity": 21, + "token_count": 494, + "parameters": [ + "rout", + "um" + ], + "start_line": 625, + "end_line": 701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "common_sign2map", + "long_name": "common_sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 19, + "complexity": 7, + "token_count": 177, + "parameters": [ + "a", + "var" + ], + "start_line": 703, + "end_line": 721, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "getctype", + "long_name": "getctype( var )", + "filename": "capi_maps.py", + "nloc": 36, + "complexity": 16, + "token_count": 292, + "parameters": [ + "var" + ], + "start_line": 205, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "getstrlength", + "long_name": "getstrlength( var )", + "filename": "capi_maps.py", + "nloc": 18, + "complexity": 11, + "token_count": 167, + "parameters": [ + "var" + ], + "start_line": 245, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "getarrdims", + "long_name": "getarrdims( a , var , verbose = 0 )", + "filename": "capi_maps.py", + "nloc": 45, + "complexity": 19, + "token_count": 425, + "parameters": [ + "a", + "var", + "verbose" + ], + "start_line": 264, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "getpydocsign", + "long_name": "getpydocsign( a , var )", + "filename": "capi_maps.py", + "nloc": 59, + "complexity": 21, + "token_count": 485, + "parameters": [ + "a", + "var" + ], + "start_line": 313, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "getarrdocsign", + "long_name": "getarrdocsign( a , var )", + "filename": "capi_maps.py", + "nloc": 14, + "complexity": 5, + "token_count": 108, + "parameters": [ + "a", + "var" + ], + "start_line": 373, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "getinit", + "long_name": "getinit( a , var )", + "filename": "capi_maps.py", + "nloc": 24, + "complexity": 12, + "token_count": 241, + "parameters": [ + "a", + "var" + ], + "start_line": 388, + "end_line": 412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "sign2map", + "long_name": "sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 83, + "complexity": 30, + "token_count": 829, + "parameters": [ + "a", + "var" + ], + "start_line": 414, + "end_line": 510, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 97, + "top_nesting_level": 0 + }, + { + "name": "routsign2map", + "long_name": "routsign2map( rout )", + "filename": "capi_maps.py", + "nloc": 65, + "complexity": 26, + "token_count": 583, + "parameters": [ + "rout" + ], + "start_line": 512, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "modsign2map", + "long_name": "modsign2map( m )", + "filename": "capi_maps.py", + "nloc": 20, + "complexity": 9, + "token_count": 183, + "parameters": [ + "m" + ], + "start_line": 585, + "end_line": 608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "cb_sign2map", + "long_name": "cb_sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 14, + "complexity": 5, + "token_count": 133, + "parameters": [ + "a", + "var" + ], + "start_line": 610, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "cb_routsign2map", + "long_name": "cb_routsign2map( rout , um )", + "filename": "capi_maps.py", + "nloc": 73, + "complexity": 21, + "token_count": 494, + "parameters": [ + "rout", + "um" + ], + "start_line": 625, + "end_line": 701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "common_sign2map", + "long_name": "common_sign2map( a , var )", + "filename": "capi_maps.py", + "nloc": 19, + "complexity": 7, + "token_count": 177, + "parameters": [ + "a", + "var" + ], + "start_line": 703, + "end_line": 721, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 651, + "complexity": 182, + "token_count": 5093, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/cb_rules.py", + "new_path": "numpy/f2py/cb_rules.py", + "filename": "cb_rules.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n Copyright 2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/07/20 11:27:58 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nBuild call-back mechanism for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/07/20 11:27:58 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.53 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\n#from capi_maps import *\nimport cfuncs\n\n################## Rules for callback function ##############\n\ncb_routine_rules={\n 'cbtypedefs':'typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);',\n 'body':\"\"\"\n#begintitle#\nPyObject *#name#_capi = NULL;/*was Py_None*/\nPyTupleObject *#name#_args_capi = NULL;\nint #name#_nofargs = 0;\njmp_buf #name#_jmpbuf;\n/*typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);*/\n#static# #rctype# #callbackname# (#optargs##args##strarglens##noargs#) {\n\\tPyTupleObject *capi_arglist = #name#_args_capi;\n\\tPyObject *capi_return = NULL;\n\\tPyObject *capi_tmp = NULL;\n\\tint capi_j,capi_i = 0;\n\\tint capi_longjmp_ok = 1;\n#decl#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_start_clock();\n#endif\n\\tCFUNCSMESS(\\\"cb:Call-back function #name# (maxnofargs=#maxnofargs#(-#nofoptargs#))\\\\n\\\");\n\\tCFUNCSMESSPY(\\\"cb:#name#_capi=\\\",#name#_capi);\n\\tif (#name#_capi==NULL) {\n\\t\\tcapi_longjmp_ok = 0;\n\\t\\t#name#_capi = PyObject_GetAttrString(#modulename#_module,\\\"#argname#\\\");\n\\t}\n\\tif (#name#_capi==NULL) {\n\\t\\tPyErr_SetString(#modulename#_error,\\\"cb: Callback #argname# not defined (as an argument or module #modulename# attribute).\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n\\tif (PyCObject_Check(#name#_capi)) {\n\\t#name#_typedef #name#_cptr;\n\\t#name#_cptr = PyCObject_AsVoidPtr(#name#_capi);\n\\t#returncptr#(*#name#_cptr)(#optargs_nm##args_nm#);\n\\t#return#\n\\t}\n\\tif (capi_arglist==NULL) {\n\\t\\tcapi_longjmp_ok = 0;\n\\t\\tcapi_tmp = PyObject_GetAttrString(#modulename#_module,\\\"#argname#_extra_args\\\");\n\\t\\tif (capi_tmp) {\n\\t\\t\\tcapi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);\n\\t\\t\\tif (capi_arglist==NULL) {\n\\t\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"Failed to convert #modulename#.#argname#_extra_args to tuple.\\\\n\\\");\n\\t\\t\\t\\tgoto capi_fail;\n\\t\\t\\t}\n\\t\\t} else {\n\\t\\t\\tPyErr_Clear();\n\\t\\t\\tcapi_arglist = (PyTupleObject *)Py_BuildValue(\\\"()\\\");\n\\t\\t}\n\\t}\n\\tif (capi_arglist == NULL) {\n\\t\\tPyErr_SetString(#modulename#_error,\\\"Callback #argname# argument list is not set.\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n#setdims#\n#pyobjfrom#\n\\tCFUNCSMESSPY(\\\"cb:capi_arglist=\\\",capi_arglist);\n\\tCFUNCSMESS(\\\"cb:Call-back calling Python function #argname#.\\\\n\\\");\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_start_call_clock();\n#endif\n\\tcapi_return = PyObject_CallObject(#name#_capi,(PyObject *)capi_arglist);\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_stop_call_clock();\n#endif\n\\tCFUNCSMESSPY(\\\"cb:capi_return=\\\",capi_return);\n\\tif (capi_return == NULL) {\n\\t\\tfprintf(stderr,\\\"capi_return is NULL\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n\\tif (capi_return == Py_None) {\n\\t\\tPy_DECREF(capi_return);\n\\t\\tcapi_return = Py_BuildValue(\\\"()\\\");\n\\t}\n\\telse if (!PyTuple_Check(capi_return)) {\n\\t\\tcapi_return = Py_BuildValue(\\\"(N)\\\",capi_return);\n\\t}\n\\tcapi_j = PyTuple_Size(capi_return);\n\\tcapi_i = 0;\n#frompyobj#\n\\tCFUNCSMESS(\\\"cb:#name#:successful\\\\n\\\");\n\\tPy_DECREF(capi_return);\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_stop_clock();\n#endif\n\\tgoto capi_return_pt;\ncapi_fail:\n\\tfprintf(stderr,\\\"Call-back #name# failed.\\\\n\\\");\n\\tPy_XDECREF(capi_return);\n\\tif (capi_longjmp_ok)\n\\t\\tlongjmp(#name#_jmpbuf,-1);\ncapi_return_pt:\n\\t;\n#return#\n}\n#endtitle#\n\"\"\",\n 'need':['setjmp.h','CFUNCSMESS'],\n 'maxnofargs':'#maxnofargs#',\n 'nofoptargs':'#nofoptargs#',\n 'docstr':\"\"\"\\\n\\tdef #argname#(#docsignature#): return #docreturn#\\\\n\\\\\n#docstrsigns#\"\"\",\n 'latexdocstr':\"\"\"\n{{}\\\\verb@def #argname#(#latexdocsignature#): return #docreturn#@{}}\n#routnote#\n\n#latexdocstrsigns#\"\"\",\n 'docstrshort':'def #argname#(#docsignature#): return #docreturn#'\n }\ncb_rout_rules=[\n {# Init\n 'separatorsfor':{'decl':'\\n',\n 'args':',','optargs':'','pyobjfrom':'\\n','freemem':'\\n',\n 'args_td':',','optargs_td':'',\n 'args_nm':',','optargs_nm':'',\n 'frompyobj':'\\n','setdims':'\\n',\n 'docstrsigns':'\\\\n\"\\n\"',\n 'latexdocstrsigns':'\\n',\n 'latexdocstrreq':'\\n','latexdocstropt':'\\n',\n 'latexdocstrout':'\\n','latexdocstrcbs':'\\n',\n },\n 'decl':'/*decl*/','pyobjfrom':'/*pyobjfrom*/','frompyobj':'/*frompyobj*/',\n 'args':[],'optargs':'','return':'','strarglens':'','freemem':'/*freemem*/',\n 'args_td':[],'optargs_td':'','strarglens_td':'',\n 'args_nm':[],'optargs_nm':'','strarglens_nm':'',\n 'noargs':'',\n 'setdims':'/*setdims*/',\n 'docstrsigns':'','latexdocstrsigns':'',\n 'docstrreq':'\\tRequired arguments:',\n 'docstropt':'\\tOptional arguments:',\n 'docstrout':'\\tReturn objects:',\n 'docstrcbs':'\\tCall-back functions:',\n 'docreturn':'','docsign':'','docsignopt':'',\n 'latexdocstrreq':'\\\\noindent Required arguments:',\n 'latexdocstropt':'\\\\noindent Optional arguments:',\n 'latexdocstrout':'\\\\noindent Return objects:',\n 'latexdocstrcbs':'\\\\noindent Call-back functions:',\n 'routnote':{hasnote:'--- #note#',l_not(hasnote):''},\n },{ # Function\n 'decl':'\\t#ctype# return_value;',\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\");'},\n '\\tif (capi_j>capi_i)\\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\");',\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",return_value);'}\n ],\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},'GETSCALARFROMPYTUPLE'],\n 'return':'\\treturn return_value;',\n '_check':l_and(isfunction,l_not(isstringfunction),l_not(iscomplexfunction))\n },\n {# String function\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#name#:%d:\\\\n\",return_value_len);'},\n 'args':'#ctype# return_value,int return_value_len',\n 'args_nm':'return_value,&return_value_len',\n 'args_td':'#ctype# ,int',\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\\\\\"\");'},\n \"\"\"\\tif (capi_j>capi_i)\n\\t\\tGETSTRFROMPYTUPLE(capi_return,capi_i++,return_value,return_value_len);\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#\\\\\".\\\\n\",return_value);'}\n ],\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},\n 'string.h','GETSTRFROMPYTUPLE'],\n 'return':'return;',\n '_check':isstringfunction\n },\n {# Complex function\n 'optargs':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n#ctype# *return_value\n#endif\n\"\"\",\n 'optargs_nm':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\nreturn_value\n#endif\n\"\"\",\n 'optargs_td':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n#ctype# *\n#endif\n\"\"\",\n 'decl':\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\t#ctype# return_value;\n#endif\n\"\"\",\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\");'},\n \"\"\"\\\n\\tif (capi_j>capi_i)\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,\\\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\\\");\n#else\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,return_value,#ctype#,\\\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\\\");\n#endif\n\"\"\",\n {debugcapi:\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\tfprintf(stderr,\\\"#showvalueformat#.\\\\n\\\",(return_value).r,(return_value).i);\n#else\n\\tfprintf(stderr,\\\"#showvalueformat#.\\\\n\\\",(*return_value).r,(*return_value).i);\n#endif\n\n\"\"\"}\n ],\n 'return':\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\treturn return_value;\n#else\n\\treturn;\n#endif\n\"\"\",\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},\n 'string.h','GETSCALARFROMPYTUPLE','#ctype#'],\n '_check':iscomplexfunction\n },\n {'docstrout':'\\t\\t#pydocsignout#',\n 'latexdocstrout':['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {hasnote:'--- #note#'}],\n 'docreturn':'#rname#,',\n '_check':isfunction},\n {'_check':issubroutine,'return':'return;'}\n ]\n\ncb_arg_rules=[\n { # Doc\n 'docstropt':{l_and(isoptional,isintent_nothide):'\\t\\t#pydocsign#'},\n 'docstrreq':{l_and(isrequired,isintent_nothide):'\\t\\t#pydocsign#'},\n 'docstrout':{isintent_out:'\\t\\t#pydocsignout#'},\n 'latexdocstropt':{l_and(isoptional,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrreq':{l_and(isrequired,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrout':{isintent_out:['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {l_and(hasnote,isintent_hide):'--- #note#',\n l_and(hasnote,isintent_nothide):'--- See above.'}]},\n 'docsign':{l_and(isrequired,isintent_nothide):'#varname#,'},\n 'docsignopt':{l_and(isoptional,isintent_nothide):'#varname#,'},\n 'depend':''\n },\n {\n 'args':{\n l_and (isscalar,isintent_c):'#ctype# #varname#',\n l_and (isscalar,l_not(isintent_c)):'#ctype# *#varname#_cb_capi',\n isarray:'#ctype# *#varname#',\n isstring:'#ctype# #varname#'\n },\n 'args_nm':{\n l_and (isscalar,isintent_c):'#varname#',\n l_and (isscalar,l_not(isintent_c)):'#varname#_cb_capi',\n isarray:'#varname#',\n isstring:'#varname#'\n },\n 'args_td':{\n l_and (isscalar,isintent_c):'#ctype#',\n l_and (isscalar,l_not(isintent_c)):'#ctype# *',\n isarray:'#ctype# *',\n isstring:'#ctype#'\n },\n 'strarglens':{isstring:',int #varname#_cb_len'}, # untested with multiple args\n 'strarglens_td':{isstring:',int'}, # untested with multiple args\n\n },\n { # Scalars\n 'decl':{l_not(isintent_c):'\\t#ctype# #varname#=(*#varname#_cb_capi);'},\n 'error': {l_and(isintent_c,isintent_out,\n throw_error('intent(c,out) is forbidden for callback scalar arguments')):\\\n ''},\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\");'},\n {isintent_out:'\\tif (capi_j>capi_i)\\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,#varname#_cb_capi,#ctype#,\"#ctype#_from_pyobj failed in converting argument #varname# of call-back function #name# to C #ctype#\\\\n\");'},\n {l_and(debugcapi,l_and(l_not(iscomplex),isintent_c)):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",#varname#);'},\n {l_and(debugcapi,l_and(l_not(iscomplex),l_not(isintent_c))):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",*#varname#_cb_capi);'},\n {l_and(debugcapi,l_and(iscomplex,isintent_c)):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",(#varname#).r,(#varname#).i);'},\n {l_and(debugcapi,l_and(iscomplex,l_not(isintent_c))):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",(*#varname#_cb_capi).r,(*#varname#_cb_capi).i);'},\n ],\n 'need':[{isintent_out:['#ctype#_from_pyobj','GETSCALARFROMPYTUPLE']},\n {debugcapi:'CFUNCSMESS'}],\n '_check':isscalar\n },{\n 'pyobjfrom':[{isintent_in:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyobj_from_#ctype#1(#varname#)))\n\\t\\t\\tgoto capi_fail;\"\"\"},\n {isintent_inout:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname#_cb_capi)))\n\\t\\t\\tgoto capi_fail;\"\"\"}],\n 'need':[{isintent_in:'pyobj_from_#ctype#1'},\n {isintent_inout:'pyarr_from_p_#ctype#1'},\n {iscomplex:'#ctype#'}],\n '_check':l_and(isscalar,isintent_nothide),\n '_optional':''\n },{# String\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\\\\\"\");'},\n \"\"\"\\tif (capi_j>capi_i)\n\\t\\tGETSTRFROMPYTUPLE(capi_return,capi_i++,#varname#,#varname#_cb_len);\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#\\\\\":%d:.\\\\n\",#varname#,#varname#_cb_len);'},\n ],\n 'need':['#ctype#','GETSTRFROMPYTUPLE',\n {debugcapi:'CFUNCSMESS'},'string.h'],\n '_check':l_and(isstring,isintent_out)\n },{\n 'pyobjfrom':[{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#varname#=\\\\\"#showvalueformat#\\\\\":%d:\\\\n\",#varname#,#varname#_cb_len);'},\n {isintent_in:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyobj_from_#ctype#1(#varname#)))\n\\t\\t\\tgoto capi_fail;\"\"\"},\n {isintent_inout:\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tint #varname#_cb_dims[] = {#varname#_cb_len};\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname#,#varname#_cb_dims)))\n\\t\\t\\tgoto capi_fail;\n\\t}\"\"\"}],\n 'need':[{isintent_in:'pyobj_from_#ctype#1'},\n {isintent_inout:'pyarr_from_p_#ctype#1'}],\n '_check':l_and(isstring,isintent_nothide),\n '_optional':''\n },\n# Array ...\n {\n 'decl':'\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n 'setdims':'\\t#cbsetdims#;',\n '_check':isarray,\n '_depend':''\n },\n {\n 'pyobjfrom':[{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#varname#\\\\n\");'},\n {isintent_c:\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname#_Dims,#atype#,NULL,(char*)#varname#,0,CARRAY_FLAGS,NULL); /*XXX: Hmm, what will destroy this array??? */\n\"\"\",\n l_not(isintent_c):\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname#_Dims,#atype#,NULL,(char*)#varname#,0,FARRAY_FLAGS,NULL); /*XXX: Hmm, what will destroy this array??? */\n\"\"\",\n }, \n \"\"\"\n\\t\\tif (tmp_arr==NULL)\n\\t\\t\\tgoto capi_fail;\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,(PyObject *)tmp_arr))\n\\t\\t\\tgoto capi_fail;\n}\"\"\"],\n '_check':l_and(isarray,isintent_nothide,l_or(isintent_in,isintent_inout)),\n '_optional':'',\n },{\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\");'},\n \"\"\"\\tif (capi_j>capi_i) {\n\\t\\tPyArrayObject *rv_cb_arr = NULL;\n\\t\\tif ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;\n\\t\\trv_cb_arr = array_from_pyobj(#atype#,#varname#_Dims,#rank#,F2PY_INTENT_IN\"\"\",\n {isintent_c:'|F2PY_INTENT_C'},\n \"\"\",capi_tmp);\n\\t\\tif (rv_cb_arr == NULL) {\n\\t\\t\\tfprintf(stderr,\\\"rv_cb_arr is NULL\\\\n\\\");\n\\t\\t\\tgoto capi_fail;\n\\t\\t}\n\\t\\tMEMCOPY(#varname#,rv_cb_arr->data,PyArray_NBYTES(rv_cb_arr));\n\\t\\tif (capi_tmp != (PyObject *)rv_cb_arr) {\n\\t\\t\\tPy_DECREF(rv_cb_arr);\n\\t\\t}\n\\t}\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"<-.\\\\n\");'},\n ],\n 'need':['MEMCOPY',{iscomplexarray:'#ctype#'}],\n '_check':l_and(isarray,isintent_out)\n },{\n 'docreturn':'#varname#,',\n '_check':isintent_out\n }\n ]\n\n################## Build call-back module #############\ncb_map={}\ndef buildcallbacks(m):\n global cb_map\n cb_map[m['name']]=[]\n for bi in m['body']:\n if bi['block']=='interface':\n for b in bi['body']:\n if b:\n buildcallback(b,m['name'])\n else:\n errmess('warning: empty body for %s\\n' % (m['name']))\n\ndef buildcallback(rout,um):\n global cb_map\n outmess('\\tConstructing call-back function \"cb_%s_in_%s\"\\n'%(rout['name'],um))\n args,depargs=getargs(rout)\n capi_maps.depargs=depargs\n var=rout['vars']\n vrd=capi_maps.cb_routsign2map(rout,um)\n rd=dictappend({},vrd)\n cb_map[um].append([rout['name'],rd['name']])\n for r in cb_rout_rules:\n if (r.has_key('_check') and r['_check'](rout)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,rout)\n rd=dictappend(rd,ar)\n savevrd={}\n for a in args:\n vrd=capi_maps.cb_sign2map(a,var[a])\n savevrd[a]=vrd\n for r in cb_arg_rules:\n if r.has_key('_depend'): continue\n if r.has_key('_optional') and isoptional(var[a]): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in args:\n vrd=savevrd[a]\n for r in cb_arg_rules:\n if r.has_key('_depend'): continue\n if (not r.has_key('_optional')) or (r.has_key('_optional') and isrequired(var[a])): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in depargs:\n vrd=savevrd[a]\n for r in cb_arg_rules:\n if not r.has_key('_depend'): continue\n if r.has_key('_optional'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n if rd.has_key('args') and rd.has_key('optargs'):\n if type(rd['optargs'])==type([]):\n rd['optargs']=rd['optargs']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n rd['optargs_nm']=rd['optargs_nm']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n rd['optargs_td']=rd['optargs_td']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n if type(rd['docreturn'])==types.ListType:\n rd['docreturn']=stripcomma(replace('#docreturn#',{'docreturn':rd['docreturn']}))\n optargs=stripcomma(replace('#docsignopt#',\n {'docsignopt':rd['docsignopt']}\n ))\n if optargs=='':\n rd['docsignature']=stripcomma(replace('#docsign#',{'docsign':rd['docsign']}))\n else:\n rd['docsignature']=replace('#docsign#[#docsignopt#]',\n {'docsign':rd['docsign'],\n 'docsignopt':optargs,\n })\n rd['latexdocsignature']=string.replace(rd['docsignature'],'_','\\\\_')\n rd['latexdocsignature']=string.replace(rd['latexdocsignature'],',',', ')\n rd['docstrsigns']=[]\n rd['latexdocstrsigns']=[]\n for k in ['docstrreq','docstropt','docstrout','docstrcbs']:\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['docstrsigns']=rd['docstrsigns']+rd[k]\n k='latex'+k\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['latexdocstrsigns']=rd['latexdocstrsigns']+rd[k][0:1]+\\\n ['\\\\begin{description}']+rd[k][1:]+\\\n ['\\\\end{description}']\n if not rd.has_key('args'):\n rd['args']=''\n rd['args_td']=''\n rd['args_nm']=''\n if not (rd.get('args') or rd.get('optargs') or rd.get('strarglens')):\n rd['noargs'] = 'void'\n\n ar=applyrules(cb_routine_rules,rd)\n cfuncs.callbacks[rd['name']]=ar['body']\n if type(ar['need'])==types.StringType:\n ar['need']=[ar['need']]\n\n if rd.has_key('need'):\n for t in cfuncs.typedefs.keys():\n if t in rd['need']:\n ar['need'].append(t)\n\n cfuncs.typedefs_generated[rd['name']+'_typedef'] = ar['cbtypedefs']\n ar['need'].append(rd['name']+'_typedef')\n cfuncs.needs[rd['name']]=ar['need']\n\n capi_maps.lcb2_map[rd['name']]={'maxnofargs':ar['maxnofargs'],\n 'nofoptargs':ar['nofoptargs'],\n 'docstr':ar['docstr'],\n 'latexdocstr':ar['latexdocstr'],\n 'argname':rd['argname']\n }\n outmess('\\t %s\\n'%(ar['docstrshort']))\n #print ar['body']\n return\n################## Build call-back function #############\n\n\n\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nBuild call-back mechanism for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/07/20 11:27:58 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.53 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\n#from capi_maps import *\nimport cfuncs\n\n################## Rules for callback function ##############\n\ncb_routine_rules={\n 'cbtypedefs':'typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);',\n 'body':\"\"\"\n#begintitle#\nPyObject *#name#_capi = NULL;/*was Py_None*/\nPyTupleObject *#name#_args_capi = NULL;\nint #name#_nofargs = 0;\njmp_buf #name#_jmpbuf;\n/*typedef #rctype#(*#name#_typedef)(#optargs_td##args_td##strarglens_td##noargs#);*/\n#static# #rctype# #callbackname# (#optargs##args##strarglens##noargs#) {\n\\tPyTupleObject *capi_arglist = #name#_args_capi;\n\\tPyObject *capi_return = NULL;\n\\tPyObject *capi_tmp = NULL;\n\\tint capi_j,capi_i = 0;\n\\tint capi_longjmp_ok = 1;\n#decl#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_start_clock();\n#endif\n\\tCFUNCSMESS(\\\"cb:Call-back function #name# (maxnofargs=#maxnofargs#(-#nofoptargs#))\\\\n\\\");\n\\tCFUNCSMESSPY(\\\"cb:#name#_capi=\\\",#name#_capi);\n\\tif (#name#_capi==NULL) {\n\\t\\tcapi_longjmp_ok = 0;\n\\t\\t#name#_capi = PyObject_GetAttrString(#modulename#_module,\\\"#argname#\\\");\n\\t}\n\\tif (#name#_capi==NULL) {\n\\t\\tPyErr_SetString(#modulename#_error,\\\"cb: Callback #argname# not defined (as an argument or module #modulename# attribute).\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n\\tif (PyCObject_Check(#name#_capi)) {\n\\t#name#_typedef #name#_cptr;\n\\t#name#_cptr = PyCObject_AsVoidPtr(#name#_capi);\n\\t#returncptr#(*#name#_cptr)(#optargs_nm##args_nm#);\n\\t#return#\n\\t}\n\\tif (capi_arglist==NULL) {\n\\t\\tcapi_longjmp_ok = 0;\n\\t\\tcapi_tmp = PyObject_GetAttrString(#modulename#_module,\\\"#argname#_extra_args\\\");\n\\t\\tif (capi_tmp) {\n\\t\\t\\tcapi_arglist = (PyTupleObject *)PySequence_Tuple(capi_tmp);\n\\t\\t\\tif (capi_arglist==NULL) {\n\\t\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"Failed to convert #modulename#.#argname#_extra_args to tuple.\\\\n\\\");\n\\t\\t\\t\\tgoto capi_fail;\n\\t\\t\\t}\n\\t\\t} else {\n\\t\\t\\tPyErr_Clear();\n\\t\\t\\tcapi_arglist = (PyTupleObject *)Py_BuildValue(\\\"()\\\");\n\\t\\t}\n\\t}\n\\tif (capi_arglist == NULL) {\n\\t\\tPyErr_SetString(#modulename#_error,\\\"Callback #argname# argument list is not set.\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n#setdims#\n#pyobjfrom#\n\\tCFUNCSMESSPY(\\\"cb:capi_arglist=\\\",capi_arglist);\n\\tCFUNCSMESS(\\\"cb:Call-back calling Python function #argname#.\\\\n\\\");\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_start_call_clock();\n#endif\n\\tcapi_return = PyObject_CallObject(#name#_capi,(PyObject *)capi_arglist);\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_stop_call_clock();\n#endif\n\\tCFUNCSMESSPY(\\\"cb:capi_return=\\\",capi_return);\n\\tif (capi_return == NULL) {\n\\t\\tfprintf(stderr,\\\"capi_return is NULL\\\\n\\\");\n\\t\\tgoto capi_fail;\n\\t}\n\\tif (capi_return == Py_None) {\n\\t\\tPy_DECREF(capi_return);\n\\t\\tcapi_return = Py_BuildValue(\\\"()\\\");\n\\t}\n\\telse if (!PyTuple_Check(capi_return)) {\n\\t\\tcapi_return = Py_BuildValue(\\\"(N)\\\",capi_return);\n\\t}\n\\tcapi_j = PyTuple_Size(capi_return);\n\\tcapi_i = 0;\n#frompyobj#\n\\tCFUNCSMESS(\\\"cb:#name#:successful\\\\n\\\");\n\\tPy_DECREF(capi_return);\n#ifdef F2PY_REPORT_ATEXIT\nf2py_cb_stop_clock();\n#endif\n\\tgoto capi_return_pt;\ncapi_fail:\n\\tfprintf(stderr,\\\"Call-back #name# failed.\\\\n\\\");\n\\tPy_XDECREF(capi_return);\n\\tif (capi_longjmp_ok)\n\\t\\tlongjmp(#name#_jmpbuf,-1);\ncapi_return_pt:\n\\t;\n#return#\n}\n#endtitle#\n\"\"\",\n 'need':['setjmp.h','CFUNCSMESS'],\n 'maxnofargs':'#maxnofargs#',\n 'nofoptargs':'#nofoptargs#',\n 'docstr':\"\"\"\\\n\\tdef #argname#(#docsignature#): return #docreturn#\\\\n\\\\\n#docstrsigns#\"\"\",\n 'latexdocstr':\"\"\"\n{{}\\\\verb@def #argname#(#latexdocsignature#): return #docreturn#@{}}\n#routnote#\n\n#latexdocstrsigns#\"\"\",\n 'docstrshort':'def #argname#(#docsignature#): return #docreturn#'\n }\ncb_rout_rules=[\n {# Init\n 'separatorsfor':{'decl':'\\n',\n 'args':',','optargs':'','pyobjfrom':'\\n','freemem':'\\n',\n 'args_td':',','optargs_td':'',\n 'args_nm':',','optargs_nm':'',\n 'frompyobj':'\\n','setdims':'\\n',\n 'docstrsigns':'\\\\n\"\\n\"',\n 'latexdocstrsigns':'\\n',\n 'latexdocstrreq':'\\n','latexdocstropt':'\\n',\n 'latexdocstrout':'\\n','latexdocstrcbs':'\\n',\n },\n 'decl':'/*decl*/','pyobjfrom':'/*pyobjfrom*/','frompyobj':'/*frompyobj*/',\n 'args':[],'optargs':'','return':'','strarglens':'','freemem':'/*freemem*/',\n 'args_td':[],'optargs_td':'','strarglens_td':'',\n 'args_nm':[],'optargs_nm':'','strarglens_nm':'',\n 'noargs':'',\n 'setdims':'/*setdims*/',\n 'docstrsigns':'','latexdocstrsigns':'',\n 'docstrreq':'\\tRequired arguments:',\n 'docstropt':'\\tOptional arguments:',\n 'docstrout':'\\tReturn objects:',\n 'docstrcbs':'\\tCall-back functions:',\n 'docreturn':'','docsign':'','docsignopt':'',\n 'latexdocstrreq':'\\\\noindent Required arguments:',\n 'latexdocstropt':'\\\\noindent Optional arguments:',\n 'latexdocstrout':'\\\\noindent Return objects:',\n 'latexdocstrcbs':'\\\\noindent Call-back functions:',\n 'routnote':{hasnote:'--- #note#',l_not(hasnote):''},\n },{ # Function\n 'decl':'\\t#ctype# return_value;',\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\");'},\n '\\tif (capi_j>capi_i)\\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\");',\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",return_value);'}\n ],\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},'GETSCALARFROMPYTUPLE'],\n 'return':'\\treturn return_value;',\n '_check':l_and(isfunction,l_not(isstringfunction),l_not(iscomplexfunction))\n },\n {# String function\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#name#:%d:\\\\n\",return_value_len);'},\n 'args':'#ctype# return_value,int return_value_len',\n 'args_nm':'return_value,&return_value_len',\n 'args_td':'#ctype# ,int',\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\\\\\"\");'},\n \"\"\"\\tif (capi_j>capi_i)\n\\t\\tGETSTRFROMPYTUPLE(capi_return,capi_i++,return_value,return_value_len);\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#\\\\\".\\\\n\",return_value);'}\n ],\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},\n 'string.h','GETSTRFROMPYTUPLE'],\n 'return':'return;',\n '_check':isstringfunction\n },\n {# Complex function\n 'optargs':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n#ctype# *return_value\n#endif\n\"\"\",\n 'optargs_nm':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\nreturn_value\n#endif\n\"\"\",\n 'optargs_td':\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n#ctype# *\n#endif\n\"\"\",\n 'decl':\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\t#ctype# return_value;\n#endif\n\"\"\",\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting return_value->\");'},\n \"\"\"\\\n\\tif (capi_j>capi_i)\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,&return_value,#ctype#,\\\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\\\");\n#else\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,return_value,#ctype#,\\\"#ctype#_from_pyobj failed in converting return_value of call-back function #name# to C #ctype#\\\\n\\\");\n#endif\n\"\"\",\n {debugcapi:\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\tfprintf(stderr,\\\"#showvalueformat#.\\\\n\\\",(return_value).r,(return_value).i);\n#else\n\\tfprintf(stderr,\\\"#showvalueformat#.\\\\n\\\",(*return_value).r,(*return_value).i);\n#endif\n\n\"\"\"}\n ],\n 'return':\"\"\"\n#ifdef F2PY_CB_RETURNCOMPLEX\n\\treturn return_value;\n#else\n\\treturn;\n#endif\n\"\"\",\n 'need':['#ctype#_from_pyobj',{debugcapi:'CFUNCSMESS'},\n 'string.h','GETSCALARFROMPYTUPLE','#ctype#'],\n '_check':iscomplexfunction\n },\n {'docstrout':'\\t\\t#pydocsignout#',\n 'latexdocstrout':['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {hasnote:'--- #note#'}],\n 'docreturn':'#rname#,',\n '_check':isfunction},\n {'_check':issubroutine,'return':'return;'}\n ]\n\ncb_arg_rules=[\n { # Doc\n 'docstropt':{l_and(isoptional,isintent_nothide):'\\t\\t#pydocsign#'},\n 'docstrreq':{l_and(isrequired,isintent_nothide):'\\t\\t#pydocsign#'},\n 'docstrout':{isintent_out:'\\t\\t#pydocsignout#'},\n 'latexdocstropt':{l_and(isoptional,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrreq':{l_and(isrequired,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrout':{isintent_out:['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {l_and(hasnote,isintent_hide):'--- #note#',\n l_and(hasnote,isintent_nothide):'--- See above.'}]},\n 'docsign':{l_and(isrequired,isintent_nothide):'#varname#,'},\n 'docsignopt':{l_and(isoptional,isintent_nothide):'#varname#,'},\n 'depend':''\n },\n {\n 'args':{\n l_and (isscalar,isintent_c):'#ctype# #varname#',\n l_and (isscalar,l_not(isintent_c)):'#ctype# *#varname#_cb_capi',\n isarray:'#ctype# *#varname#',\n isstring:'#ctype# #varname#'\n },\n 'args_nm':{\n l_and (isscalar,isintent_c):'#varname#',\n l_and (isscalar,l_not(isintent_c)):'#varname#_cb_capi',\n isarray:'#varname#',\n isstring:'#varname#'\n },\n 'args_td':{\n l_and (isscalar,isintent_c):'#ctype#',\n l_and (isscalar,l_not(isintent_c)):'#ctype# *',\n isarray:'#ctype# *',\n isstring:'#ctype#'\n },\n 'strarglens':{isstring:',int #varname#_cb_len'}, # untested with multiple args\n 'strarglens_td':{isstring:',int'}, # untested with multiple args\n\n },\n { # Scalars\n 'decl':{l_not(isintent_c):'\\t#ctype# #varname#=(*#varname#_cb_capi);'},\n 'error': {l_and(isintent_c,isintent_out,\n throw_error('intent(c,out) is forbidden for callback scalar arguments')):\\\n ''},\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\");'},\n {isintent_out:'\\tif (capi_j>capi_i)\\n\\t\\tGETSCALARFROMPYTUPLE(capi_return,capi_i++,#varname#_cb_capi,#ctype#,\"#ctype#_from_pyobj failed in converting argument #varname# of call-back function #name# to C #ctype#\\\\n\");'},\n {l_and(debugcapi,l_and(l_not(iscomplex),isintent_c)):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",#varname#);'},\n {l_and(debugcapi,l_and(l_not(iscomplex),l_not(isintent_c))):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",*#varname#_cb_capi);'},\n {l_and(debugcapi,l_and(iscomplex,isintent_c)):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",(#varname#).r,(#varname#).i);'},\n {l_and(debugcapi,l_and(iscomplex,l_not(isintent_c))):'\\tfprintf(stderr,\"#showvalueformat#.\\\\n\",(*#varname#_cb_capi).r,(*#varname#_cb_capi).i);'},\n ],\n 'need':[{isintent_out:['#ctype#_from_pyobj','GETSCALARFROMPYTUPLE']},\n {debugcapi:'CFUNCSMESS'}],\n '_check':isscalar\n },{\n 'pyobjfrom':[{isintent_in:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyobj_from_#ctype#1(#varname#)))\n\\t\\t\\tgoto capi_fail;\"\"\"},\n {isintent_inout:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname#_cb_capi)))\n\\t\\t\\tgoto capi_fail;\"\"\"}],\n 'need':[{isintent_in:'pyobj_from_#ctype#1'},\n {isintent_inout:'pyarr_from_p_#ctype#1'},\n {iscomplex:'#ctype#'}],\n '_check':l_and(isscalar,isintent_nothide),\n '_optional':''\n },{# String\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\\\\\"\");'},\n \"\"\"\\tif (capi_j>capi_i)\n\\t\\tGETSTRFROMPYTUPLE(capi_return,capi_i++,#varname#,#varname#_cb_len);\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"#showvalueformat#\\\\\":%d:.\\\\n\",#varname#,#varname#_cb_len);'},\n ],\n 'need':['#ctype#','GETSTRFROMPYTUPLE',\n {debugcapi:'CFUNCSMESS'},'string.h'],\n '_check':l_and(isstring,isintent_out)\n },{\n 'pyobjfrom':[{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#varname#=\\\\\"#showvalueformat#\\\\\":%d:\\\\n\",#varname#,#varname#_cb_len);'},\n {isintent_in:\"\"\"\\\n\\tif (#name#_nofargs>capi_i)\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyobj_from_#ctype#1(#varname#)))\n\\t\\t\\tgoto capi_fail;\"\"\"},\n {isintent_inout:\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tint #varname#_cb_dims[] = {#varname#_cb_len};\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,pyarr_from_p_#ctype#1(#varname#,#varname#_cb_dims)))\n\\t\\t\\tgoto capi_fail;\n\\t}\"\"\"}],\n 'need':[{isintent_in:'pyobj_from_#ctype#1'},\n {isintent_inout:'pyarr_from_p_#ctype#1'}],\n '_check':l_and(isstring,isintent_nothide),\n '_optional':''\n },\n# Array ...\n {\n 'decl':'\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n 'setdims':'\\t#cbsetdims#;',\n '_check':isarray,\n '_depend':''\n },\n {\n 'pyobjfrom':[{debugcapi:'\\tfprintf(stderr,\"debug-capi:cb:#varname#\\\\n\");'},\n {isintent_c:\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname#_Dims,#atype#,NULL,(char*)#varname#,0,CARRAY_FLAGS,NULL); /*XXX: Hmm, what will destroy this array??? */\n\"\"\",\n l_not(isintent_c):\"\"\"\\\n\\tif (#name#_nofargs>capi_i) {\n\\t\\tPyArrayObject *tmp_arr = (PyArrayObject *)PyArray_New(&PyArray_Type,#rank#,#varname#_Dims,#atype#,NULL,(char*)#varname#,0,FARRAY_FLAGS,NULL); /*XXX: Hmm, what will destroy this array??? */\n\"\"\",\n }, \n \"\"\"\n\\t\\tif (tmp_arr==NULL)\n\\t\\t\\tgoto capi_fail;\n\\t\\tif (PyTuple_SetItem((PyObject *)capi_arglist,capi_i++,(PyObject *)tmp_arr))\n\\t\\t\\tgoto capi_fail;\n}\"\"\"],\n '_check':l_and(isarray,isintent_nothide,l_or(isintent_in,isintent_inout)),\n '_optional':'',\n },{\n 'frompyobj':[{debugcapi:'\\tCFUNCSMESS(\"cb:Getting #varname#->\");'},\n \"\"\"\\tif (capi_j>capi_i) {\n\\t\\tPyArrayObject *rv_cb_arr = NULL;\n\\t\\tif ((capi_tmp = PyTuple_GetItem(capi_return,capi_i++))==NULL) goto capi_fail;\n\\t\\trv_cb_arr = array_from_pyobj(#atype#,#varname#_Dims,#rank#,F2PY_INTENT_IN\"\"\",\n {isintent_c:'|F2PY_INTENT_C'},\n \"\"\",capi_tmp);\n\\t\\tif (rv_cb_arr == NULL) {\n\\t\\t\\tfprintf(stderr,\\\"rv_cb_arr is NULL\\\\n\\\");\n\\t\\t\\tgoto capi_fail;\n\\t\\t}\n\\t\\tMEMCOPY(#varname#,rv_cb_arr->data,PyArray_NBYTES(rv_cb_arr));\n\\t\\tif (capi_tmp != (PyObject *)rv_cb_arr) {\n\\t\\t\\tPy_DECREF(rv_cb_arr);\n\\t\\t}\n\\t}\"\"\",\n {debugcapi:'\\tfprintf(stderr,\"<-.\\\\n\");'},\n ],\n 'need':['MEMCOPY',{iscomplexarray:'#ctype#'}],\n '_check':l_and(isarray,isintent_out)\n },{\n 'docreturn':'#varname#,',\n '_check':isintent_out\n }\n ]\n\n################## Build call-back module #############\ncb_map={}\ndef buildcallbacks(m):\n global cb_map\n cb_map[m['name']]=[]\n for bi in m['body']:\n if bi['block']=='interface':\n for b in bi['body']:\n if b:\n buildcallback(b,m['name'])\n else:\n errmess('warning: empty body for %s\\n' % (m['name']))\n\ndef buildcallback(rout,um):\n global cb_map\n outmess('\\tConstructing call-back function \"cb_%s_in_%s\"\\n'%(rout['name'],um))\n args,depargs=getargs(rout)\n capi_maps.depargs=depargs\n var=rout['vars']\n vrd=capi_maps.cb_routsign2map(rout,um)\n rd=dictappend({},vrd)\n cb_map[um].append([rout['name'],rd['name']])\n for r in cb_rout_rules:\n if (r.has_key('_check') and r['_check'](rout)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,rout)\n rd=dictappend(rd,ar)\n savevrd={}\n for a in args:\n vrd=capi_maps.cb_sign2map(a,var[a])\n savevrd[a]=vrd\n for r in cb_arg_rules:\n if r.has_key('_depend'): continue\n if r.has_key('_optional') and isoptional(var[a]): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in args:\n vrd=savevrd[a]\n for r in cb_arg_rules:\n if r.has_key('_depend'): continue\n if (not r.has_key('_optional')) or (r.has_key('_optional') and isrequired(var[a])): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in depargs:\n vrd=savevrd[a]\n for r in cb_arg_rules:\n if not r.has_key('_depend'): continue\n if r.has_key('_optional'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n if rd.has_key('args') and rd.has_key('optargs'):\n if type(rd['optargs'])==type([]):\n rd['optargs']=rd['optargs']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n rd['optargs_nm']=rd['optargs_nm']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n rd['optargs_td']=rd['optargs_td']+[\"\"\"\n#ifndef F2PY_CB_RETURNCOMPLEX\n,\n#endif\n\"\"\"]\n if type(rd['docreturn'])==types.ListType:\n rd['docreturn']=stripcomma(replace('#docreturn#',{'docreturn':rd['docreturn']}))\n optargs=stripcomma(replace('#docsignopt#',\n {'docsignopt':rd['docsignopt']}\n ))\n if optargs=='':\n rd['docsignature']=stripcomma(replace('#docsign#',{'docsign':rd['docsign']}))\n else:\n rd['docsignature']=replace('#docsign#[#docsignopt#]',\n {'docsign':rd['docsign'],\n 'docsignopt':optargs,\n })\n rd['latexdocsignature']=string.replace(rd['docsignature'],'_','\\\\_')\n rd['latexdocsignature']=string.replace(rd['latexdocsignature'],',',', ')\n rd['docstrsigns']=[]\n rd['latexdocstrsigns']=[]\n for k in ['docstrreq','docstropt','docstrout','docstrcbs']:\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['docstrsigns']=rd['docstrsigns']+rd[k]\n k='latex'+k\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['latexdocstrsigns']=rd['latexdocstrsigns']+rd[k][0:1]+\\\n ['\\\\begin{description}']+rd[k][1:]+\\\n ['\\\\end{description}']\n if not rd.has_key('args'):\n rd['args']=''\n rd['args_td']=''\n rd['args_nm']=''\n if not (rd.get('args') or rd.get('optargs') or rd.get('strarglens')):\n rd['noargs'] = 'void'\n\n ar=applyrules(cb_routine_rules,rd)\n cfuncs.callbacks[rd['name']]=ar['body']\n if type(ar['need'])==types.StringType:\n ar['need']=[ar['need']]\n\n if rd.has_key('need'):\n for t in cfuncs.typedefs.keys():\n if t in rd['need']:\n ar['need'].append(t)\n\n cfuncs.typedefs_generated[rd['name']+'_typedef'] = ar['cbtypedefs']\n ar['need'].append(rd['name']+'_typedef')\n cfuncs.needs[rd['name']]=ar['need']\n\n capi_maps.lcb2_map[rd['name']]={'maxnofargs':ar['maxnofargs'],\n 'nofoptargs':ar['nofoptargs'],\n 'docstr':ar['docstr'],\n 'latexdocstr':ar['latexdocstr'],\n 'argname':rd['argname']\n }\n outmess('\\t %s\\n'%(ar['docstrshort']))\n #print ar['body']\n return\n################## Build call-back function #############\n\n\n\n\n\n", + "methods": [ + { + "name": "buildcallbacks", + "long_name": "buildcallbacks( m )", + "filename": "cb_rules.py", + "nloc": 10, + "complexity": 5, + "token_count": 66, + "parameters": [ + "m" + ], + "start_line": 405, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "buildcallback", + "long_name": "buildcallback( rout , um )", + "filename": "cb_rules.py", + "nloc": 108, + "complexity": 50, + "token_count": 1035, + "parameters": [ + "rout", + "um" + ], + "start_line": 416, + "end_line": 528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 113, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "buildcallbacks", + "long_name": "buildcallbacks( m )", + "filename": "cb_rules.py", + "nloc": 10, + "complexity": 5, + "token_count": 66, + "parameters": [ + "m" + ], + "start_line": 405, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "buildcallback", + "long_name": "buildcallback( rout , um )", + "filename": "cb_rules.py", + "nloc": 108, + "complexity": 50, + "token_count": 1035, + "parameters": [ + "rout", + "um" + ], + "start_line": 416, + "end_line": 528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 113, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 507, + "complexity": 55, + "token_count": 2323, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/cfuncs.py", + "new_path": "numpy/f2py/cfuncs.py", + "filename": "cfuncs.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,7 +7,7 @@\n Copyright 1999,2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/05/06 11:42:34 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nC declarations, CPP macros, and C functions for f2py2e.\nOnly required declarations/macros/functions will be used.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 11:42:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.75 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport types,sys,copy,os\nerrmess=sys.stderr.write\n\n##################### Definitions ##################\n\noutneeds={'includes0':[],'includes':[],'typedefs':[],'typedefs_generated':[],\n 'userincludes':[],\n 'cppmacros':[],'cfuncs':[],'callbacks':[],'f90modhooks':[],\n 'commonhooks':[]}\nneeds={}\nincludes0={'includes0':'/*need_includes0*/'}\nincludes={'includes':'/*need_includes*/'}\nuserincludes={'userincludes':'/*need_userincludes*/'}\ntypedefs={'typedefs':'/*need_typedefs*/'}\ntypedefs_generated={'typedefs_generated':'/*need_typedefs_generated*/'}\ncppmacros={'cppmacros':'/*need_cppmacros*/'}\ncfuncs={'cfuncs':'/*need_cfuncs*/'}\ncallbacks={'callbacks':'/*need_callbacks*/'}\nf90modhooks={'f90modhooks':'/*need_f90modhooks*/',\n 'initf90modhooksstatic':'/*initf90modhooksstatic*/',\n 'initf90modhooksdynamic':'/*initf90modhooksdynamic*/',\n }\ncommonhooks={'commonhooks':'/*need_commonhooks*/',\n 'initcommonhooks':'/*need_initcommonhooks*/',\n }\n\n############ Includes ###################\n\nincludes0['math.h']='#include '\nincludes0['string.h']='#include '\nincludes0['setjmp.h']='#include '\n\nincludes['Python.h']='#include \"Python.h\"'\nneeds['arrayobject.h']=['Python.h']\nincludes['arrayobject.h']='''#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API\n#include \"arrayobject.h\"'''\n\nincludes['arrayobject.h']='#include \"fortranobject.h\"'\n\n############# Type definitions ###############\n\ntypedefs['unsigned_char']='typedef unsigned char unsigned_char;'\ntypedefs['unsigned_short']='typedef unsigned short unsigned_short;'\ntypedefs['unsigned_long']='typedef unsigned long unsigned_long;'\ntypedefs['signed_char']='typedef signed char signed_char;'\ntypedefs['long_long']=\"\"\"\\\n#ifdef _WIN32\ntypedef __int64 long_long;\n#else\ntypedef long long long_long;\ntypedef unsigned long long unsigned_long_long;\n#endif\n\"\"\"\ntypedefs['insinged_long_long']=\"\"\"\\\n#ifdef _WIN32\ntypedef __uint64 long_long;\n#else\ntypedef unsigned long long unsigned_long_long;\n#endif\n\"\"\"\ntypedefs['long_double']=\"\"\"\\\n#ifndef _LONG_DOUBLE\ntypedef long double long_double;\n#endif\n\"\"\"\ntypedefs['complex_long_double']='typedef struct {long double r,i;} complex_long_double;'\ntypedefs['complex_float']='typedef struct {float r,i;} complex_float;'\ntypedefs['complex_double']='typedef struct {double r,i;} complex_double;'\ntypedefs['string']=\"\"\"typedef char * string;\"\"\"\n\n\n############### CPP macros ####################\ncppmacros['CFUNCSMESS']=\"\"\"\\\n#ifdef DEBUGCFUNCS\n#define CFUNCSMESS(mess) fprintf(stderr,\\\"debug-capi:\\\"mess);\n#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \\\\\n\\tPyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\\\\n\\tfprintf(stderr,\\\"\\\\n\\\");\n#else\n#define CFUNCSMESS(mess)\n#define CFUNCSMESSPY(mess,obj)\n#endif\n\"\"\"\ncppmacros['F_FUNC']=\"\"\"\\\n#if defined(PREPEND_FORTRAN)\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) _##F\n#else\n#define F_FUNC(f,F) _##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) _##F##_\n#else\n#define F_FUNC(f,F) _##f##_\n#endif\n#endif\n#else\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) F\n#else\n#define F_FUNC(f,F) f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) F##_\n#else\n#define F_FUNC(f,F) f##_\n#endif\n#endif\n#endif\n#if defined(UNDERSCORE_G77)\n#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)\n#else\n#define F_FUNC_US(f,F) F_FUNC(f,F)\n#endif\n\"\"\"\ncppmacros['F_WRAPPEDFUNC']=\"\"\"\\\n#if defined(PREPEND_FORTRAN)\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F\n#else\n#define F_WRAPPEDFUNC(f,F) _f2pywrap##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_\n#else\n#define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_\n#endif\n#endif\n#else\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F\n#else\n#define F_WRAPPEDFUNC(f,F) f2pywrap##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_\n#else\n#define F_WRAPPEDFUNC(f,F) f2pywrap##f##_\n#endif\n#endif\n#endif\n#if defined(UNDERSCORE_G77)\n#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_)\n#else\n#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F)\n#endif\n\"\"\"\ncppmacros['F_MODFUNC']=\"\"\"\\\n#if defined(F90MOD2CCONV1) /*E.g. Compaq Fortran */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f\n#else\n#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f ## _\n#endif\n#endif\n\n#if defined(F90MOD2CCONV2) /*E.g. IBM XL Fortran, not tested though */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f\n#else\n#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f ## _\n#endif\n#endif\n\n#if defined(F90MOD2CCONV3) /*E.g. MIPSPro Compilers */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) f ## .in. ## m\n#else\n#define F_MODFUNCNAME(m,f) f ## .in. ## m ## _\n#endif\n#endif\n/*\n#if defined(UPPERCASE_FORTRAN)\n#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(M,F)\n#else\n#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(m,f)\n#endif\n*/\n\n#define F_MODFUNC(m,f) (*(f2pymodstruct##m##.##f))\n\"\"\"\ncppmacros['SWAPUNSAFE']=\"\"\"\\\n#define SWAP(a,b) (size_t)(a) = ((size_t)(a) ^ (size_t)(b));\\\\\n (size_t)(b) = ((size_t)(a) ^ (size_t)(b));\\\\\n (size_t)(a) = ((size_t)(a) ^ (size_t)(b))\n\"\"\"\ncppmacros['SWAP']=\"\"\"\\\n#define SWAP(a,b,t) {\\\\\n\\tt *c;\\\\\n\\tc = a;\\\\\n\\ta = b;\\\\\n\\tb = c;}\n\"\"\"\n#cppmacros['ISCONTIGUOUS']='#define ISCONTIGUOUS(m) ((m)->flags & CONTIGUOUS)'\ncppmacros['PRINTPYOBJERR']=\"\"\"\\\n#define PRINTPYOBJERR(obj)\\\\\n\\tfprintf(stderr,\\\"#modulename#.error is related to \\\");\\\\\n\\tPyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\\\\n\\tfprintf(stderr,\\\"\\\\n\\\");\n\"\"\"\ncppmacros['MINMAX']=\"\"\"\\\n#ifndef MAX\n#define MAX(a,b) ((a > b) ? (a) : (b))\n#endif\n#ifndef MIN\n#define MIN(a,b) ((a < b) ? (a) : (b))\n#endif\n\"\"\"\ncppmacros['len..']=\"\"\"\\\n#define rank(var) var ## _Rank\n#define shape(var,dim) var ## _Dims[dim]\n#define old_rank(var) (((PyArrayObject *)(capi_ ## var ## _tmp))->nd)\n#define old_shape(var,dim) (((PyArrayObject *)(capi_ ## var ## _tmp))->dimensions[dim])\n#define fshape(var,dim) shape(var,rank(var)-dim-1)\n#define len(var) shape(var,0)\n#define flen(var) fshape(var,0)\n#define size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp))\n/* #define index(i) capi_i ## i */\n#define slen(var) capi_ ## var ## _len\n\"\"\"\n\ncppmacros['pyobj_from_char1']='#define pyobj_from_char1(v) (PyInt_FromLong(v))'\ncppmacros['pyobj_from_short1']='#define pyobj_from_short1(v) (PyInt_FromLong(v))'\nneeds['pyobj_from_int1']=['signed_char']\ncppmacros['pyobj_from_int1']='#define pyobj_from_int1(v) (PyInt_FromLong(v))'\ncppmacros['pyobj_from_long1']='#define pyobj_from_long1(v) (PyLong_FromLong(v))'\nneeds['pyobj_from_long_long1']=['long_long']\ncppmacros['pyobj_from_long_long1']=\"\"\"\\\n#ifdef HAVE_LONG_LONG\n#define pyobj_from_long_long1(v) (PyLong_FromLongLong(v))\n#else\n#warning HAVE_LONG_LONG is not available. Redefining pyobj_from_long_long.\n#define pyobj_from_long_long1(v) (PyLong_FromLong(v))\n#endif\n\"\"\"\nneeds['pyobj_from_long_double1']=['long_double']\ncppmacros['pyobj_from_long_double1']='#define pyobj_from_long_double1(v) (PyFloat_FromDouble(v))'\ncppmacros['pyobj_from_double1']='#define pyobj_from_double1(v) (PyFloat_FromDouble(v))'\ncppmacros['pyobj_from_float1']='#define pyobj_from_float1(v) (PyFloat_FromDouble(v))'\nneeds['pyobj_from_complex_long_double1']=['complex_long_double']\ncppmacros['pyobj_from_complex_long_double1']='#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_complex_double1']=['complex_double']\ncppmacros['pyobj_from_complex_double1']='#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_complex_float1']=['complex_float']\ncppmacros['pyobj_from_complex_float1']='#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_string1']=['string']\ncppmacros['pyobj_from_string1']='#define pyobj_from_string1(v) (PyString_FromString((char *)v))'\nneeds['TRYPYARRAYTEMPLATE']=['PRINTPYOBJERR']\ncppmacros['TRYPYARRAYTEMPLATE']=\"\"\"\\\n/* New SciPy */\n#define TRYPYARRAYTEMPLATECHAR case PyArray_STRING: *(char *)(arr->data)=*v; break;\n#define TRYPYARRAYTEMPLATELONG case PyArray_LONG: *(long *)(arr->data)=*v; break;\n#define TRYPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data); break;\n\n#define TRYPYARRAYTEMPLATE(ctype,typecode) \\\\\n\tPyArrayObject *arr = NULL;\\\\\n\tif (!obj) return -2;\\\\\n\tif (!PyArray_Check(obj)) return -1;\\\\\n\tif (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\\\"TRYPYARRAYTEMPLATE:\\\");PRINTPYOBJERR(obj);return 0;}\\\\\n\tif (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\\\\n\tswitch (arr->descr->type_num) {\\\\\n\t\tcase PyArray_DOUBLE: *(double *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_INT: *(int *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONG: *(long *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_FLOAT: *(float *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CDOUBLE: *(double *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CFLOAT: *(float *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_UINT: *(uint *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\\\\n\tdefault: return -2;\\\\\n\t};\\\\\n\treturn 1\n\"\"\"\n\nneeds['TRYCOMPLEXPYARRAYTEMPLATE']=['PRINTPYOBJERR']\ncppmacros['TRYCOMPLEXPYARRAYTEMPLATE']=\"\"\"\\\n#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\n#define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\\\\\n\tPyArrayObject *arr = NULL;\\\\\n\tif (!obj) return -2;\\\\\n\tif (!PyArray_Check(obj)) return -1;\\\\\n if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\\\"TRYCOMPLEXPYARRAYTEMPLATE:\\\");PRINTPYOBJERR(obj);return 0;}\\\\\n\tif (arr->descr->type==typecode) {\\\\\n *(ctype *)(arr->data)=(*v).r;\\\\\n *(ctype *)(arr->data+sizeof(ctype))=(*v).i;\\\\\n return 1;\\\\\n }\\\\\n\tswitch (arr->descr->type_num) {\\\\\n\t\tcase PyArray_CDOUBLE: *(double *)(arr->data)=(*v).r;*(double *)(arr->data+sizeof(double))=(*v).i;break;\\\\\n\t\tcase PyArray_CFLOAT: *(float *)(arr->data)=(*v).r;*(float *)(arr->data+sizeof(float))=(*v).i;break;\\\\\n\t\tcase PyArray_DOUBLE: *(double *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONG: *(long *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_FLOAT: *(float *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_INT: *(int *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=(*v).r;*(longdouble *)(arr->data+sizeof(longdouble))=(*v).i;break;\\\\ \n case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\\\\\n\t\tdefault: return -2;\\\\\n\t};\\\\\n\treturn -1; \n\"\"\"\n## cppmacros['NUMFROMARROBJ']=\"\"\"\\\n## #define NUMFROMARROBJ(typenum,ctype) \\\\\n## \\tif (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\\\\n## \\telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\\\\n## \\tif (arr) {\\\\\n## \\t\\tif (arr->descr->type_num==PyArray_OBJECT) {\\\\\n## \\t\\t\\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\\\"\\\"))\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t} else {\\\\\n## \\t\\t\\t(arr->descr->cast[typenum])(arr->data,1,(char*)v,1,1);\\\\\n## \\t\\t}\\\\\n## \\t\\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\\\\n## \\t\\treturn 1;\\\\\n## \\t}\n## \"\"\"\n## #XXX: Note that CNUMFROMARROBJ is identical with NUMFROMARROBJ\n## cppmacros['CNUMFROMARROBJ']=\"\"\"\\\n## #define CNUMFROMARROBJ(typenum,ctype) \\\\\n## \\tif (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\\\\n## \\telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\\\\n## \\tif (arr) {\\\\\n## \\t\\tif (arr->descr->type_num==PyArray_OBJECT) {\\\\\n## \\t\\t\\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\\\"\\\"))\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t} else {\\\\\n## \\t\\t\\t(arr->descr->cast[typenum])((void *)(arr->data),1,(void *)(v),1,1);\\\\\n## \\t\\t}\\\\\n## \\t\\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\\\\n## \\t\\treturn 1;\\\\\n## \\t}\n## \"\"\"\n\n\nneeds['GETSTRFROMPYTUPLE']=['STRINGCOPYN','PRINTPYOBJERR']\ncppmacros['GETSTRFROMPYTUPLE']=\"\"\"\\\n#define GETSTRFROMPYTUPLE(tuple,index,str,len) {\\\\\n\\t\\tPyObject *rv_cb_str = PyTuple_GetItem((tuple),(index));\\\\\n\\t\\tif (rv_cb_str == NULL)\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t\\tif (PyString_Check(rv_cb_str)) {\\\\\n\\t\\t\\tstr[len-1]='\\\\0';\\\\\n\\t\\t\\tSTRINGCOPYN((str),PyString_AS_STRING((PyStringObject*)rv_cb_str),(len));\\\\\n\\t\\t} else {\\\\\n\\t\\t\\tPRINTPYOBJERR(rv_cb_str);\\\\\n\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"string object expected\\\");\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t\\t}\\\\\n\\t}\n\"\"\"\ncppmacros['GETSCALARFROMPYTUPLE']=\"\"\"\\\n#define GETSCALARFROMPYTUPLE(tuple,index,var,ctype,mess) {\\\\\n\\t\\tif ((capi_tmp = PyTuple_GetItem((tuple),(index)))==NULL) goto capi_fail;\\\\\n\\t\\tif (!(ctype ## _from_pyobj((var),capi_tmp,mess)))\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\n\nneeds['MEMCOPY']=['string.h']\ncppmacros['MEMCOPY']=\"\"\"\\\n#define MEMCOPY(to,from,n)\\\\\n\\tif ((memcpy(to,from,n)) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"memcpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\ncppmacros['STRINGMALLOC']=\"\"\"\\\n#define STRINGMALLOC(str,len)\\\\\n\\tif ((str = (string)malloc(sizeof(char)*(len+1))) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"out of memory\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t} else {\\\\\n\\t\\t(str)[len] = '\\\\0';\\\\\n\\t}\n\"\"\"\ncppmacros['STRINGFREE']=\"\"\"\\\n#define STRINGFREE(str)\\\\\n\\tif (!(str == NULL)) free(str);\n\"\"\"\nneeds['STRINGCOPYN']=['string.h']\ncppmacros['STRINGCOPYN']=\"\"\"\\\n#define STRINGCOPYN(to,from,n)\\\\\n\\tif ((strncpy(to,from,sizeof(char)*(n))) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"strncpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t} else if (strlen(to)<(n)) {\\\\\n\\t\\tmemset((to)+strlen(to), ' ', (n)-strlen(to));\\\\\n\\t} /* Padding with spaces instead of nulls. */\n\"\"\"\nneeds['STRINGCOPY']=['string.h']\ncppmacros['STRINGCOPY']=\"\"\"\\\n#define STRINGCOPY(to,from)\\\\\n\\tif ((strcpy(to,from)) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"strcpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\ncppmacros['CHECKGENERIC']=\"\"\"\\\n#define CHECKGENERIC(check,tcheck,name) \\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKARRAY']=\"\"\"\\\n#define CHECKARRAY(check,tcheck,name) \\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKSTRING']=\"\"\"\\\n#define CHECKSTRING(check,tcheck,name,show,var)\\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\tfprintf(stderr,show\\\"\\\\n\\\",slen(var),var);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKSCALAR']=\"\"\"\\\n#define CHECKSCALAR(check,tcheck,name,show,var)\\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\tfprintf(stderr,show\\\"\\\\n\\\",var);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\n## cppmacros['CHECKDIMS']=\"\"\"\\\n## #define CHECKDIMS(dims,rank) \\\\\n## \\tfor (int i=0;i<(rank);i++)\\\\\n## \\t\\tif (dims[i]<0) {\\\\\n## \\t\\t\\tfprintf(stderr,\\\"Unspecified array argument requires a complete dimension specification.\\\\n\\\");\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t}\n## \"\"\"\ncppmacros['ARRSIZE']='#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))'\ncppmacros['OLDPYNUM']=\"\"\"\\\n#ifdef OLDPYNUM\n#error You need to intall Numeric Python version 13 or higher. Get it from http:/sourceforge.net/project/?group_id=1369\n#endif\n\"\"\"\n################# C functions ###############\n\ncfuncs['calcarrindex']=\"\"\"\\\nstatic int calcarrindex(int *i,PyArrayObject *arr) {\n\\tint k,ii = i[0];\n\\tfor (k=1; k < arr->nd; k++)\n\\t\\tii += (ii*(arr->dimensions[k] - 1)+i[k]); /* assuming contiguous arr */\n\\treturn ii;\n}\"\"\"\ncfuncs['calcarrindextr']=\"\"\"\\\nstatic int calcarrindextr(int *i,PyArrayObject *arr) {\n\\tint k,ii = i[arr->nd-1];\n\\tfor (k=1; k < arr->nd; k++)\n\\t\\tii += (ii*(arr->dimensions[arr->nd-k-1] - 1)+i[arr->nd-k-1]); /* assuming contiguous arr */\n\\treturn ii;\n}\"\"\"\ncfuncs['forcomb']=\"\"\"\\\nstatic struct { int nd;intp *d;int *i,*i_tr,tr; } forcombcache;\nstatic int initforcomb(intp *dims,int nd,int tr) {\n int k;\n if (dims==NULL) return 0;\n if (nd<0) return 0;\n forcombcache.nd = nd;\n forcombcache.d = dims;\n forcombcache.tr = tr;\n if ((forcombcache.i = (int *)malloc(sizeof(int)*nd))==NULL) return 0;\n if ((forcombcache.i_tr = (int *)malloc(sizeof(int)*nd))==NULL) return 0;\n for (k=1;kdata,str,PyArray_NBYTES(arr)); }\n\\treturn 1;\ncapi_fail:\n\\tPRINTPYOBJERR(obj);\n\\tPyErr_SetString(#modulename#_error,\\\"try_pyarr_from_string failed\\\");\n\\treturn 0;\n}\n\"\"\"\nneeds['string_from_pyobj']=['string','STRINGMALLOC','STRINGCOPYN']\ncfuncs['string_from_pyobj']=\"\"\"\\\nstatic int string_from_pyobj(string *str,int *len,const string inistr,PyObject *obj,const char *errmess) {\n\\tPyArrayObject *arr = NULL;\n\\tPyObject *tmp = NULL;\n#ifdef DEBUGCFUNCS\nfprintf(stderr,\\\"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\\\\n\\\",(char*)str,*len,(char *)inistr,obj);\n#endif\n\\tif (obj == Py_None) {\n\\t\\tif (*len == -1)\n\\t\\t\\t*len = strlen(inistr); /* Will this cause problems? */\n\\t\\tSTRINGMALLOC(*str,*len);\n\\t\\tSTRINGCOPYN(*str,inistr,*len);\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_Check(obj)) {\n\\t\\tif ((arr = (PyArrayObject *)obj) == NULL)\n\\t\\t\\tgoto capi_fail;\n\\t\\tif (!ISCONTIGUOUS(arr)) {\n\\t\\t\\tPyErr_SetString(PyExc_ValueError,\\\"array object is non-contiguous.\\\");\n\\t\\t\\tgoto capi_fail;\n\\t\\t}\n\\t\\tif (*len == -1)\n\\t\\t\\t*len = (arr->descr->elsize)*PyArray_SIZE(arr);\n\\t\\tSTRINGMALLOC(*str,*len);\n\\t\\tSTRINGCOPYN(*str,arr->data,*len);\n\\t\\treturn 1;\n\\t}\n\\tif (PyString_Check(obj)) {\n\\t\\ttmp = obj;\n\\t\\tPy_INCREF(tmp);\n\\t}\n\\telse\n\\t\\ttmp = PyObject_Str(obj);\n\\tif (tmp == NULL) goto capi_fail;\n\\tif (*len == -1)\n\\t\\t*len = PyString_GET_SIZE(tmp);\n\\tSTRINGMALLOC(*str,*len);\n\\tSTRINGCOPYN(*str,PyString_AS_STRING(tmp),*len);\n\\tPy_DECREF(tmp);\n\\treturn 1;\ncapi_fail:\n\\tPy_XDECREF(tmp);\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['char_from_pyobj']=['int_from_pyobj']\ncfuncs['char_from_pyobj']=\"\"\"\\\nstatic int char_from_pyobj(char* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (char)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['signed_char_from_pyobj']=['int_from_pyobj','signed_char']\ncfuncs['signed_char_from_pyobj']=\"\"\"\\\nstatic int signed_char_from_pyobj(signed_char* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (signed_char)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['short_from_pyobj']=['int_from_pyobj']\ncfuncs['short_from_pyobj']=\"\"\"\\\nstatic int short_from_pyobj(short* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (short)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['int_from_pyobj']=\"\"\"\\\nstatic int int_from_pyobj(int* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = (int)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Int(obj);\n\\tif (tmp) {\n\\t\\t*v = PyInt_AS_LONG(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['long_from_pyobj']=\"\"\"\\\nstatic int long_from_pyobj(long* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Int(obj);\n\\tif (tmp) {\n\\t\\t*v = PyInt_AS_LONG(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (long_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['long_long_from_pyobj']=['long_long']\ncfuncs['long_long_from_pyobj']=\"\"\"\\\nstatic int long_long_from_pyobj(long_long* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyLong_Check(obj)) {\n\\t\\t*v = PyLong_AsLongLong(obj);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = (long_long)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Long(obj);\n\\tif (tmp) {\n\\t\\t*v = PyLong_AsLongLong(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (long_long_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['long_double_from_pyobj']=['double_from_pyobj','long_double']\ncfuncs['long_double_from_pyobj']=\"\"\"\\\nstatic int long_double_from_pyobj(long_double* v,PyObject *obj,const char *errmess) {\n\\tdouble d=0;\n\\tif (PyArray_CheckScalar(obj)){\n\\t\\tif PyArray_IsScalar(obj, LongDouble) {\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t\\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_LONGDOUBLE) {\n\\t\\t\\t(*v) = *((longdouble *)PyArray_DATA(obj))\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t}\n\\tif (double_from_pyobj(&d,obj,errmess)) {\n\\t\\t*v = (long_double)d;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['double_from_pyobj']=\"\"\"\\\nstatic int double_from_pyobj(double* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyFloat_Check(obj)) {\n#ifdef __sgi\n\\t\\t*v = PyFloat_AsDouble(obj);\n#else\n\\t\\t*v = PyFloat_AS_DOUBLE(obj);\n#endif\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Float(obj);\n\\tif (tmp) {\n#ifdef __sgi\n\\t\\t*v = PyFloat_AsDouble(tmp);\n#else\n\\t\\t*v = PyFloat_AS_DOUBLE(tmp);\n#endif\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['float_from_pyobj']=['double_from_pyobj']\ncfuncs['float_from_pyobj']=\"\"\"\\\nstatic int float_from_pyobj(float* v,PyObject *obj,const char *errmess) {\n\\tdouble d=0.0;\n\\tif (double_from_pyobj(&d,obj,errmess)) {\n\\t\\t*v = (float)d;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_long_double_from_pyobj']=['complex_long_double','long_double',\n 'complex_double_from_pyobj']\ncfuncs['complex_long_double_from_pyobj']=\"\"\"\\\nstatic int complex_long_double_from_pyobj(complex_long_double* v,PyObject *obj,const char *errmess) {\n\\tcomplex_double cd={0.0,0.0};\n\\tif (PyArray_CheckScalar(obj)){\n\\t\\tif PyArray_IsScalar(obj, CLongDouble) {\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t\\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_CLONGDOUBLE) {\n\\t\\t\\t(*v).r = ((clongdouble *)PyArray_DATA(obj))->real;\n\\t\\t\\t(*v).i = ((clongdouble *)PyArray_DATA(obj))->imag;\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t}\n\\tif (complex_double_from_pyobj(&cd,obj,errmess)) {\n\\t\\t(*v).r = (long_double)cd.r;\n\\t\\t(*v).i = (long_double)cd.i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_double_from_pyobj']=['complex_double']\ncfuncs['complex_double_from_pyobj']=\"\"\"\\\nstatic int complex_double_from_pyobj(complex_double* v,PyObject *obj,const char *errmess) {\n\\tPy_complex c;\n\\tif (PyComplex_Check(obj)) {\n\\t\\tc=PyComplex_AsCComplex(obj);\n\\t\\t(*v).r=c.real, (*v).i=c.imag;\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_IsScalar(obj, ComplexFloating)) {\n\\t\\tif (PyArray_IsScalar(obj, CFloat)) {\n\\t\\t\\tcfloat new;\n\\t\\t\\tPyArray_ScalarAsCtype(obj, &new);\n\\t\\t\\t(*v).r = (double)new.real;\n\\t\\t\\t(*v).i = (double)new.imag;\n\\t\\t}\n\\t\\telse if (PyArray_IsScalar(obj, CLongDouble)) {\n\\t\\t\\tclongdouble new;\n\\t\\t\\tPyArray_ScalarAsCtype(obj, &new);\n\\t\\t\\t(*v).r = (double)new.real;\n\\t\\t\\t(*v).i = (double)new.imag;\n\\t\\t}\n\\t\\telse { /* if (PyArray_IsScalar(obj, CDouble)) */\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t}\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_CheckScalar(obj)) { /* 0-dim array or still array scalar */\n\\t\\tPyObject *arr;\n\\t\\tif (PyArray_Check(obj)) {\n\\t\\t\\tarr = PyArray_Cast((PyArrayObject *)obj, PyArray_CDOUBLE);\n\\t\\t}\n\\t\\telse {\n\\t\\t\\tarr = PyArray_FromScalar(obj, PyArray_DescrFromType(PyArray_CDOUBLE));\n\\t\\t}\n\\t\\tif (arr==NULL) return 0;\n\\t\\t(*v).r = ((cdouble *)PyArray_DATA(arr))->real;\n\\t\\t(*v).i = ((cdouble *)PyArray_DATA(arr))->imag;\n\\t\\treturn 1;\n\\t}\n\\t/* Python does not provide PyNumber_Complex function :-( */\n\\t(*v).i=0.0;\n\\tif (PyFloat_Check(obj)) {\n#ifdef __sgi\n\\t\\t(*v).r = PyFloat_AsDouble(obj);\n#else\n\\t\\t(*v).r = PyFloat_AS_DOUBLE(obj);\n#endif\n\\t\\treturn 1;\n\\t}\n\\tif (PyInt_Check(obj)) {\n\\t\\t(*v).r = (double)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\tif (PyLong_Check(obj)) {\n\\t\\t(*v).r = PyLong_AsDouble(obj);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PySequence_Check(obj) && (!PyString_Check(obj))) {\n\\t\\tPyObject *tmp = PySequence_GetItem(obj,0);\n\\t\\tif (tmp) {\n\\t\\t\\tif (complex_double_from_pyobj(v,tmp,errmess)) {\n\\t\\t\\t\\tPy_DECREF(tmp);\n\\t\\t\\t\\treturn 1;\n\\t\\t\\t}\n\\t\\t\\tPy_DECREF(tmp);\n\\t\\t}\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL)\n\\t\\t\\terr = PyExc_TypeError;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_float_from_pyobj']=['complex_float','complex_double_from_pyobj']\ncfuncs['complex_float_from_pyobj']=\"\"\"\\\nstatic int complex_float_from_pyobj(complex_float* v,PyObject *obj,const char *errmess) {\n\\tcomplex_double cd={0.0,0.0};\n\\tif (complex_double_from_pyobj(&cd,obj,errmess)) {\n\\t\\t(*v).r = (float)cd.r;\n\\t\\t(*v).i = (float)cd.i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['try_pyarr_from_char']=['pyobj_from_char1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_char']='static int try_pyarr_from_char(PyObject* obj,char* v) {\\n\\tTRYPYARRAYTEMPLATE(char,\\'c\\');\\n}\\n'\nneeds['try_pyarr_from_signed_char']=['TRYPYARRAYTEMPLATE','unsigned_char']\ncfuncs['try_pyarr_from_unsigned_char']='static int try_pyarr_from_unsigned_char(PyObject* obj,unsigned_char* v) {\\n\\tTRYPYARRAYTEMPLATE(unsigned_char,\\'b\\');\\n}\\n'\nneeds['try_pyarr_from_signed_char']=['TRYPYARRAYTEMPLATE','signed_char']\ncfuncs['try_pyarr_from_signed_char']='static int try_pyarr_from_signed_char(PyObject* obj,signed_char* v) {\\n\\tTRYPYARRAYTEMPLATE(signed_char,\\'1\\');\\n}\\n'\nneeds['try_pyarr_from_short']=['pyobj_from_short1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_short']='static int try_pyarr_from_short(PyObject* obj,short* v) {\\n\\tTRYPYARRAYTEMPLATE(short,\\'s\\');\\n}\\n'\nneeds['try_pyarr_from_int']=['pyobj_from_int1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_int']='static int try_pyarr_from_int(PyObject* obj,int* v) {\\n\\tTRYPYARRAYTEMPLATE(int,\\'i\\');\\n}\\n'\nneeds['try_pyarr_from_long']=['pyobj_from_long1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_long']='static int try_pyarr_from_long(PyObject* obj,long* v) {\\n\\tTRYPYARRAYTEMPLATE(long,\\'l\\');\\n}\\n'\nneeds['try_pyarr_from_long_long']=['pyobj_from_long_long1','TRYPYARRAYTEMPLATE','long_long']\ncfuncs['try_pyarr_from_long_long']='static int try_pyarr_from_long_long(PyObject* obj,long_long* v) {\\n\\tTRYPYARRAYTEMPLATE(long_long,\\'L\\');\\n}\\n'\nneeds['try_pyarr_from_float']=['pyobj_from_float1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_float']='static int try_pyarr_from_float(PyObject* obj,float* v) {\\n\\tTRYPYARRAYTEMPLATE(float,\\'f\\');\\n}\\n'\nneeds['try_pyarr_from_double']=['pyobj_from_double1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_double']='static int try_pyarr_from_double(PyObject* obj,double* v) {\\n\\tTRYPYARRAYTEMPLATE(double,\\'d\\');\\n}\\n'\nneeds['try_pyarr_from_complex_float']=['pyobj_from_complex_float1','TRYCOMPLEXPYARRAYTEMPLATE','complex_float']\ncfuncs['try_pyarr_from_complex_float']='static int try_pyarr_from_complex_float(PyObject* obj,complex_float* v) {\\n\\tTRYCOMPLEXPYARRAYTEMPLATE(float,\\'F\\');\\n}\\n'\nneeds['try_pyarr_from_complex_double']=['pyobj_from_complex_double1','TRYCOMPLEXPYARRAYTEMPLATE','complex_double']\ncfuncs['try_pyarr_from_complex_double']='static int try_pyarr_from_complex_double(PyObject* obj,complex_double* v) {\\n\\tTRYCOMPLEXPYARRAYTEMPLATE(double,\\'D\\');\\n}\\n'\n\nneeds['create_cb_arglist']=['CFUNCSMESS','PRINTPYOBJERR','MINMAX']\ncfuncs['create_cb_arglist']=\"\"\"\\\nstatic int create_cb_arglist(PyObject* fun,PyTupleObject* xa,const int maxnofargs,const int nofoptargs,int *nofargs,PyTupleObject **args,const char *errmess) {\n\\tPyObject *tmp = NULL;\n\\tPyObject *tmp_fun = NULL;\n\\tint tot,opt,ext,siz,i,di=0;\n\\tCFUNCSMESS(\\\"create_cb_arglist\\\\n\\\");\n\\ttot=opt=ext=siz=0;\n\\t/* Get the total number of arguments */\n\\tif (PyFunction_Check(fun))\n\\t\\ttmp_fun = fun;\n\\telse {\n\\t\\tdi = 1;\n\\t\\tif (PyObject_HasAttrString(fun,\\\"im_func\\\")) {\n\\t\\t\\ttmp_fun = PyObject_GetAttrString(fun,\\\"im_func\\\");\n\\t\\t}\n\\t\\telse if (PyObject_HasAttrString(fun,\\\"__call__\\\")) {\n\\t\\t\\ttmp = PyObject_GetAttrString(fun,\\\"__call__\\\");\n\\t\\t\\tif (PyObject_HasAttrString(tmp,\\\"im_func\\\"))\n\\t\\t\\t\\ttmp_fun = PyObject_GetAttrString(tmp,\\\"im_func\\\");\n\\t\\t\\telse {\n\\t\\t\\t\\ttmp_fun = fun; /* built-in function */\n\\t\\t\\t\\ttot = maxnofargs;\n\\t\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\t\\ttot += PyTuple_Size((PyObject *)xa);\n\\t\\t\\t}\n\\t\\t\\tPy_XDECREF(tmp);\n\\t\\t}\n\\t\\telse if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {\n\\t\\t\\ttot = maxnofargs;\n\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\ttot += PyTuple_Size((PyObject *)xa);\n\\t\\t\\ttmp_fun = fun;\n\\t\\t}\n\\t\\telse if (PyCObject_Check(fun)) {\n\\t\\t\\ttot = maxnofargs;\n\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\text = PyTuple_Size((PyObject *)xa);\n\\t\\t\\tif(ext>0) {\n\\t\\t\\t\\tfprintf(stderr,\\\"extra arguments tuple cannot be used with CObject call-back\\\\n\\\");\n\\t\\t\\t\\tgoto capi_fail;\n\\t\\t\\t}\n\\t\\t\\ttmp_fun = fun;\n\\t\\t}\n\\t}\nif (tmp_fun==NULL) {\nfprintf(stderr,\\\"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\\\\n\\\",(fun==NULL?\\\"NULL\\\":fun->ob_type->tp_name));\ngoto capi_fail;\n}\n\\tif (PyObject_HasAttrString(tmp_fun,\\\"func_code\\\")) {\n\\t\\tif (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\\\"func_code\\\"),\\\"co_argcount\\\"))\n\\t\\t\\ttot = PyInt_AsLong(PyObject_GetAttrString(tmp,\\\"co_argcount\\\")) - di;\n\\t\\tPy_XDECREF(tmp);\n\\t}\n\\t/* Get the number of optional arguments */\n\\tif (PyObject_HasAttrString(tmp_fun,\\\"func_defaults\\\"))\n\\t\\tif (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\\\"func_defaults\\\")))\n\\t\\t\\topt = PyTuple_Size(tmp);\n\\t\\tPy_XDECREF(tmp);\n\\t/* Get the number of extra arguments */\n\\tif (xa != NULL)\n\\t\\text = PyTuple_Size((PyObject *)xa);\n\\t/* Calculate the size of call-backs argument list */\n\\tsiz = MIN(maxnofargs+ext,tot);\n\\t*nofargs = MAX(0,siz-ext);\n#ifdef DEBUGCFUNCS\n\\tfprintf(stderr,\\\"debug-capi:create_cb_arglist:maxnofargs(-nofoptargs),tot,opt,ext,siz,nofargs=%d(-%d),%d,%d,%d,%d,%d\\\\n\\\",maxnofargs,nofoptargs,tot,opt,ext,siz,*nofargs);\n#endif\n\\tif (siz0:\n if not needs.has_key(outneeds[n][0]):\n out.append(outneeds[n][0])\n del outneeds[n][0]\n else:\n flag=0\n for k in outneeds[n][1:]:\n if k in needs[outneeds[n][0]]:\n flag=1\n break\n if flag:\n outneeds[n]=outneeds[n][1:]+[outneeds[n][0]]\n else:\n out.append(outneeds[n][0])\n del outneeds[n][0]\n if saveout and (0 not in map(lambda x,y:x==y,saveout,outneeds[n])):\n print n,saveout\n errmess('get_needs: no progress in sorting needs, probably circular dependence, skipping.\\n')\n out=out+saveout\n break\n saveout=copy.copy(outneeds[n])\n if out==[]: out=[n]\n res[n]=out\n return res\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nC declarations, CPP macros, and C functions for f2py2e.\nOnly required declarations/macros/functions will be used.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 11:42:34 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.75 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport types,sys,copy,os\nerrmess=sys.stderr.write\n\n##################### Definitions ##################\n\noutneeds={'includes0':[],'includes':[],'typedefs':[],'typedefs_generated':[],\n 'userincludes':[],\n 'cppmacros':[],'cfuncs':[],'callbacks':[],'f90modhooks':[],\n 'commonhooks':[]}\nneeds={}\nincludes0={'includes0':'/*need_includes0*/'}\nincludes={'includes':'/*need_includes*/'}\nuserincludes={'userincludes':'/*need_userincludes*/'}\ntypedefs={'typedefs':'/*need_typedefs*/'}\ntypedefs_generated={'typedefs_generated':'/*need_typedefs_generated*/'}\ncppmacros={'cppmacros':'/*need_cppmacros*/'}\ncfuncs={'cfuncs':'/*need_cfuncs*/'}\ncallbacks={'callbacks':'/*need_callbacks*/'}\nf90modhooks={'f90modhooks':'/*need_f90modhooks*/',\n 'initf90modhooksstatic':'/*initf90modhooksstatic*/',\n 'initf90modhooksdynamic':'/*initf90modhooksdynamic*/',\n }\ncommonhooks={'commonhooks':'/*need_commonhooks*/',\n 'initcommonhooks':'/*need_initcommonhooks*/',\n }\n\n############ Includes ###################\n\nincludes0['math.h']='#include '\nincludes0['string.h']='#include '\nincludes0['setjmp.h']='#include '\n\nincludes['Python.h']='#include \"Python.h\"'\nneeds['arrayobject.h']=['Python.h']\nincludes['arrayobject.h']='''#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API\n#include \"arrayobject.h\"'''\n\nincludes['arrayobject.h']='#include \"fortranobject.h\"'\n\n############# Type definitions ###############\n\ntypedefs['unsigned_char']='typedef unsigned char unsigned_char;'\ntypedefs['unsigned_short']='typedef unsigned short unsigned_short;'\ntypedefs['unsigned_long']='typedef unsigned long unsigned_long;'\ntypedefs['signed_char']='typedef signed char signed_char;'\ntypedefs['long_long']=\"\"\"\\\n#ifdef _WIN32\ntypedef __int64 long_long;\n#else\ntypedef long long long_long;\ntypedef unsigned long long unsigned_long_long;\n#endif\n\"\"\"\ntypedefs['insinged_long_long']=\"\"\"\\\n#ifdef _WIN32\ntypedef __uint64 long_long;\n#else\ntypedef unsigned long long unsigned_long_long;\n#endif\n\"\"\"\ntypedefs['long_double']=\"\"\"\\\n#ifndef _LONG_DOUBLE\ntypedef long double long_double;\n#endif\n\"\"\"\ntypedefs['complex_long_double']='typedef struct {long double r,i;} complex_long_double;'\ntypedefs['complex_float']='typedef struct {float r,i;} complex_float;'\ntypedefs['complex_double']='typedef struct {double r,i;} complex_double;'\ntypedefs['string']=\"\"\"typedef char * string;\"\"\"\n\n\n############### CPP macros ####################\ncppmacros['CFUNCSMESS']=\"\"\"\\\n#ifdef DEBUGCFUNCS\n#define CFUNCSMESS(mess) fprintf(stderr,\\\"debug-capi:\\\"mess);\n#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \\\\\n\\tPyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\\\\n\\tfprintf(stderr,\\\"\\\\n\\\");\n#else\n#define CFUNCSMESS(mess)\n#define CFUNCSMESSPY(mess,obj)\n#endif\n\"\"\"\ncppmacros['F_FUNC']=\"\"\"\\\n#if defined(PREPEND_FORTRAN)\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) _##F\n#else\n#define F_FUNC(f,F) _##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) _##F##_\n#else\n#define F_FUNC(f,F) _##f##_\n#endif\n#endif\n#else\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) F\n#else\n#define F_FUNC(f,F) f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_FUNC(f,F) F##_\n#else\n#define F_FUNC(f,F) f##_\n#endif\n#endif\n#endif\n#if defined(UNDERSCORE_G77)\n#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)\n#else\n#define F_FUNC_US(f,F) F_FUNC(f,F)\n#endif\n\"\"\"\ncppmacros['F_WRAPPEDFUNC']=\"\"\"\\\n#if defined(PREPEND_FORTRAN)\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F\n#else\n#define F_WRAPPEDFUNC(f,F) _f2pywrap##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_\n#else\n#define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_\n#endif\n#endif\n#else\n#if defined(NO_APPEND_FORTRAN)\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F\n#else\n#define F_WRAPPEDFUNC(f,F) f2pywrap##f\n#endif\n#else\n#if defined(UPPERCASE_FORTRAN)\n#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_\n#else\n#define F_WRAPPEDFUNC(f,F) f2pywrap##f##_\n#endif\n#endif\n#endif\n#if defined(UNDERSCORE_G77)\n#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_)\n#else\n#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F)\n#endif\n\"\"\"\ncppmacros['F_MODFUNC']=\"\"\"\\\n#if defined(F90MOD2CCONV1) /*E.g. Compaq Fortran */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f\n#else\n#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f ## _\n#endif\n#endif\n\n#if defined(F90MOD2CCONV2) /*E.g. IBM XL Fortran, not tested though */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f\n#else\n#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f ## _\n#endif\n#endif\n\n#if defined(F90MOD2CCONV3) /*E.g. MIPSPro Compilers */\n#if defined(NO_APPEND_FORTRAN)\n#define F_MODFUNCNAME(m,f) f ## .in. ## m\n#else\n#define F_MODFUNCNAME(m,f) f ## .in. ## m ## _\n#endif\n#endif\n/*\n#if defined(UPPERCASE_FORTRAN)\n#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(M,F)\n#else\n#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(m,f)\n#endif\n*/\n\n#define F_MODFUNC(m,f) (*(f2pymodstruct##m##.##f))\n\"\"\"\ncppmacros['SWAPUNSAFE']=\"\"\"\\\n#define SWAP(a,b) (size_t)(a) = ((size_t)(a) ^ (size_t)(b));\\\\\n (size_t)(b) = ((size_t)(a) ^ (size_t)(b));\\\\\n (size_t)(a) = ((size_t)(a) ^ (size_t)(b))\n\"\"\"\ncppmacros['SWAP']=\"\"\"\\\n#define SWAP(a,b,t) {\\\\\n\\tt *c;\\\\\n\\tc = a;\\\\\n\\ta = b;\\\\\n\\tb = c;}\n\"\"\"\n#cppmacros['ISCONTIGUOUS']='#define ISCONTIGUOUS(m) ((m)->flags & CONTIGUOUS)'\ncppmacros['PRINTPYOBJERR']=\"\"\"\\\n#define PRINTPYOBJERR(obj)\\\\\n\\tfprintf(stderr,\\\"#modulename#.error is related to \\\");\\\\\n\\tPyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\\\\n\\tfprintf(stderr,\\\"\\\\n\\\");\n\"\"\"\ncppmacros['MINMAX']=\"\"\"\\\n#ifndef MAX\n#define MAX(a,b) ((a > b) ? (a) : (b))\n#endif\n#ifndef MIN\n#define MIN(a,b) ((a < b) ? (a) : (b))\n#endif\n\"\"\"\ncppmacros['len..']=\"\"\"\\\n#define rank(var) var ## _Rank\n#define shape(var,dim) var ## _Dims[dim]\n#define old_rank(var) (((PyArrayObject *)(capi_ ## var ## _tmp))->nd)\n#define old_shape(var,dim) (((PyArrayObject *)(capi_ ## var ## _tmp))->dimensions[dim])\n#define fshape(var,dim) shape(var,rank(var)-dim-1)\n#define len(var) shape(var,0)\n#define flen(var) fshape(var,0)\n#define size(var) PyArray_SIZE((PyArrayObject *)(capi_ ## var ## _tmp))\n/* #define index(i) capi_i ## i */\n#define slen(var) capi_ ## var ## _len\n\"\"\"\n\ncppmacros['pyobj_from_char1']='#define pyobj_from_char1(v) (PyInt_FromLong(v))'\ncppmacros['pyobj_from_short1']='#define pyobj_from_short1(v) (PyInt_FromLong(v))'\nneeds['pyobj_from_int1']=['signed_char']\ncppmacros['pyobj_from_int1']='#define pyobj_from_int1(v) (PyInt_FromLong(v))'\ncppmacros['pyobj_from_long1']='#define pyobj_from_long1(v) (PyLong_FromLong(v))'\nneeds['pyobj_from_long_long1']=['long_long']\ncppmacros['pyobj_from_long_long1']=\"\"\"\\\n#ifdef HAVE_LONG_LONG\n#define pyobj_from_long_long1(v) (PyLong_FromLongLong(v))\n#else\n#warning HAVE_LONG_LONG is not available. Redefining pyobj_from_long_long.\n#define pyobj_from_long_long1(v) (PyLong_FromLong(v))\n#endif\n\"\"\"\nneeds['pyobj_from_long_double1']=['long_double']\ncppmacros['pyobj_from_long_double1']='#define pyobj_from_long_double1(v) (PyFloat_FromDouble(v))'\ncppmacros['pyobj_from_double1']='#define pyobj_from_double1(v) (PyFloat_FromDouble(v))'\ncppmacros['pyobj_from_float1']='#define pyobj_from_float1(v) (PyFloat_FromDouble(v))'\nneeds['pyobj_from_complex_long_double1']=['complex_long_double']\ncppmacros['pyobj_from_complex_long_double1']='#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_complex_double1']=['complex_double']\ncppmacros['pyobj_from_complex_double1']='#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_complex_float1']=['complex_float']\ncppmacros['pyobj_from_complex_float1']='#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))'\nneeds['pyobj_from_string1']=['string']\ncppmacros['pyobj_from_string1']='#define pyobj_from_string1(v) (PyString_FromString((char *)v))'\nneeds['TRYPYARRAYTEMPLATE']=['PRINTPYOBJERR']\ncppmacros['TRYPYARRAYTEMPLATE']=\"\"\"\\\n/* New SciPy */\n#define TRYPYARRAYTEMPLATECHAR case PyArray_STRING: *(char *)(arr->data)=*v; break;\n#define TRYPYARRAYTEMPLATELONG case PyArray_LONG: *(long *)(arr->data)=*v; break;\n#define TRYPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data); break;\n\n#define TRYPYARRAYTEMPLATE(ctype,typecode) \\\\\n\tPyArrayObject *arr = NULL;\\\\\n\tif (!obj) return -2;\\\\\n\tif (!PyArray_Check(obj)) return -1;\\\\\n\tif (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\\\"TRYPYARRAYTEMPLATE:\\\");PRINTPYOBJERR(obj);return 0;}\\\\\n\tif (arr->descr->type==typecode) {*(ctype *)(arr->data)=*v; return 1;}\\\\\n\tswitch (arr->descr->type_num) {\\\\\n\t\tcase PyArray_DOUBLE: *(double *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_INT: *(int *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONG: *(long *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_FLOAT: *(float *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CDOUBLE: *(double *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CFLOAT: *(float *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_BOOL: *(Bool *)(arr->data)=(*v!=0); break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_USHORT: *(ushort *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_UINT: *(uint *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_ULONG: *(ulong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONGLONG: *(longlong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_ULONGLONG: *(ulonglong *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=*v; break;\\\\\n\t\tcase PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_ ## ctype ## 1(*v),arr->data, arr); break;\\\\\n\tdefault: return -2;\\\\\n\t};\\\\\n\treturn 1\n\"\"\"\n\nneeds['TRYCOMPLEXPYARRAYTEMPLATE']=['PRINTPYOBJERR']\ncppmacros['TRYCOMPLEXPYARRAYTEMPLATE']=\"\"\"\\\n#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\n#define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\\\\\n\tPyArrayObject *arr = NULL;\\\\\n\tif (!obj) return -2;\\\\\n\tif (!PyArray_Check(obj)) return -1;\\\\\n if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\\\"TRYCOMPLEXPYARRAYTEMPLATE:\\\");PRINTPYOBJERR(obj);return 0;}\\\\\n\tif (arr->descr->type==typecode) {\\\\\n *(ctype *)(arr->data)=(*v).r;\\\\\n *(ctype *)(arr->data+sizeof(ctype))=(*v).i;\\\\\n return 1;\\\\\n }\\\\\n\tswitch (arr->descr->type_num) {\\\\\n\t\tcase PyArray_CDOUBLE: *(double *)(arr->data)=(*v).r;*(double *)(arr->data+sizeof(double))=(*v).i;break;\\\\\n\t\tcase PyArray_CFLOAT: *(float *)(arr->data)=(*v).r;*(float *)(arr->data+sizeof(float))=(*v).i;break;\\\\\n\t\tcase PyArray_DOUBLE: *(double *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONG: *(long *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_FLOAT: *(float *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_INT: *(int *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BOOL: *(Bool *)(arr->data)=((*v).r!=0 && (*v).i!=0)); break;\\\\\n\t\tcase PyArray_UBYTE: *(unsigned char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_BYTE: *(signed char *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_SHORT: *(short *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_USHORT: *(ushort *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_UINT: *(uint *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_ULONG: *(ulong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONGLONG: *(longlong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_ULONGLONG: *(ulonglong *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_LONGDOUBLE: *(longdouble *)(arr->data)=(*v).r; break;\\\\\n\t\tcase PyArray_CLONGDOUBLE: *(longdouble *)(arr->data)=(*v).r;*(longdouble *)(arr->data+sizeof(longdouble))=(*v).i;break;\\\\ \n case PyArray_OBJECT: (arr->descr->f->setitem)(pyobj_from_complex_ ## ctype ## 1((*v)),arr->data, arr); break;\\\\\n\t\tdefault: return -2;\\\\\n\t};\\\\\n\treturn -1; \n\"\"\"\n## cppmacros['NUMFROMARROBJ']=\"\"\"\\\n## #define NUMFROMARROBJ(typenum,ctype) \\\\\n## \\tif (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\\\\n## \\telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\\\\n## \\tif (arr) {\\\\\n## \\t\\tif (arr->descr->type_num==PyArray_OBJECT) {\\\\\n## \\t\\t\\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\\\"\\\"))\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t} else {\\\\\n## \\t\\t\\t(arr->descr->cast[typenum])(arr->data,1,(char*)v,1,1);\\\\\n## \\t\\t}\\\\\n## \\t\\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\\\\n## \\t\\treturn 1;\\\\\n## \\t}\n## \"\"\"\n## #XXX: Note that CNUMFROMARROBJ is identical with NUMFROMARROBJ\n## cppmacros['CNUMFROMARROBJ']=\"\"\"\\\n## #define CNUMFROMARROBJ(typenum,ctype) \\\\\n## \\tif (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\\\\n## \\telse arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\\\\n## \\tif (arr) {\\\\\n## \\t\\tif (arr->descr->type_num==PyArray_OBJECT) {\\\\\n## \\t\\t\\tif (!ctype ## _from_pyobj(v,(arr->descr->getitem)(arr->data),\\\"\\\"))\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t} else {\\\\\n## \\t\\t\\t(arr->descr->cast[typenum])((void *)(arr->data),1,(void *)(v),1,1);\\\\\n## \\t\\t}\\\\\n## \\t\\tif ((PyObject *)arr != obj) { Py_DECREF(arr); }\\\\\n## \\t\\treturn 1;\\\\\n## \\t}\n## \"\"\"\n\n\nneeds['GETSTRFROMPYTUPLE']=['STRINGCOPYN','PRINTPYOBJERR']\ncppmacros['GETSTRFROMPYTUPLE']=\"\"\"\\\n#define GETSTRFROMPYTUPLE(tuple,index,str,len) {\\\\\n\\t\\tPyObject *rv_cb_str = PyTuple_GetItem((tuple),(index));\\\\\n\\t\\tif (rv_cb_str == NULL)\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t\\tif (PyString_Check(rv_cb_str)) {\\\\\n\\t\\t\\tstr[len-1]='\\\\0';\\\\\n\\t\\t\\tSTRINGCOPYN((str),PyString_AS_STRING((PyStringObject*)rv_cb_str),(len));\\\\\n\\t\\t} else {\\\\\n\\t\\t\\tPRINTPYOBJERR(rv_cb_str);\\\\\n\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"string object expected\\\");\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t\\t}\\\\\n\\t}\n\"\"\"\ncppmacros['GETSCALARFROMPYTUPLE']=\"\"\"\\\n#define GETSCALARFROMPYTUPLE(tuple,index,var,ctype,mess) {\\\\\n\\t\\tif ((capi_tmp = PyTuple_GetItem((tuple),(index)))==NULL) goto capi_fail;\\\\\n\\t\\tif (!(ctype ## _from_pyobj((var),capi_tmp,mess)))\\\\\n\\t\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\n\nneeds['MEMCOPY']=['string.h']\ncppmacros['MEMCOPY']=\"\"\"\\\n#define MEMCOPY(to,from,n)\\\\\n\\tif ((memcpy(to,from,n)) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"memcpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\ncppmacros['STRINGMALLOC']=\"\"\"\\\n#define STRINGMALLOC(str,len)\\\\\n\\tif ((str = (string)malloc(sizeof(char)*(len+1))) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"out of memory\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t} else {\\\\\n\\t\\t(str)[len] = '\\\\0';\\\\\n\\t}\n\"\"\"\ncppmacros['STRINGFREE']=\"\"\"\\\n#define STRINGFREE(str)\\\\\n\\tif (!(str == NULL)) free(str);\n\"\"\"\nneeds['STRINGCOPYN']=['string.h']\ncppmacros['STRINGCOPYN']=\"\"\"\\\n#define STRINGCOPYN(to,from,n)\\\\\n\\tif ((strncpy(to,from,sizeof(char)*(n))) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"strncpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t} else if (strlen(to)<(n)) {\\\\\n\\t\\tmemset((to)+strlen(to), ' ', (n)-strlen(to));\\\\\n\\t} /* Padding with spaces instead of nulls. */\n\"\"\"\nneeds['STRINGCOPY']=['string.h']\ncppmacros['STRINGCOPY']=\"\"\"\\\n#define STRINGCOPY(to,from)\\\\\n\\tif ((strcpy(to,from)) == NULL) {\\\\\n\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"strcpy failed\\\");\\\\\n\\t\\tgoto capi_fail;\\\\\n\\t}\n\"\"\"\ncppmacros['CHECKGENERIC']=\"\"\"\\\n#define CHECKGENERIC(check,tcheck,name) \\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKARRAY']=\"\"\"\\\n#define CHECKARRAY(check,tcheck,name) \\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKSTRING']=\"\"\"\\\n#define CHECKSTRING(check,tcheck,name,show,var)\\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\tfprintf(stderr,show\\\"\\\\n\\\",slen(var),var);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\ncppmacros['CHECKSCALAR']=\"\"\"\\\n#define CHECKSCALAR(check,tcheck,name,show,var)\\\\\n\\tif (!(check)) {\\\\\n\\t\\tPyErr_SetString(#modulename#_error,\\\"(\\\"tcheck\\\") failed for \\\"name);\\\\\n\\t\\tfprintf(stderr,show\\\"\\\\n\\\",var);\\\\\n\\t\\t/*goto capi_fail;*/\\\\\n\\t} else \"\"\"\n## cppmacros['CHECKDIMS']=\"\"\"\\\n## #define CHECKDIMS(dims,rank) \\\\\n## \\tfor (int i=0;i<(rank);i++)\\\\\n## \\t\\tif (dims[i]<0) {\\\\\n## \\t\\t\\tfprintf(stderr,\\\"Unspecified array argument requires a complete dimension specification.\\\\n\\\");\\\\\n## \\t\\t\\tgoto capi_fail;\\\\\n## \\t\\t}\n## \"\"\"\ncppmacros['ARRSIZE']='#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))'\ncppmacros['OLDPYNUM']=\"\"\"\\\n#ifdef OLDPYNUM\n#error You need to intall Numeric Python version 13 or higher. Get it from http:/sourceforge.net/project/?group_id=1369\n#endif\n\"\"\"\n################# C functions ###############\n\ncfuncs['calcarrindex']=\"\"\"\\\nstatic int calcarrindex(int *i,PyArrayObject *arr) {\n\\tint k,ii = i[0];\n\\tfor (k=1; k < arr->nd; k++)\n\\t\\tii += (ii*(arr->dimensions[k] - 1)+i[k]); /* assuming contiguous arr */\n\\treturn ii;\n}\"\"\"\ncfuncs['calcarrindextr']=\"\"\"\\\nstatic int calcarrindextr(int *i,PyArrayObject *arr) {\n\\tint k,ii = i[arr->nd-1];\n\\tfor (k=1; k < arr->nd; k++)\n\\t\\tii += (ii*(arr->dimensions[arr->nd-k-1] - 1)+i[arr->nd-k-1]); /* assuming contiguous arr */\n\\treturn ii;\n}\"\"\"\ncfuncs['forcomb']=\"\"\"\\\nstatic struct { int nd;intp *d;int *i,*i_tr,tr; } forcombcache;\nstatic int initforcomb(intp *dims,int nd,int tr) {\n int k;\n if (dims==NULL) return 0;\n if (nd<0) return 0;\n forcombcache.nd = nd;\n forcombcache.d = dims;\n forcombcache.tr = tr;\n if ((forcombcache.i = (int *)malloc(sizeof(int)*nd))==NULL) return 0;\n if ((forcombcache.i_tr = (int *)malloc(sizeof(int)*nd))==NULL) return 0;\n for (k=1;kdata,str,PyArray_NBYTES(arr)); }\n\\treturn 1;\ncapi_fail:\n\\tPRINTPYOBJERR(obj);\n\\tPyErr_SetString(#modulename#_error,\\\"try_pyarr_from_string failed\\\");\n\\treturn 0;\n}\n\"\"\"\nneeds['string_from_pyobj']=['string','STRINGMALLOC','STRINGCOPYN']\ncfuncs['string_from_pyobj']=\"\"\"\\\nstatic int string_from_pyobj(string *str,int *len,const string inistr,PyObject *obj,const char *errmess) {\n\\tPyArrayObject *arr = NULL;\n\\tPyObject *tmp = NULL;\n#ifdef DEBUGCFUNCS\nfprintf(stderr,\\\"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\\\\n\\\",(char*)str,*len,(char *)inistr,obj);\n#endif\n\\tif (obj == Py_None) {\n\\t\\tif (*len == -1)\n\\t\\t\\t*len = strlen(inistr); /* Will this cause problems? */\n\\t\\tSTRINGMALLOC(*str,*len);\n\\t\\tSTRINGCOPYN(*str,inistr,*len);\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_Check(obj)) {\n\\t\\tif ((arr = (PyArrayObject *)obj) == NULL)\n\\t\\t\\tgoto capi_fail;\n\\t\\tif (!ISCONTIGUOUS(arr)) {\n\\t\\t\\tPyErr_SetString(PyExc_ValueError,\\\"array object is non-contiguous.\\\");\n\\t\\t\\tgoto capi_fail;\n\\t\\t}\n\\t\\tif (*len == -1)\n\\t\\t\\t*len = (arr->descr->elsize)*PyArray_SIZE(arr);\n\\t\\tSTRINGMALLOC(*str,*len);\n\\t\\tSTRINGCOPYN(*str,arr->data,*len);\n\\t\\treturn 1;\n\\t}\n\\tif (PyString_Check(obj)) {\n\\t\\ttmp = obj;\n\\t\\tPy_INCREF(tmp);\n\\t}\n\\telse\n\\t\\ttmp = PyObject_Str(obj);\n\\tif (tmp == NULL) goto capi_fail;\n\\tif (*len == -1)\n\\t\\t*len = PyString_GET_SIZE(tmp);\n\\tSTRINGMALLOC(*str,*len);\n\\tSTRINGCOPYN(*str,PyString_AS_STRING(tmp),*len);\n\\tPy_DECREF(tmp);\n\\treturn 1;\ncapi_fail:\n\\tPy_XDECREF(tmp);\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['char_from_pyobj']=['int_from_pyobj']\ncfuncs['char_from_pyobj']=\"\"\"\\\nstatic int char_from_pyobj(char* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (char)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['signed_char_from_pyobj']=['int_from_pyobj','signed_char']\ncfuncs['signed_char_from_pyobj']=\"\"\"\\\nstatic int signed_char_from_pyobj(signed_char* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (signed_char)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['short_from_pyobj']=['int_from_pyobj']\ncfuncs['short_from_pyobj']=\"\"\"\\\nstatic int short_from_pyobj(short* v,PyObject *obj,const char *errmess) {\n\\tint i=0;\n\\tif (int_from_pyobj(&i,obj,errmess)) {\n\\t\\t*v = (short)i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['int_from_pyobj']=\"\"\"\\\nstatic int int_from_pyobj(int* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = (int)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Int(obj);\n\\tif (tmp) {\n\\t\\t*v = PyInt_AS_LONG(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (int_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['long_from_pyobj']=\"\"\"\\\nstatic int long_from_pyobj(long* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Int(obj);\n\\tif (tmp) {\n\\t\\t*v = PyInt_AS_LONG(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (long_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['long_long_from_pyobj']=['long_long']\ncfuncs['long_long_from_pyobj']=\"\"\"\\\nstatic int long_long_from_pyobj(long_long* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyLong_Check(obj)) {\n\\t\\t*v = PyLong_AsLongLong(obj);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PyInt_Check(obj)) {\n\\t\\t*v = (long_long)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Long(obj);\n\\tif (tmp) {\n\\t\\t*v = PyLong_AsLongLong(tmp);\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (long_long_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['long_double_from_pyobj']=['double_from_pyobj','long_double']\ncfuncs['long_double_from_pyobj']=\"\"\"\\\nstatic int long_double_from_pyobj(long_double* v,PyObject *obj,const char *errmess) {\n\\tdouble d=0;\n\\tif (PyArray_CheckScalar(obj)){\n\\t\\tif PyArray_IsScalar(obj, LongDouble) {\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t\\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_LONGDOUBLE) {\n\\t\\t\\t(*v) = *((longdouble *)PyArray_DATA(obj))\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t}\n\\tif (double_from_pyobj(&d,obj,errmess)) {\n\\t\\t*v = (long_double)d;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\ncfuncs['double_from_pyobj']=\"\"\"\\\nstatic int double_from_pyobj(double* v,PyObject *obj,const char *errmess) {\n\\tPyObject* tmp = NULL;\n\\tif (PyFloat_Check(obj)) {\n#ifdef __sgi\n\\t\\t*v = PyFloat_AsDouble(obj);\n#else\n\\t\\t*v = PyFloat_AS_DOUBLE(obj);\n#endif\n\\t\\treturn 1;\n\\t}\n\\ttmp = PyNumber_Float(obj);\n\\tif (tmp) {\n#ifdef __sgi\n\\t\\t*v = PyFloat_AsDouble(tmp);\n#else\n\\t\\t*v = PyFloat_AS_DOUBLE(tmp);\n#endif\n\\t\\tPy_DECREF(tmp);\n\\t\\treturn 1;\n\\t}\n\\tif (PyComplex_Check(obj))\n\\t\\ttmp = PyObject_GetAttrString(obj,\\\"real\\\");\n\\telse if (PyString_Check(obj))\n\\t\\t/*pass*/;\n\\telse if (PySequence_Check(obj))\n\\t\\ttmp = PySequence_GetItem(obj,0);\n\\tif (tmp) {\n\\t\\tPyErr_Clear();\n\\t\\tif (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}\n\\t\\tPy_DECREF(tmp);\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL) err = #modulename#_error;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['float_from_pyobj']=['double_from_pyobj']\ncfuncs['float_from_pyobj']=\"\"\"\\\nstatic int float_from_pyobj(float* v,PyObject *obj,const char *errmess) {\n\\tdouble d=0.0;\n\\tif (double_from_pyobj(&d,obj,errmess)) {\n\\t\\t*v = (float)d;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_long_double_from_pyobj']=['complex_long_double','long_double',\n 'complex_double_from_pyobj']\ncfuncs['complex_long_double_from_pyobj']=\"\"\"\\\nstatic int complex_long_double_from_pyobj(complex_long_double* v,PyObject *obj,const char *errmess) {\n\\tcomplex_double cd={0.0,0.0};\n\\tif (PyArray_CheckScalar(obj)){\n\\t\\tif PyArray_IsScalar(obj, CLongDouble) {\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t\\telse if (PyArray_Check(obj) && PyArray_TYPE(obj)==PyArray_CLONGDOUBLE) {\n\\t\\t\\t(*v).r = ((clongdouble *)PyArray_DATA(obj))->real;\n\\t\\t\\t(*v).i = ((clongdouble *)PyArray_DATA(obj))->imag;\n\\t\\t\\treturn 1;\n\\t\\t}\n\\t}\n\\tif (complex_double_from_pyobj(&cd,obj,errmess)) {\n\\t\\t(*v).r = (long_double)cd.r;\n\\t\\t(*v).i = (long_double)cd.i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_double_from_pyobj']=['complex_double']\ncfuncs['complex_double_from_pyobj']=\"\"\"\\\nstatic int complex_double_from_pyobj(complex_double* v,PyObject *obj,const char *errmess) {\n\\tPy_complex c;\n\\tif (PyComplex_Check(obj)) {\n\\t\\tc=PyComplex_AsCComplex(obj);\n\\t\\t(*v).r=c.real, (*v).i=c.imag;\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_IsScalar(obj, ComplexFloating)) {\n\\t\\tif (PyArray_IsScalar(obj, CFloat)) {\n\\t\\t\\tcfloat new;\n\\t\\t\\tPyArray_ScalarAsCtype(obj, &new);\n\\t\\t\\t(*v).r = (double)new.real;\n\\t\\t\\t(*v).i = (double)new.imag;\n\\t\\t}\n\\t\\telse if (PyArray_IsScalar(obj, CLongDouble)) {\n\\t\\t\\tclongdouble new;\n\\t\\t\\tPyArray_ScalarAsCtype(obj, &new);\n\\t\\t\\t(*v).r = (double)new.real;\n\\t\\t\\t(*v).i = (double)new.imag;\n\\t\\t}\n\\t\\telse { /* if (PyArray_IsScalar(obj, CDouble)) */\n\\t\\t\\tPyArray_ScalarAsCtype(obj, v);\n\\t\\t}\n\\t\\treturn 1;\n\\t}\n\\tif (PyArray_CheckScalar(obj)) { /* 0-dim array or still array scalar */\n\\t\\tPyObject *arr;\n\\t\\tif (PyArray_Check(obj)) {\n\\t\\t\\tarr = PyArray_Cast((PyArrayObject *)obj, PyArray_CDOUBLE);\n\\t\\t}\n\\t\\telse {\n\\t\\t\\tarr = PyArray_FromScalar(obj, PyArray_DescrFromType(PyArray_CDOUBLE));\n\\t\\t}\n\\t\\tif (arr==NULL) return 0;\n\\t\\t(*v).r = ((cdouble *)PyArray_DATA(arr))->real;\n\\t\\t(*v).i = ((cdouble *)PyArray_DATA(arr))->imag;\n\\t\\treturn 1;\n\\t}\n\\t/* Python does not provide PyNumber_Complex function :-( */\n\\t(*v).i=0.0;\n\\tif (PyFloat_Check(obj)) {\n#ifdef __sgi\n\\t\\t(*v).r = PyFloat_AsDouble(obj);\n#else\n\\t\\t(*v).r = PyFloat_AS_DOUBLE(obj);\n#endif\n\\t\\treturn 1;\n\\t}\n\\tif (PyInt_Check(obj)) {\n\\t\\t(*v).r = (double)PyInt_AS_LONG(obj);\n\\t\\treturn 1;\n\\t}\n\\tif (PyLong_Check(obj)) {\n\\t\\t(*v).r = PyLong_AsDouble(obj);\n\\t\\treturn (!PyErr_Occurred());\n\\t}\n\\tif (PySequence_Check(obj) && (!PyString_Check(obj))) {\n\\t\\tPyObject *tmp = PySequence_GetItem(obj,0);\n\\t\\tif (tmp) {\n\\t\\t\\tif (complex_double_from_pyobj(v,tmp,errmess)) {\n\\t\\t\\t\\tPy_DECREF(tmp);\n\\t\\t\\t\\treturn 1;\n\\t\\t\\t}\n\\t\\t\\tPy_DECREF(tmp);\n\\t\\t}\n\\t}\n\\t{\n\\t\\tPyObject* err = PyErr_Occurred();\n\\t\\tif (err==NULL)\n\\t\\t\\terr = PyExc_TypeError;\n\\t\\tPyErr_SetString(err,errmess);\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['complex_float_from_pyobj']=['complex_float','complex_double_from_pyobj']\ncfuncs['complex_float_from_pyobj']=\"\"\"\\\nstatic int complex_float_from_pyobj(complex_float* v,PyObject *obj,const char *errmess) {\n\\tcomplex_double cd={0.0,0.0};\n\\tif (complex_double_from_pyobj(&cd,obj,errmess)) {\n\\t\\t(*v).r = (float)cd.r;\n\\t\\t(*v).i = (float)cd.i;\n\\t\\treturn 1;\n\\t}\n\\treturn 0;\n}\n\"\"\"\nneeds['try_pyarr_from_char']=['pyobj_from_char1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_char']='static int try_pyarr_from_char(PyObject* obj,char* v) {\\n\\tTRYPYARRAYTEMPLATE(char,\\'c\\');\\n}\\n'\nneeds['try_pyarr_from_signed_char']=['TRYPYARRAYTEMPLATE','unsigned_char']\ncfuncs['try_pyarr_from_unsigned_char']='static int try_pyarr_from_unsigned_char(PyObject* obj,unsigned_char* v) {\\n\\tTRYPYARRAYTEMPLATE(unsigned_char,\\'b\\');\\n}\\n'\nneeds['try_pyarr_from_signed_char']=['TRYPYARRAYTEMPLATE','signed_char']\ncfuncs['try_pyarr_from_signed_char']='static int try_pyarr_from_signed_char(PyObject* obj,signed_char* v) {\\n\\tTRYPYARRAYTEMPLATE(signed_char,\\'1\\');\\n}\\n'\nneeds['try_pyarr_from_short']=['pyobj_from_short1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_short']='static int try_pyarr_from_short(PyObject* obj,short* v) {\\n\\tTRYPYARRAYTEMPLATE(short,\\'s\\');\\n}\\n'\nneeds['try_pyarr_from_int']=['pyobj_from_int1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_int']='static int try_pyarr_from_int(PyObject* obj,int* v) {\\n\\tTRYPYARRAYTEMPLATE(int,\\'i\\');\\n}\\n'\nneeds['try_pyarr_from_long']=['pyobj_from_long1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_long']='static int try_pyarr_from_long(PyObject* obj,long* v) {\\n\\tTRYPYARRAYTEMPLATE(long,\\'l\\');\\n}\\n'\nneeds['try_pyarr_from_long_long']=['pyobj_from_long_long1','TRYPYARRAYTEMPLATE','long_long']\ncfuncs['try_pyarr_from_long_long']='static int try_pyarr_from_long_long(PyObject* obj,long_long* v) {\\n\\tTRYPYARRAYTEMPLATE(long_long,\\'L\\');\\n}\\n'\nneeds['try_pyarr_from_float']=['pyobj_from_float1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_float']='static int try_pyarr_from_float(PyObject* obj,float* v) {\\n\\tTRYPYARRAYTEMPLATE(float,\\'f\\');\\n}\\n'\nneeds['try_pyarr_from_double']=['pyobj_from_double1','TRYPYARRAYTEMPLATE']\ncfuncs['try_pyarr_from_double']='static int try_pyarr_from_double(PyObject* obj,double* v) {\\n\\tTRYPYARRAYTEMPLATE(double,\\'d\\');\\n}\\n'\nneeds['try_pyarr_from_complex_float']=['pyobj_from_complex_float1','TRYCOMPLEXPYARRAYTEMPLATE','complex_float']\ncfuncs['try_pyarr_from_complex_float']='static int try_pyarr_from_complex_float(PyObject* obj,complex_float* v) {\\n\\tTRYCOMPLEXPYARRAYTEMPLATE(float,\\'F\\');\\n}\\n'\nneeds['try_pyarr_from_complex_double']=['pyobj_from_complex_double1','TRYCOMPLEXPYARRAYTEMPLATE','complex_double']\ncfuncs['try_pyarr_from_complex_double']='static int try_pyarr_from_complex_double(PyObject* obj,complex_double* v) {\\n\\tTRYCOMPLEXPYARRAYTEMPLATE(double,\\'D\\');\\n}\\n'\n\nneeds['create_cb_arglist']=['CFUNCSMESS','PRINTPYOBJERR','MINMAX']\ncfuncs['create_cb_arglist']=\"\"\"\\\nstatic int create_cb_arglist(PyObject* fun,PyTupleObject* xa,const int maxnofargs,const int nofoptargs,int *nofargs,PyTupleObject **args,const char *errmess) {\n\\tPyObject *tmp = NULL;\n\\tPyObject *tmp_fun = NULL;\n\\tint tot,opt,ext,siz,i,di=0;\n\\tCFUNCSMESS(\\\"create_cb_arglist\\\\n\\\");\n\\ttot=opt=ext=siz=0;\n\\t/* Get the total number of arguments */\n\\tif (PyFunction_Check(fun))\n\\t\\ttmp_fun = fun;\n\\telse {\n\\t\\tdi = 1;\n\\t\\tif (PyObject_HasAttrString(fun,\\\"im_func\\\")) {\n\\t\\t\\ttmp_fun = PyObject_GetAttrString(fun,\\\"im_func\\\");\n\\t\\t}\n\\t\\telse if (PyObject_HasAttrString(fun,\\\"__call__\\\")) {\n\\t\\t\\ttmp = PyObject_GetAttrString(fun,\\\"__call__\\\");\n\\t\\t\\tif (PyObject_HasAttrString(tmp,\\\"im_func\\\"))\n\\t\\t\\t\\ttmp_fun = PyObject_GetAttrString(tmp,\\\"im_func\\\");\n\\t\\t\\telse {\n\\t\\t\\t\\ttmp_fun = fun; /* built-in function */\n\\t\\t\\t\\ttot = maxnofargs;\n\\t\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\t\\ttot += PyTuple_Size((PyObject *)xa);\n\\t\\t\\t}\n\\t\\t\\tPy_XDECREF(tmp);\n\\t\\t}\n\\t\\telse if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {\n\\t\\t\\ttot = maxnofargs;\n\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\ttot += PyTuple_Size((PyObject *)xa);\n\\t\\t\\ttmp_fun = fun;\n\\t\\t}\n\\t\\telse if (PyCObject_Check(fun)) {\n\\t\\t\\ttot = maxnofargs;\n\\t\\t\\tif (xa != NULL)\n\\t\\t\\t\\text = PyTuple_Size((PyObject *)xa);\n\\t\\t\\tif(ext>0) {\n\\t\\t\\t\\tfprintf(stderr,\\\"extra arguments tuple cannot be used with CObject call-back\\\\n\\\");\n\\t\\t\\t\\tgoto capi_fail;\n\\t\\t\\t}\n\\t\\t\\ttmp_fun = fun;\n\\t\\t}\n\\t}\nif (tmp_fun==NULL) {\nfprintf(stderr,\\\"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\\\\n\\\",(fun==NULL?\\\"NULL\\\":fun->ob_type->tp_name));\ngoto capi_fail;\n}\n\\tif (PyObject_HasAttrString(tmp_fun,\\\"func_code\\\")) {\n\\t\\tif (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\\\"func_code\\\"),\\\"co_argcount\\\"))\n\\t\\t\\ttot = PyInt_AsLong(PyObject_GetAttrString(tmp,\\\"co_argcount\\\")) - di;\n\\t\\tPy_XDECREF(tmp);\n\\t}\n\\t/* Get the number of optional arguments */\n\\tif (PyObject_HasAttrString(tmp_fun,\\\"func_defaults\\\"))\n\\t\\tif (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\\\"func_defaults\\\")))\n\\t\\t\\topt = PyTuple_Size(tmp);\n\\t\\tPy_XDECREF(tmp);\n\\t/* Get the number of extra arguments */\n\\tif (xa != NULL)\n\\t\\text = PyTuple_Size((PyObject *)xa);\n\\t/* Calculate the size of call-backs argument list */\n\\tsiz = MIN(maxnofargs+ext,tot);\n\\t*nofargs = MAX(0,siz-ext);\n#ifdef DEBUGCFUNCS\n\\tfprintf(stderr,\\\"debug-capi:create_cb_arglist:maxnofargs(-nofoptargs),tot,opt,ext,siz,nofargs=%d(-%d),%d,%d,%d,%d,%d\\\\n\\\",maxnofargs,nofoptargs,tot,opt,ext,siz,*nofargs);\n#endif\n\\tif (siz0:\n if not needs.has_key(outneeds[n][0]):\n out.append(outneeds[n][0])\n del outneeds[n][0]\n else:\n flag=0\n for k in outneeds[n][1:]:\n if k in needs[outneeds[n][0]]:\n flag=1\n break\n if flag:\n outneeds[n]=outneeds[n][1:]+[outneeds[n][0]]\n else:\n out.append(outneeds[n][0])\n del outneeds[n][0]\n if saveout and (0 not in map(lambda x,y:x==y,saveout,outneeds[n])):\n print n,saveout\n errmess('get_needs: no progress in sorting needs, probably circular dependence, skipping.\\n')\n out=out+saveout\n break\n saveout=copy.copy(outneeds[n])\n if out==[]: out=[n]\n res[n]=out\n return res\n", + "methods": [ + { + "name": "buildcfuncs", + "long_name": "buildcfuncs( )", + "filename": "cfuncs.py", + "nloc": 8, + "complexity": 2, + "token_count": 55, + "parameters": [], + "start_line": 1044, + "end_line": 1051, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "append_needs", + "long_name": "append_needs( need , flag = 1 )", + "filename": "cfuncs.py", + "nloc": 48, + "complexity": 30, + "token_count": 422, + "parameters": [ + "need", + "flag" + ], + "start_line": 1056, + "end_line": 1103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "get_needs", + "long_name": "get_needs( )", + "filename": "cfuncs.py", + "nloc": 30, + "complexity": 10, + "token_count": 236, + "parameters": [], + "start_line": 1105, + "end_line": 1134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "buildcfuncs", + "long_name": "buildcfuncs( )", + "filename": "cfuncs.py", + "nloc": 8, + "complexity": 2, + "token_count": 55, + "parameters": [], + "start_line": 1044, + "end_line": 1051, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "append_needs", + "long_name": "append_needs( need , flag = 1 )", + "filename": "cfuncs.py", + "nloc": 48, + "complexity": 30, + "token_count": 422, + "parameters": [ + "need", + "flag" + ], + "start_line": 1056, + "end_line": 1103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "get_needs", + "long_name": "get_needs( )", + "filename": "cfuncs.py", + "nloc": 30, + "complexity": 10, + "token_count": 236, + "parameters": [], + "start_line": 1105, + "end_line": 1134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 1062, + "complexity": 42, + "token_count": 1729, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/common_rules.py", + "new_path": "numpy/f2py/common_rules.py", + "filename": "common_rules.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n Copyright 2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/05/06 10:57:33 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nBuild common block mechanism for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 10:57:33 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.19 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\nimport func2subr\nfrom crackfortran import rmbadname\n##############\n\ndef findcommonblocks(block,top=1):\n ret = []\n if hascommon(block):\n for n in block['common'].keys():\n vars={}\n for v in block['common'][n]:\n vars[v]=block['vars'][v]\n ret.append((n,block['common'][n],vars))\n elif hasbody(block):\n for b in block['body']:\n ret=ret+findcommonblocks(b,0)\n if top:\n tret=[]\n names=[]\n for t in ret:\n if t[0] not in names:\n names.append(t[0])\n tret.append(t)\n return tret\n return ret\n\ndef buildhooks(m):\n ret = {'commonhooks':[],'initcommonhooks':[],'docs':['\"COMMON blocks:\\\\n\"']}\n fwrap = ['']\n def fadd(line,s=fwrap): s[0] = '%s\\n %s'%(s[0],line)\n chooks = ['']\n def cadd(line,s=chooks): s[0] = '%s\\n%s'%(s[0],line)\n ihooks = ['']\n def iadd(line,s=ihooks): s[0] = '%s\\n%s'%(s[0],line)\n doc = ['']\n def dadd(line,s=doc): s[0] = '%s\\n%s'%(s[0],line)\n for (name,vnames,vars) in findcommonblocks(m):\n lower_name = string.lower(name)\n hnames,inames = [],[]\n for n in vnames:\n if isintent_hide(vars[n]): hnames.append(n)\n else: inames.append(n)\n if hnames:\n outmess('\\t\\tConstructing COMMON block support for \"%s\"...\\n\\t\\t %s\\n\\t\\t Hidden: %s\\n'%(name,string.join(inames,','),string.join(hnames,',')))\n else:\n outmess('\\t\\tConstructing COMMON block support for \"%s\"...\\n\\t\\t %s\\n'%(name,string.join(inames,',')))\n fadd('subroutine f2pyinit%s(setupfunc)'%name)\n fadd('external setupfunc')\n for n in vnames:\n fadd(func2subr.var2fixfortran(vars,n))\n if name=='_BLNK_':\n fadd('common %s'%(string.join(vnames,',')))\n else:\n fadd('common /%s/ %s'%(name,string.join(vnames,',')))\n fadd('call setupfunc(%s)'%(string.join(inames,',')))\n fadd('end\\n')\n cadd('static FortranDataDef f2py_%s_def[] = {'%(name))\n idims=[]\n for n in inames:\n ct = capi_maps.getctype(vars[n])\n at = capi_maps.c2capi_map[ct]\n dm = capi_maps.getarrdims(n,vars[n])\n if dm['dims']: idims.append('(%s)'%(dm['dims']))\n else: idims.append('')\n dms=string.strip(dm['dims'])\n if not dms: dms='-1'\n cadd('\\t{\\\"%s\\\",%s,{{%s}},%s},'%(n,dm['rank'],dms,at))\n cadd('\\t{NULL}\\n};')\n inames1 = rmbadname(inames)\n inames1_tps = string.join(map(lambda s:'char *'+s,inames1),',')\n cadd('static void f2py_setup_%s(%s) {'%(name,inames1_tps))\n cadd('\\tint i_f2py=0;')\n for n in inames1:\n cadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(name,n))\n cadd('}')\n if '_' in lower_name:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n cadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void(*)(%s));'\\\n %(F_FUNC,lower_name,string.upper(name),\n string.join(['char*']*len(inames1),',')))\n cadd('static void f2py_init_%s(void) {'%name)\n cadd('\\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'\\\n %(F_FUNC,lower_name,string.upper(name),name))\n cadd('}\\n')\n iadd('\\tPyDict_SetItemString(d, \\\"%s\\\", PyFortranObject_New(f2py_%s_def,f2py_init_%s));'%(name,name,name))\n tname = string.replace(name,'_','\\\\_')\n dadd('\\\\subsection{Common block \\\\texttt{%s}}\\n'%(tname))\n dadd('\\\\begin{description}')\n for n in inames:\n dadd('\\\\item[]{{}\\\\verb@%s@{}}'%(capi_maps.getarrdocsign(n,vars[n])))\n if hasnote(vars[n]):\n note = vars[n]['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd('--- %s'%(note))\n dadd('\\\\end{description}')\n ret['docs'].append('\"\\t/%s/ %s\\\\n\"'%(name,string.join(map(lambda v,d:v+d,inames,idims),',')))\n ret['commonhooks']=chooks\n ret['initcommonhooks']=ihooks\n ret['latexdoc']=doc[0]\n if len(ret['docs'])<=1: ret['docs']=''\n return ret,fwrap[0]\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nBuild common block mechanism for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 10:57:33 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.19 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\nimport func2subr\nfrom crackfortran import rmbadname\n##############\n\ndef findcommonblocks(block,top=1):\n ret = []\n if hascommon(block):\n for n in block['common'].keys():\n vars={}\n for v in block['common'][n]:\n vars[v]=block['vars'][v]\n ret.append((n,block['common'][n],vars))\n elif hasbody(block):\n for b in block['body']:\n ret=ret+findcommonblocks(b,0)\n if top:\n tret=[]\n names=[]\n for t in ret:\n if t[0] not in names:\n names.append(t[0])\n tret.append(t)\n return tret\n return ret\n\ndef buildhooks(m):\n ret = {'commonhooks':[],'initcommonhooks':[],'docs':['\"COMMON blocks:\\\\n\"']}\n fwrap = ['']\n def fadd(line,s=fwrap): s[0] = '%s\\n %s'%(s[0],line)\n chooks = ['']\n def cadd(line,s=chooks): s[0] = '%s\\n%s'%(s[0],line)\n ihooks = ['']\n def iadd(line,s=ihooks): s[0] = '%s\\n%s'%(s[0],line)\n doc = ['']\n def dadd(line,s=doc): s[0] = '%s\\n%s'%(s[0],line)\n for (name,vnames,vars) in findcommonblocks(m):\n lower_name = string.lower(name)\n hnames,inames = [],[]\n for n in vnames:\n if isintent_hide(vars[n]): hnames.append(n)\n else: inames.append(n)\n if hnames:\n outmess('\\t\\tConstructing COMMON block support for \"%s\"...\\n\\t\\t %s\\n\\t\\t Hidden: %s\\n'%(name,string.join(inames,','),string.join(hnames,',')))\n else:\n outmess('\\t\\tConstructing COMMON block support for \"%s\"...\\n\\t\\t %s\\n'%(name,string.join(inames,',')))\n fadd('subroutine f2pyinit%s(setupfunc)'%name)\n fadd('external setupfunc')\n for n in vnames:\n fadd(func2subr.var2fixfortran(vars,n))\n if name=='_BLNK_':\n fadd('common %s'%(string.join(vnames,',')))\n else:\n fadd('common /%s/ %s'%(name,string.join(vnames,',')))\n fadd('call setupfunc(%s)'%(string.join(inames,',')))\n fadd('end\\n')\n cadd('static FortranDataDef f2py_%s_def[] = {'%(name))\n idims=[]\n for n in inames:\n ct = capi_maps.getctype(vars[n])\n at = capi_maps.c2capi_map[ct]\n dm = capi_maps.getarrdims(n,vars[n])\n if dm['dims']: idims.append('(%s)'%(dm['dims']))\n else: idims.append('')\n dms=string.strip(dm['dims'])\n if not dms: dms='-1'\n cadd('\\t{\\\"%s\\\",%s,{{%s}},%s},'%(n,dm['rank'],dms,at))\n cadd('\\t{NULL}\\n};')\n inames1 = rmbadname(inames)\n inames1_tps = string.join(map(lambda s:'char *'+s,inames1),',')\n cadd('static void f2py_setup_%s(%s) {'%(name,inames1_tps))\n cadd('\\tint i_f2py=0;')\n for n in inames1:\n cadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(name,n))\n cadd('}')\n if '_' in lower_name:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n cadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void(*)(%s));'\\\n %(F_FUNC,lower_name,string.upper(name),\n string.join(['char*']*len(inames1),',')))\n cadd('static void f2py_init_%s(void) {'%name)\n cadd('\\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'\\\n %(F_FUNC,lower_name,string.upper(name),name))\n cadd('}\\n')\n iadd('\\tPyDict_SetItemString(d, \\\"%s\\\", PyFortranObject_New(f2py_%s_def,f2py_init_%s));'%(name,name,name))\n tname = string.replace(name,'_','\\\\_')\n dadd('\\\\subsection{Common block \\\\texttt{%s}}\\n'%(tname))\n dadd('\\\\begin{description}')\n for n in inames:\n dadd('\\\\item[]{{}\\\\verb@%s@{}}'%(capi_maps.getarrdocsign(n,vars[n])))\n if hasnote(vars[n]):\n note = vars[n]['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd('--- %s'%(note))\n dadd('\\\\end{description}')\n ret['docs'].append('\"\\t/%s/ %s\\\\n\"'%(name,string.join(map(lambda v,d:v+d,inames,idims),',')))\n ret['commonhooks']=chooks\n ret['initcommonhooks']=ihooks\n ret['latexdoc']=doc[0]\n if len(ret['docs'])<=1: ret['docs']=''\n return ret,fwrap[0]\n\n", + "methods": [ + { + "name": "findcommonblocks", + "long_name": "findcommonblocks( block , top = 1 )", + "filename": "common_rules.py", + "nloc": 20, + "complexity": 9, + "token_count": 144, + "parameters": [ + "block", + "top" + ], + "start_line": 34, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "buildhooks.dadd", + "long_name": "buildhooks.dadd( line , s = doc )", + "filename": "common_rules.py", + "nloc": 63, + "complexity": 15, + "token_count": 613, + "parameters": [ + "line", + "s" + ], + "start_line": 64, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 1 + }, + { + "name": "buildhooks", + "long_name": "buildhooks( m )", + "filename": "common_rules.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "m" + ], + "start_line": 55, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "findcommonblocks", + "long_name": "findcommonblocks( block , top = 1 )", + "filename": "common_rules.py", + "nloc": 20, + "complexity": 9, + "token_count": 144, + "parameters": [ + "block", + "top" + ], + "start_line": 34, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "buildhooks.dadd", + "long_name": "buildhooks.dadd( line , s = doc )", + "filename": "common_rules.py", + "nloc": 63, + "complexity": 15, + "token_count": 613, + "parameters": [ + "line", + "s" + ], + "start_line": 64, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 1 + }, + { + "name": "buildhooks", + "long_name": "buildhooks( m )", + "filename": "common_rules.py", + "nloc": 9, + "complexity": 2, + "token_count": 76, + "parameters": [ + "m" + ], + "start_line": 55, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 123, + "complexity": 26, + "token_count": 986, + "diff_parsed": { + "added": [ + "terms of the NumPy License" + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/crackfortran.py", + "new_path": "numpy/f2py/crackfortran.py", + "filename": "crackfortran.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n Copyright 1999-2004 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/09/27 07:13:49 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\ncrackfortran --- read fortran (77,90) code and extract declaration information.\n Usage is explained in the comment block below.\n\nCopyright 1999-2004 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/09/27 07:13:49 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.177 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\n\"\"\"\n Usage of crackfortran:\n ======================\n Command line keys: -quiet,-verbose,-fix,-f77,-f90,-show,-h \n -m ,--ignore-contains\n Functions: crackfortran, crack2fortran\n The following Fortran statements/constructions are supported\n (or will be if needed):\n block data,byte,call,character,common,complex,contains,data,\n dimension,double complex,double precision,end,external,function,\n implicit,integer,intent,interface,intrinsic,\n logical,module,optional,parameter,private,public,\n program,real,(sequence?),subroutine,type,use,virtual,\n include,pythonmodule\n Note: 'virtual' is mapped to 'dimension'.\n Note: 'implicit integer (z) static (z)' is 'implicit static (z)' (this is minor bug).\n Note: code after 'contains' will be ignored until its scope ends.\n Note: 'common' statement is extended: dimensions are moved to variable definitions\n Note: f2py directive: f2py is read as \n Note: pythonmodule is introduced to represent Python module\n\n Usage:\n `postlist=crackfortran(files,funcs)`\n `postlist` contains declaration information read from the list of files `files`.\n `crack2fortran(postlist)` returns a fortran code to be saved to pyf-file\n\n `postlist` has the following structure:\n *** it is a list of dictionaries containing `blocks':\n B = {'block','body','vars','parent_block'[,'name','prefix','args','result',\n 'implicit','externals','interfaced','common','sortvars',\n 'commonvars','note']}\n B['block'] = 'interface' | 'function' | 'subroutine' | 'module' |\n 'program' | 'block data' | 'type' | 'pythonmodule'\n B['body'] --- list containing `subblocks' with the same structure as `blocks'\n B['parent_block'] --- dictionary of a parent block:\n C['body'][]['parent_block'] is C\n B['vars'] --- dictionary of variable definitions\n B['sortvars'] --- dictionary of variable definitions sorted by dependence (independent first)\n B['name'] --- name of the block (not if B['block']=='interface')\n B['prefix'] --- prefix string (only if B['block']=='function')\n B['args'] --- list of argument names if B['block']== 'function' | 'subroutine'\n B['result'] --- name of the return value (only if B['block']=='function')\n B['implicit'] --- dictionary {'a':,'b':...} | None\n B['externals'] --- list of variables being external\n B['interfaced'] --- list of variables being external and defined\n B['common'] --- dictionary of common blocks (list of objects)\n B['commonvars'] --- list of variables used in common blocks (dimensions are moved to variable definitions)\n B['from'] --- string showing the 'parents' of the current block\n B['use'] --- dictionary of modules used in current block:\n {:{['only':<0|1>],['map':{:,...}]}}\n B['note'] --- list of LaTeX comments on the block\n B['f2pyenhancements'] --- optional dictionary\n {'threadsafe':'','fortranname':,\n 'callstatement':|,\n 'callprotoargument':,\n 'usercode':|,\n 'pymethoddef:'\n }\n B['entry'] --- dictionary {entryname:argslist,..}\n B['varnames'] --- list of variable names given in the order of reading the\n Fortran code, useful for derived types.\n *** Variable definition is a dictionary\n D = B['vars'][] =\n {'typespec'[,'attrspec','kindselector','charselector','=','typename']}\n D['typespec'] = 'byte' | 'character' | 'complex' | 'double complex' |\n 'double precision' | 'integer' | 'logical' | 'real' | 'type'\n D['attrspec'] --- list of attributes (e.g. 'dimension()',\n 'external','intent(in|out|inout|hide|c|callback|cache)',\n 'optional','required', etc)\n K = D['kindselector'] = {['*','kind']} (only if D['typespec'] =\n 'complex' | 'integer' | 'logical' | 'real' )\n C = D['charselector'] = {['*','len','kind']}\n (only if D['typespec']=='character')\n D['='] --- initialization expression string\n D['typename'] --- name of the type if D['typespec']=='type'\n D['dimension'] --- list of dimension bounds\n D['intent'] --- list of intent specifications\n D['depend'] --- list of variable names on which current variable depends on\n D['check'] --- list of C-expressions; if C-expr returns zero, exception is raised\n D['note'] --- list of LaTeX comments on the variable\n *** Meaning of kind/char selectors (few examples):\n D['typespec>']*K['*']\n D['typespec'](kind=K['kind'])\n character*C['*']\n character(len=C['len'],kind=C['kind'])\n (see also fortran type declaration statement formats below)\n\n Fortran 90 type declaration statement format (F77 is subset of F90)\n====================================================================\n (Main source: IBM XL Fortran 5.1 Language Reference Manual)\n type declaration = [[]::] \n = byte |\n character[] |\n complex[] |\n double complex |\n double precision |\n integer[] |\n logical[] |\n real[] |\n type()\n = * |\n ([len=][,[kind=]]) |\n (kind=[,len=])\n = * |\n ([kind=])\n = comma separated list of attributes.\n Only the following attributes are used in\n building up the interface:\n external\n (parameter --- affects '=' key)\n optional\n intent\n Other attributes are ignored.\n = in | out | inout\n = comma separated list of dimension bounds.\n = [[*][()] | [()]*]\n [// | =] [,]\n\n In addition, the following attributes are used: check,depend,note\n\n TODO:\n * Apply 'parameter' attribute (e.g. 'integer parameter :: i=2' 'real x(i)'\n -> 'real x(2)')\n The above may be solved by creating appropriate preprocessor program, for example.\n\"\"\"\n#\nimport sys,string,fileinput,re,pprint,os,copy\nfrom auxfuncs import *\n\n# Global flags:\nstrictf77=1 # Ignore `!' comments unless line[0]=='!'\nsourcecodeform='fix' # 'fix','free'\nquiet=0 # Be verbose if 0 (Obsolete: not used any more)\nverbose=1 # Be quiet if 0, extra verbose if > 1.\ntabchar=4*' '\npyffilename=''\nf77modulename=''\nskipemptyends=0 # for old F77 programs without 'program' statement\nignorecontains=1\ndolowercase=1\ndebug=[]\n## do_analyze = 1\n\n###### global variables\n\n## use reload(crackfortran) to reset these variables\n\ngroupcounter=0\ngrouplist={groupcounter:[]}\nneededmodule=-1\nexpectbegin=1\nskipblocksuntil=-1\nusermodules=[]\nf90modulevars={}\ngotnextfile=1\nfilepositiontext=''\ncurrentfilename=''\nskipfunctions=[]\nskipfuncs=[]\nonlyfuncs=[]\ninclude_paths=[]\nprevious_context = None\n\n###### Some helper functions\ndef show(o,f=0):pprint.pprint(o)\nerrmess=sys.stderr.write\ndef outmess(line,flag=1):\n global filepositiontext\n if not verbose: return\n if not quiet:\n if flag:sys.stdout.write(filepositiontext)\n sys.stdout.write(line)\nre._MAXCACHE=50\ndefaultimplicitrules={}\nfor c in \"abcdefghopqrstuvwxyz$_\": defaultimplicitrules[c]={'typespec':'real'}\nfor c in \"ijklmn\": defaultimplicitrules[c]={'typespec':'integer'}\ndel c\nbadnames={}\ninvbadnames={}\nfor n in ['int','double','float','char','short','long','void','case','while',\n 'return','signed','unsigned','if','for','typedef','sizeof','union',\n 'struct','static','register','new','break','do','goto','switch',\n 'continue','else','inline','extern','delete','const','auto',\n 'len','rank','shape','index','slen','size','_i',\n 'flen','fshape',\n 'string','complex_double','float_double','stdin','stderr','stdout',\n 'type','default']:\n badnames[n]=n+'_bn'\n invbadnames[n+'_bn']=n\ndef rmbadname1(name):\n if badnames.has_key(name):\n errmess('rmbadname1: Replacing \"%s\" with \"%s\".\\n'%(name,badnames[name]))\n return badnames[name]\n return name\ndef rmbadname(names): return map(rmbadname1,names)\n\ndef undo_rmbadname1(name):\n if invbadnames.has_key(name):\n errmess('undo_rmbadname1: Replacing \"%s\" with \"%s\".\\n'\\\n %(name,invbadnames[name]))\n return invbadnames[name]\n return name\ndef undo_rmbadname(names): return map(undo_rmbadname1,names)\n\ndef getextension(name):\n i=string.rfind(name,'.')\n if i==-1: return ''\n if '\\\\' in name[i:]: return ''\n if '/' in name[i:]: return ''\n return name[i+1:]\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\n\n####### Read fortran (77,90) code\ndef readfortrancode(ffile,dowithline=show,istop=1):\n \"\"\"\n Read fortran codes from files and\n 1) Get rid of comments, line continuations, and empty lines; lower cases.\n 2) Call dowithline(line) on every line.\n 3) Recursively call itself when statement \\\"include ''\\\" is met.\n \"\"\"\n global gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase,include_paths\n if not istop:\n saveglobals=gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase\n if ffile==[]: return\n localdolowercase = dolowercase\n cont=0\n finalline=''\n ll=''\n commentline=re.compile(r'(?P([^\"]*\"[^\"]*\"[^\"!]*|[^\\']*\\'[^\\']*\\'[^\\'!]*|[^!]*))!{1}(?P.*)')\n includeline=re.compile(r'\\s*include\\s*(\\'|\")(?P[^\\'\"]*)(\\'|\")',re.I)\n cont1=re.compile(r'(?P.*)&\\s*\\Z')\n cont2=re.compile(r'(\\s*&|)(?P.*)')\n mline_mark = re.compile(r\".*?'''\")\n if istop: dowithline('',-1)\n ll,l1='',''\n spacedigits=[' ']+map(str,range(10))\n filepositiontext=''\n fin=fileinput.FileInput(ffile)\n while 1:\n l=fin.readline()\n if not l: break\n if fin.isfirstline():\n filepositiontext=''\n currentfilename=fin.filename()\n gotnextfile=1\n l1=l\n strictf77=0\n sourcecodeform='fix'\n ext = os.path.splitext(currentfilename)[1]\n if is_f_file(currentfilename) and \\\n not (_has_f90_header(l) or _has_fix_header(l)):\n strictf77=1 \n elif is_free_format(currentfilename) and not _has_fix_header(l):\n sourcecodeform='free'\n if strictf77: beginpattern=beginpattern77\n else: beginpattern=beginpattern90\n outmess('\\tReading file %s (format:%s%s)\\n'\\\n %(`currentfilename`,sourcecodeform,\n strictf77 and ',strict' or ''))\n\n l=string.expandtabs(l).replace('\\xa0',' ')\n while not l=='': # Get rid of newline characters\n if l[-1] not in \"\\n\\r\\f\": break\n l=l[:-1]\n if not strictf77:\n r=commentline.match(l)\n if r:\n l=r.group('line')+' ' # Strip comments starting with `!'\n rl=r.group('rest')\n if string.lower(rl[:4])=='f2py': # f2py directive\n l = l + 4*' '\n r=commentline.match(rl[4:])\n if r: l=l+r('line')\n else: l = l + rl[4:]\n if string.strip(l)=='': # Skip empty line\n cont=0\n continue\n if sourcecodeform=='fix':\n if l[0] in ['*','c','!','C','#']:\n if string.lower(l[1:5])=='f2py': # f2py directive\n l=' '+l[5:]\n else: # Skip comment line\n cont=0\n continue\n elif strictf77:\n if len(l)>72: l=l[:72]\n if not (l[0] in spacedigits):\n raise 'readfortrancode: Found non-(space,digit) char in the first column.\\n\\tAre you sure that this code is in fix form?\\n\\tline=%s'%`l`\n\n if (not cont or strictf77) and (len(l)>5 and not l[5]==' '):\n # Continuation of a previous line\n ll=ll+l[6:]\n finalline=''\n origfinalline=''\n else:\n if not strictf77:\n # F90 continuation\n r=cont1.match(l)\n if r: l=r.group('line') # Continuation follows ..\n if cont:\n ll=ll+cont2.match(l).group('line')\n finalline=''\n origfinalline=''\n else:\n l=' '+l[5:] # clean up line beginning from possible digits.\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline=ll\n ll=l\n cont=(r is not None)\n else:\n l=' '+l[5:] # clean up line beginning from possible digits.\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline =ll\n ll=l\n\n elif sourcecodeform=='free':\n if not cont and ext=='.pyf' and mline_mark.match(l):\n l = l + '\\n'\n while 1:\n lc = fin.readline()\n if not lc:\n errmess('Unexpected end of file when reading multiline\\n')\n break\n l = l + lc\n if mline_mark.match(lc):\n break\n l = l.rstrip()\n r=cont1.match(l)\n if r: l=r.group('line') # Continuation follows ..\n if cont:\n ll=ll+cont2.match(l).group('line')\n finalline=''\n origfinalline=''\n else:\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline =ll\n ll=l\n cont=(r is not None)\n else:\n raise ValueError,\"Flag sourcecodeform must be either 'fix' or 'free': %s\"%`sourcecodeform`\n filepositiontext='Line #%d in %s:\"%s\"\\n\\t' % (fin.filelineno()-1,currentfilename,l1)\n m=includeline.match(origfinalline)\n if m:\n fn=m.group('name')\n if os.path.isfile(fn):\n readfortrancode(fn,dowithline=dowithline,istop=0)\n else:\n include_dirs = [os.path.dirname(currentfilename)] + include_paths\n foundfile = 0\n for inc_dir in include_dirs:\n fn1 = os.path.join(inc_dir,fn)\n if os.path.isfile(fn1):\n foundfile = 1\n readfortrancode(fn1,dowithline=dowithline,istop=0)\n break\n if not foundfile:\n outmess('readfortrancode: could not find include file %s. Ignoring.\\n'%(`fn`))\n else:\n dowithline(finalline)\n l1=ll\n if localdolowercase:\n finalline=string.lower(ll)\n else: finalline=ll\n origfinalline = ll\n filepositiontext='Line #%d in %s:\"%s\"\\n\\t' % (fin.filelineno()-1,currentfilename,l1)\n m=includeline.match(origfinalline)\n if m:\n fn=m.group('name')\n fn1=os.path.join(os.path.dirname(currentfilename),fn)\n if os.path.isfile(fn):\n readfortrancode(fn,dowithline=dowithline,istop=0)\n elif os.path.isfile(fn1):\n readfortrancode(fn1,dowithline=dowithline,istop=0)\n else:\n outmess('readfortrancode: could not find include file %s. Ignoring.\\n'%(`fn`))\n else:\n dowithline(finalline)\n filepositiontext=''\n fin.close()\n if istop: dowithline('',1)\n else:\n gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase=saveglobals\n\n########### Crack line\nbeforethisafter=r'\\s*(?P%s(?=\\s*(\\b(%s)\\b)))'+ \\\n r'\\s*(?P(\\b(%s)\\b))'+ \\\n r'\\s*(?P%s)\\s*\\Z'\n##\nfortrantypes='character|logical|integer|real|complex|double\\s*(precision\\s*(complex|)|complex)|type(?=\\s*\\([\\w\\s,=(*)]*\\))|byte'\ntypespattern=re.compile(beforethisafter%('',fortrantypes,fortrantypes,'.*'),re.I),'type'\ntypespattern4implicit=re.compile(beforethisafter%('',fortrantypes+'|static|automatic|undefined',fortrantypes+'|static|automatic|undefined','.*'),re.I)\n#\nfunctionpattern=re.compile(beforethisafter%('([a-z]+[\\w\\s(=*+-/)]*?|)','function','function','.*'),re.I),'begin'\nsubroutinepattern=re.compile(beforethisafter%('[a-z\\s]*?','subroutine','subroutine','.*'),re.I),'begin'\n#modulepattern=re.compile(beforethisafter%('[a-z\\s]*?','module','module','.*'),re.I),'begin'\n#\ngroupbegins77=r'program|block\\s*data'\nbeginpattern77=re.compile(beforethisafter%('',groupbegins77,groupbegins77,'.*'),re.I),'begin'\ngroupbegins90=groupbegins77+r'|module|python\\s*module|interface|type(?!\\s*\\()'\nbeginpattern90=re.compile(beforethisafter%('',groupbegins90,groupbegins90,'.*'),re.I),'begin'\ngroupends=r'end|endprogram|endblockdata|endmodule|endpythonmodule|endinterface'\nendpattern=re.compile(beforethisafter%('',groupends,groupends,'[\\w\\s]*'),re.I),'end'\n#endifs='end\\s*(if|do|where|select|while|forall)'\nendifs='(end\\s*(if|do|where|select|while|forall))|(module\\s*procedure)'\nendifpattern=re.compile(beforethisafter%('[\\w]*?',endifs,endifs,'[\\w\\s]*'),re.I),'endif'\n#\nimplicitpattern=re.compile(beforethisafter%('','implicit','implicit','.*'),re.I),'implicit'\ndimensionpattern=re.compile(beforethisafter%('','dimension|virtual','dimension|virtual','.*'),re.I),'dimension'\nexternalpattern=re.compile(beforethisafter%('','external','external','.*'),re.I),'external'\noptionalpattern=re.compile(beforethisafter%('','optional','optional','.*'),re.I),'optional'\nrequiredpattern=re.compile(beforethisafter%('','required','required','.*'),re.I),'required'\npublicpattern=re.compile(beforethisafter%('','public','public','.*'),re.I),'public'\nprivatepattern=re.compile(beforethisafter%('','private','private','.*'),re.I),'private'\nintrisicpattern=re.compile(beforethisafter%('','intrisic','intrisic','.*'),re.I),'intrisic'\nintentpattern=re.compile(beforethisafter%('','intent|depend|note|check','intent|depend|note|check','\\s*\\(.*?\\).*'),re.I),'intent'\nparameterpattern=re.compile(beforethisafter%('','parameter','parameter','\\s*\\(.*'),re.I),'parameter'\ndatapattern=re.compile(beforethisafter%('','data','data','.*'),re.I),'data'\ncallpattern=re.compile(beforethisafter%('','call','call','.*'),re.I),'call'\nentrypattern=re.compile(beforethisafter%('','entry','entry','.*'),re.I),'entry'\ncallfunpattern=re.compile(beforethisafter%('','callfun','callfun','.*'),re.I),'callfun'\ncommonpattern=re.compile(beforethisafter%('','common','common','.*'),re.I),'common'\nusepattern=re.compile(beforethisafter%('','use','use','.*'),re.I),'use'\ncontainspattern=re.compile(beforethisafter%('','contains','contains',''),re.I),'contains'\nformatpattern=re.compile(beforethisafter%('','format','format','.*'),re.I),'format'\n## Non-fortran and f2py-specific statements\nf2pyenhancementspattern=re.compile(beforethisafter%('','threadsafe|fortranname|callstatement|callprotoargument|usercode|pymethoddef','threadsafe|fortranname|callstatement|callprotoargument|usercode|pymethoddef','.*'),re.I|re.S),'f2pyenhancements'\nmultilinepattern = re.compile(r\"\\s*(?P''')(?P.*?)(?P''')\\s*\\Z\",re.S),'multiline'\n##\n\ndef _simplifyargs(argsline):\n a = []\n for n in string.split(markoutercomma(argsline),'@,@'):\n for r in '(),':\n n = string.replace(n,r,'_')\n a.append(n)\n return string.join(a,',')\n\ncrackline_re_1 = re.compile(r'\\s*(?P\\b[a-z]+[\\w]*\\b)\\s*[=].*',re.I)\ndef crackline(line,reset=0):\n \"\"\"\n reset=-1 --- initialize\n reset=0 --- crack the line\n reset=1 --- final check if mismatch of blocks occured\n\n Cracked data is saved in grouplist[0].\n \"\"\"\n global beginpattern,groupcounter,groupname,groupcache,grouplist,gotnextfile,\\\n filepositiontext,currentfilename,neededmodule,expectbegin,skipblocksuntil,\\\n skipemptyends,previous_context\n if ';' in line and not (f2pyenhancementspattern[0].match(line) or\n multilinepattern[0].match(line)):\n for l in line.split(';'):\n assert reset==0,`reset` # XXX: non-zero reset values need testing\n crackline(l,reset)\n return\n if reset<0:\n groupcounter=0\n groupname={groupcounter:''}\n groupcache={groupcounter:{}}\n grouplist={groupcounter:[]}\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['block']=''\n groupcache[groupcounter]['name']=''\n neededmodule=-1\n skipblocksuntil=-1\n return\n if reset>0:\n fl=0\n if f77modulename and neededmodule==groupcounter: fl=2\n while groupcounter>fl:\n outmess('crackline: groupcounter=%s groupname=%s\\n'%(`groupcounter`,`groupname`))\n outmess('crackline: Mismatch of blocks encountered. Trying to fix it by assuming \"end\" statement.\\n')\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1\n if f77modulename and neededmodule==groupcounter:\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end interface\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end module\n neededmodule=-1\n return\n if line=='': return\n flag=0\n for pat in [dimensionpattern,externalpattern,intentpattern,optionalpattern,\n requiredpattern,\n parameterpattern,datapattern,publicpattern,privatepattern,\n intrisicpattern,\n endifpattern,endpattern,\n formatpattern,\n beginpattern,functionpattern,subroutinepattern,\n implicitpattern,typespattern,commonpattern,\n callpattern,usepattern,containspattern,\n entrypattern,\n f2pyenhancementspattern,\n multilinepattern\n ]:\n m = pat[0].match(line)\n if m:\n break\n flag=flag+1\n if not m:\n re_1 = crackline_re_1\n if 0<=skipblocksuntil<=groupcounter:return\n if groupcache[groupcounter].has_key('externals'):\n for name in groupcache[groupcounter]['externals']:\n if invbadnames.has_key(name):\n name=invbadnames[name]\n if groupcache[groupcounter].has_key('interfaced') and name in groupcache[groupcounter]['interfaced']: continue\n m1=re.match(r'(?P[^\"]*)\\b%s\\b\\s*@\\(@(?P[^@]*)@\\)@.*\\Z'%name,markouterparen(line),re.I)\n if m1:\n m2 = re_1.match(m1.group('before'))\n a = _simplifyargs(m1.group('args'))\n if m2:\n line='callfun %s(%s) result (%s)'%(name,a,m2.group('result'))\n else: line='callfun %s(%s)'%(name,a)\n m = callfunpattern[0].match(line)\n if not m:\n outmess('crackline: could not resolve function call for line=%s.\\n'%`line`)\n return\n analyzeline(m,'callfun',line)\n return\n if verbose>1:\n previous_context = None\n outmess('crackline:%d: No pattern for line\\n'%(groupcounter))\n return\n elif pat[1]=='end':\n if 0<=skipblocksuntil(@\\(@.*?@\\)@|[*][\\d*]+|[*]\\s*@\\(@.*?@\\)@|))(?P.*)\\Z',re.I)\nnameargspattern=re.compile(r'\\s*(?P\\b[\\w$]+\\b)\\s*(@\\(@\\s*(?P[\\w\\s,]*)\\s*@\\)@|)\\s*(result(\\s*@\\(@\\s*(?P\\b[\\w$]+\\b)\\s*@\\)@|))*\\s*\\Z',re.I)\ncallnameargspattern=re.compile(r'\\s*(?P\\b[\\w$]+\\b)\\s*@\\(@\\s*(?P.*)\\s*@\\)@\\s*\\Z',re.I)\nreal16pattern = re.compile(r'([-+]?(?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+))[dD]((?:[-+]?\\d+)?)')\nreal8pattern = re.compile(r'([-+]?((?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+))[eE]((?:[-+]?\\d+)?)|(\\d+\\.\\d*))')\n\n_intentcallbackpattern = re.compile(r'intent\\s*\\(.*?\\bcallback\\b',re.I)\ndef _is_intent_callback(vdecl):\n for a in vdecl.get('attrspec',[]):\n if _intentcallbackpattern.match(a):\n return 1\n return 0\n\ndef _resolvenameargspattern(line):\n line = markouterparen(line)\n m1=nameargspattern.match(line)\n if m1: return m1.group('name'),m1.group('args'),m1.group('result')\n m1=callnameargspattern.match(line)\n if m1: return m1.group('name'),m1.group('args'),None\n return None,[],None\n \ndef analyzeline(m,case,line):\n global groupcounter,groupname,groupcache,grouplist,filepositiontext,\\\n currentfilename,f77modulename,neededinterface,neededmodule,expectbegin,\\\n gotnextfile,previous_context\n block=m.group('this')\n if case != 'multiline':\n previous_context = None\n if expectbegin and case not in ['begin','call','callfun','type'] \\\n and not skipemptyends and groupcounter<1:\n newname=string.split(os.path.basename(currentfilename),'.')[0]\n outmess('analyzeline: no group yet. Creating program group with name \"%s\".\\n'%newname)\n gotnextfile=0\n groupcounter=groupcounter+1\n groupname[groupcounter]='program'\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['block']='program'\n groupcache[groupcounter]['name']=newname\n groupcache[groupcounter]['from']='fromsky'\n expectbegin=0\n if case in ['begin','call','callfun']:\n # Crack line => block,name,args,result\n block = block.lower()\n if re.match(r'block\\s*data',block,re.I): block='block data'\n if re.match(r'python\\s*module',block,re.I): block='python module'\n name,args,result = _resolvenameargspattern(m.group('after'))\n if name is None:\n if block=='block data':\n name = '_BLOCK_DATA_'\n else:\n name = ''\n if block not in ['interface','block data']:\n outmess('analyzeline: No name/args pattern found for line.\\n')\n\n previous_context = (block,name,groupcounter)\n if args: args=rmbadname(map(string.strip,string.split(markoutercomma(args),'@,@')))\n else: args=[]\n if '' in args:\n while '' in args:\n args.remove('')\n outmess('analyzeline: argument list is malformed (missing argument).\\n')\n \n # end of crack line => block,name,args,result\n needmodule=0\n needinterface=0\n\n if case in ['call','callfun']:\n needinterface=1\n if not groupcache[groupcounter].has_key('args'): return\n if name not in groupcache[groupcounter]['args']:\n return\n for it in grouplist[groupcounter]:\n if it['name']==name: return\n if name in groupcache[groupcounter]['interfaced']: return\n block={'call':'subroutine','callfun':'function'}[case]\n if f77modulename and neededmodule==-1 and groupcounter<=1:\n neededmodule=groupcounter+2\n needmodule=1\n needinterface=1 \n # Create new block(s)\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n if needmodule:\n if verbose>1:\n outmess('analyzeline: Creating module block %s\\n'%`f77modulename`,0)\n groupname[groupcounter]='module'\n groupcache[groupcounter]['block']='python module'\n groupcache[groupcounter]['name']=f77modulename\n groupcache[groupcounter]['from']=''\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n if needinterface:\n if verbose>1:\n outmess('analyzeline: Creating additional interface block.\\n',0)\n groupname[groupcounter]='interface'\n groupcache[groupcounter]['block']='interface'\n groupcache[groupcounter]['name']='unknown_interface'\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],groupcache[groupcounter-1]['name'])\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n groupname[groupcounter]=block\n groupcache[groupcounter]['block']=block\n if not name: name='unknown_'+block\n groupcache[groupcounter]['prefix']=m.group('before')\n groupcache[groupcounter]['name']=rmbadname1(name)\n groupcache[groupcounter]['result']=result\n if groupcounter==1:\n groupcache[groupcounter]['from']=currentfilename\n else:\n if f77modulename and groupcounter==3:\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],currentfilename)\n else:\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],groupcache[groupcounter-1]['name'])\n for k in groupcache[groupcounter].keys():\n if not groupcache[groupcounter][k]: del groupcache[groupcounter][k]\n groupcache[groupcounter]['args']=args\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['entry']={}\n # end of creation\n if block=='type':\n groupcache[groupcounter]['varnames'] = []\n\n if case in ['call','callfun']: # set parents variables\n if name not in groupcache[groupcounter-2]['externals']:\n groupcache[groupcounter-2]['externals'].append(name)\n groupcache[groupcounter]['vars']=copy.deepcopy(groupcache[groupcounter-2]['vars'])\n #try: del groupcache[groupcounter]['vars'][groupcache[groupcounter-2]['name']]\n #except: pass\n try: del groupcache[groupcounter]['vars'][name][groupcache[groupcounter]['vars'][name]['attrspec'].index('external')]\n except: pass\n if block in ['function','subroutine']: # set global attributes\n try: groupcache[groupcounter]['vars'][name]=appenddecl(groupcache[groupcounter]['vars'][name],groupcache[groupcounter-2]['vars'][''])\n except: pass\n if case=='callfun': # return type\n if result and groupcache[groupcounter]['vars'].has_key(result):\n if not name==result:\n groupcache[groupcounter]['vars'][name]=appenddecl(groupcache[groupcounter]['vars'][name],groupcache[groupcounter]['vars'][result])\n #if groupcounter>1: # name is interfaced\n try: groupcache[groupcounter-2]['interfaced'].append(name)\n except: pass\n if block=='function':\n t=typespattern[0].match(m.group('before')+' '+name)\n if t:\n typespec,selector,attr,edecl=cracktypespec0(t.group('this'),t.group('after'))\n updatevars(typespec,selector,attr,edecl)\n if case in ['call','callfun']:\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end routine\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end interface\n elif case=='entry':\n name,args,result=_resolvenameargspattern(m.group('after'))\n if name is not None:\n if args:\n args=rmbadname(map(string.strip,string.split(markoutercomma(args),'@,@')))\n else: args=[] \n assert result is None,`result`\n groupcache[groupcounter]['entry'][name] = args\n previous_context = ('entry',name,groupcounter)\n elif case=='type':\n typespec,selector,attr,edecl=cracktypespec0(block,m.group('after'))\n last_name = updatevars(typespec,selector,attr,edecl)\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case in ['dimension','intent','optional','required','external','public','private','intrisic']:\n edecl=groupcache[groupcounter]['vars']\n ll=m.group('after')\n i=string.find(ll,'::')\n if i<0 and case=='intent':\n i=string.find(markouterparen(ll),'@)@')-2\n ll=ll[:i+1]+'::'+ll[i+1:]\n i=string.find(ll,'::')\n if ll[i:]=='::' and groupcache[groupcounter].has_key('args'):\n outmess('All arguments will have attribute %s%s\\n'%(m.group('this'),ll[:i]))\n ll = ll + string.join(groupcache[groupcounter]['args'],',')\n if i<0:i=0;pl=''\n else: pl=string.strip(ll[:i]);ll=ll[i+2:]\n ch = string.split(markoutercomma(pl),'@,@')\n if len(ch)>1:\n pl = ch[0]\n outmess('analyzeline: cannot handle multiple attributes without type specification. Ignoring %r.\\n' % (','.join(ch[1:])))\n last_name = None\n for e in map(string.strip,string.split(markoutercomma(ll),'@,@')):\n m1=namepattern.match(e)\n if not m1:\n if case in ['public','private']: k=''\n else:\n print m.groupdict()\n outmess('analyzeline: no name pattern found in %s statement for %s. Skipping.\\n'%(case,`e`))\n continue\n else:\n k=rmbadname1(m1.group('name'))\n if not edecl.has_key(k): edecl[k]={}\n if case=='dimension': ap=case+m1.group('after')\n if case=='intent':\n ap=m.group('this')+pl\n if _intentcallbackpattern.match(ap):\n if k not in groupcache[groupcounter]['args']:\n if groupcounter>1 and \\\n string.find(groupcache[groupcounter-2]['name'],\n '__user__')==-1:\n outmess('analyzeline: appending intent(callback) %s'\\\n ' to %s arguments\\n' % (k,groupcache[groupcounter]['name']))\n groupcache[groupcounter]['args'].append(k)\n else:\n errmess('analyzeline: intent(callback) %s is already'\\\n ' in argument list' % (k))\n if case in ['optional','required','public','external','private','intrisic']: ap=case\n if edecl[k].has_key('attrspec'): edecl[k]['attrspec'].append(ap)\n else: edecl[k]['attrspec']=[ap]\n if case=='external':\n if groupcache[groupcounter]['block']=='program':\n outmess('analyzeline: ignoring program arguments\\n')\n continue\n if k not in groupcache[groupcounter]['args']:\n #outmess('analyzeline: ignoring external %s (not in arguments list)\\n'%(`k`))\n continue\n if not groupcache[groupcounter].has_key('externals'):\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['externals'].append(k)\n last_name = k\n groupcache[groupcounter]['vars']=edecl\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case=='parameter':\n edecl=groupcache[groupcounter]['vars']\n ll=string.strip(m.group('after'))[1:-1]\n last_name = None\n for e in string.split(markoutercomma(ll),'@,@'):\n try:\n k,initexpr=map(string.strip,string.split(e,'='))\n except:\n outmess('analyzeline: could not extract name,expr in parameter statement \"%s\" of \"%s\"\\n'%(e,ll));continue\n params = get_parameters(edecl)\n k=rmbadname1(k)\n if not edecl.has_key(k): edecl[k]={}\n if edecl[k].has_key('=') and (not edecl[k]['=']==initexpr):\n outmess('analyzeline: Overwriting the value of parameter \"%s\" (\"%s\") with \"%s\".\\n'%(k,edecl[k]['='],initexpr))\n t = determineexprtype(initexpr,params)\n if t:\n if t.get('typespec')=='real':\n tt = list(initexpr)\n for m in real16pattern.finditer(initexpr):\n tt[m.start():m.end()] = list(\\\n initexpr[m.start():m.end()].lower().replace('d', 'e'))\n initexpr = \"\".join(tt)\n elif t.get('typespec')=='complex':\n initexpr = initexpr[1:].lower().replace('d','e').\\\n replace(',','+1j*(')\n try:\n v = eval(initexpr,{},params)\n except (SyntaxError,NameError),msg:\n errmess('analyzeline: Failed to evaluate %r. Ignoring: %s\\n'\\\n % (initexpr, msg))\n continue\n edecl[k]['='] = repr(v)\n if edecl[k].has_key('attrspec'):\n edecl[k]['attrspec'].append('parameter')\n else: edecl[k]['attrspec']=['parameter']\n last_name = k\n groupcache[groupcounter]['vars']=edecl\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case=='implicit':\n if string.lower(string.strip(m.group('after')))=='none':\n groupcache[groupcounter]['implicit']=None\n elif m.group('after'):\n if groupcache[groupcounter].has_key('implicit'):\n impl=groupcache[groupcounter]['implicit']\n else: impl={}\n if impl is None:\n outmess('analyzeline: Overwriting earlier \"implicit none\" statement.\\n')\n impl={}\n for e in string.split(markoutercomma(m.group('after')),'@,@'):\n decl={}\n m1=re.match(r'\\s*(?P.*?)\\s*(\\(\\s*(?P[a-z-, ]+)\\s*\\)\\s*|)\\Z',e,re.I)\n if not m1:\n outmess('analyzeline: could not extract info of implicit statement part \"%s\"\\n'%(e));continue\n m2=typespattern4implicit.match(m1.group('this'))\n if not m2:\n outmess('analyzeline: could not extract types pattern of implicit statement part \"%s\"\\n'%(e));continue\n typespec,selector,attr,edecl=cracktypespec0(m2.group('this'),m2.group('after'))\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n decl['typespec']=typespec\n decl['kindselector']=kindselect\n decl['charselector']=charselect\n decl['typename']=typename\n for k in decl.keys():\n if not decl[k]: del decl[k]\n for r in string.split(markoutercomma(m1.group('after')),'@,@'):\n if '-' in r:\n try: begc,endc=map(string.strip,string.split(r,'-'))\n except:\n outmess('analyzeline: expected \"-\" instead of \"%s\" in range list of implicit statement\\n'%r);continue\n else: begc=endc=string.strip(r)\n if not len(begc)==len(endc)==1:\n outmess('analyzeline: expected \"-\" instead of \"%s\" in range list of implicit statement (2)\\n'%r);continue\n for o in range(ord(begc),ord(endc)+1):\n impl[chr(o)]=decl\n groupcache[groupcounter]['implicit']=impl\n elif case=='data':\n ll=[]\n dl='';il='';f=0;fc=1\n for c in m.group('after'):\n if c==\"'\": fc=not fc\n if c=='/' and fc: f=f+1;continue\n if f==0: dl=dl+c\n elif f==1: il=il+c\n elif f==2:\n dl = dl.strip()\n if dl.startswith(','):\n dl = dl[1:].strip()\n ll.append([dl,il])\n dl=c;il='';f=0\n if f==2:\n dl = dl.strip()\n if dl.startswith(','):\n dl = dl[1:].strip()\n ll.append([dl,il])\n vars={}\n if groupcache[groupcounter].has_key('vars'):\n vars=groupcache[groupcounter]['vars']\n last_name = None\n for l in ll:\n l=map(string.strip,l)\n if l[0][0]==',':l[0]=l[0][1:]\n if l[0][0]=='(':\n outmess('analyzeline: implied-DO list \"%s\" is not supported. Skipping.\\n'%l[0])\n continue\n #if '(' in l[0]:\n # #outmess('analyzeline: ignoring this data statement.\\n')\n # continue\n i=0;j=0;llen=len(l[1])\n for v in rmbadname(map(string.strip,string.split(markoutercomma(l[0]),'@,@'))):\n fc=0\n while (i=3:\n bn = string.strip(bn)\n if not bn: bn='_BLNK_'\n cl.append([bn,ol])\n f=f-2;bn='';ol=''\n if f%2: bn=bn+c\n else: ol=ol+c\n bn = string.strip(bn)\n if not bn: bn='_BLNK_'\n cl.append([bn,ol])\n commonkey={}\n if groupcache[groupcounter].has_key('common'):\n commonkey=groupcache[groupcounter]['common']\n for c in cl:\n if commonkey.has_key(c[0]):\n outmess('analyzeline: previously defined common block encountered. Skipping.\\n')\n continue\n commonkey[c[0]]=[]\n for i in map(string.strip,string.split(markoutercomma(c[1]),'@,@')):\n if i: commonkey[c[0]].append(i)\n groupcache[groupcounter]['common']=commonkey\n previous_context = ('common',bn,groupcounter)\n elif case=='use':\n m1=re.match(r'\\A\\s*(?P\\b[\\w]+\\b)\\s*((,(\\s*\\bonly\\b\\s*:|(?P))\\s*(?P.*))|)\\s*\\Z',m.group('after'),re.I)\n if m1:\n mm=m1.groupdict()\n if not groupcache[groupcounter].has_key('use'): groupcache[groupcounter]['use']={}\n name=m1.group('name')\n groupcache[groupcounter]['use'][name]={}\n isonly=0\n if mm.has_key('list') and mm['list'] is not None:\n if mm.has_key('notonly') and mm['notonly'] is None:isonly=1\n groupcache[groupcounter]['use'][name]['only']=isonly\n ll=map(string.strip,string.split(mm['list'],','))\n rl={}\n for l in ll:\n if '=' in l:\n m2=re.match(r'\\A\\s*(?P\\b[\\w]+\\b)\\s*=\\s*>\\s*(?P\\b[\\w]+\\b)\\s*\\Z',l,re.I)\n if m2: rl[string.strip(m2.group('local'))]=string.strip(m2.group('use'))\n else:\n outmess('analyzeline: Not local=>use pattern found in %s\\n'%`l`)\n else:\n rl[l]=l\n groupcache[groupcounter]['use'][name]['map']=rl\n else:\n pass\n \n else:\n print m.groupdict()\n outmess('analyzeline: Could not crack the use statement.\\n')\n elif case in ['f2pyenhancements']:\n if not groupcache[groupcounter].has_key ('f2pyenhancements'):\n groupcache[groupcounter]['f2pyenhancements'] = {}\n d = groupcache[groupcounter]['f2pyenhancements']\n if m.group('this')=='usercode' and d.has_key('usercode'):\n if type(d['usercode']) is type(''):\n d['usercode'] = [d['usercode']]\n d['usercode'].append(m.group('after'))\n else:\n d[m.group('this')] = m.group('after')\n elif case=='multiline':\n if previous_context is None:\n if verbose:\n outmess('analyzeline: No context for multiline block.\\n')\n return\n gc = groupcounter\n #gc = previous_context[2]\n appendmultiline(groupcache[gc],\n previous_context[:2],\n m.group('this'))\n else:\n if verbose>1:\n print m.groupdict()\n outmess('analyzeline: No code implemented for line.\\n')\n\ndef appendmultiline(group, context_name,ml):\n if not group.has_key('f2pymultilines'):\n group['f2pymultilines'] = {}\n d = group['f2pymultilines']\n if not d.has_key(context_name):\n d[context_name] = []\n d[context_name].append(ml)\n return\n\ndef cracktypespec0(typespec,ll):\n selector=None\n attr=None\n if re.match(r'double\\s*complex',typespec,re.I): typespec='double complex'\n elif re.match(r'double\\s*precision',typespec,re.I): typespec='double precision'\n else: typespec=string.lower(string.strip(typespec))\n m1=selectpattern.match(markouterparen(ll))\n if not m1:\n outmess('cracktypespec0: no kind/char_selector pattern found for line.\\n')\n return\n d=m1.groupdict()\n for k in d.keys(): d[k]=unmarkouterparen(d[k])\n if typespec in ['complex','integer','logical','real','character','type']:\n selector=d['this']\n ll=d['after']\n i=string.find(ll,'::')\n if i>=0:\n attr=string.strip(ll[:i])\n ll=ll[i+2:]\n return typespec,selector,attr,ll\n#####\nnamepattern=re.compile(r'\\s*(?P\\b[\\w]+\\b)\\s*(?P.*)\\s*\\Z',re.I)\nkindselector=re.compile(r'\\s*(\\(\\s*(kind\\s*=)?\\s*(?P.*)\\s*\\)|[*]\\s*(?P.*?))\\s*\\Z',re.I)\ncharselector=re.compile(r'\\s*(\\((?P.*)\\)|[*]\\s*(?P.*))\\s*\\Z',re.I)\nlenkindpattern=re.compile(r'\\s*(kind\\s*=\\s*(?P.*?)\\s*(@,@\\s*len\\s*=\\s*(?P.*)|)|(len\\s*=\\s*|)(?P.*?)\\s*(@,@\\s*(kind\\s*=\\s*|)(?P.*)|))\\s*\\Z',re.I)\nlenarraypattern=re.compile(r'\\s*(@\\(@\\s*(?!/)\\s*(?P.*?)\\s*@\\)@\\s*[*]\\s*(?P.*?)|([*]\\s*(?P.*?)|)\\s*(@\\(@\\s*(?!/)\\s*(?P.*?)\\s*@\\)@|))\\s*(=\\s*(?P.*?)|(@\\(@|)/\\s*(?P.*?)\\s*/(@\\)@|)|)\\s*\\Z',re.I)\ndef removespaces(expr):\n expr=string.strip(expr)\n if len(expr)<=1: return expr\n expr2=expr[0]\n for i in range(1,len(expr)-1):\n if expr[i]==' ' and \\\n ((expr[i+1] in \"()[]{}= \") or (expr[i-1] in \"()[]{}= \")): continue\n expr2=expr2+expr[i]\n expr2=expr2+expr[-1]\n return expr2\ndef markinnerspaces(line):\n l='';f=0\n cc='\\''\n cc1='\"'\n cb=''\n for c in line:\n if cb=='\\\\' and c in ['\\\\','\\'','\"']:\n l=l+c;\n cb=c\n continue \n if f==0 and c in ['\\'','\"']: cc=c; cc1={'\\'':'\"','\"':'\\''}[c]\n if c==cc:f=f+1\n elif c==cc:f=f-1\n elif c==' ' and f==1: l=l+'@_@'; continue\n l=l+c;cb=c\n return l\ndef updatevars(typespec,selector,attrspec,entitydecl):\n global groupcache,groupcounter\n last_name = None\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n if attrspec:\n attrspec=map(string.strip,string.split(markoutercomma(attrspec),'@,@'))\n l = []\n c = re.compile(r'(?P[a-zA-Z]+)')\n for a in attrspec:\n m = c.match(a)\n if m:\n s = string.lower(m.group('start'))\n a = s + a[len(s):]\n l.append(a)\n attrspec = l\n el=map(string.strip,string.split(markoutercomma(entitydecl),'@,@'))\n el1=[]\n for e in el:\n for e1 in map(string.strip,string.split(markoutercomma(removespaces(markinnerspaces(e)),comma=' '),'@ @')):\n if e1: el1.append(string.replace(e1,'@_@',' '))\n for e in el1:\n m=namepattern.match(e)\n if not m:\n outmess('updatevars: no name pattern found for entity=%s. Skipping.\\n'%(`e`))\n continue\n ename=rmbadname1(m.group('name'))\n edecl={}\n if groupcache[groupcounter]['vars'].has_key(ename):\n edecl=groupcache[groupcounter]['vars'][ename].copy()\n has_typespec = edecl.has_key('typespec')\n if not has_typespec:\n edecl['typespec']=typespec\n elif typespec and (not typespec==edecl['typespec']):\n outmess('updatevars: attempt to change the type of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['typespec'],typespec))\n if not edecl.has_key('kindselector'):\n edecl['kindselector']=copy.copy(kindselect)\n elif kindselect:\n for k in kindselect.keys():\n if edecl['kindselector'].has_key(k) and (not kindselect[k]==edecl['kindselector'][k]):\n outmess('updatevars: attempt to change the kindselector \"%s\" of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (k,ename,edecl['kindselector'][k],kindselect[k]))\n else: edecl['kindselector'][k]=copy.copy(kindselect[k])\n if not edecl.has_key('charselector') and charselect:\n if not has_typespec:\n edecl['charselector']=charselect\n else:\n errmess('updatevars:%s: attempt to change empty charselector to %r. Ignoring.\\n' \\\n %(ename,charselect))\n elif charselect:\n for k in charselect.keys():\n if edecl['charselector'].has_key(k) and (not charselect[k]==edecl['charselector'][k]):\n outmess('updatevars: attempt to change the charselector \"%s\" of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (k,ename,edecl['charselector'][k],charselect[k]))\n else: edecl['charselector'][k]=copy.copy(charselect[k])\n if not edecl.has_key('typename'):\n edecl['typename']=typename\n elif typename and (not edecl['typename']==typename):\n outmess('updatevars: attempt to change the typename of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['typename'],typename))\n if not edecl.has_key('attrspec'):\n edecl['attrspec']=copy.copy(attrspec)\n elif attrspec:\n for a in attrspec:\n if a not in edecl['attrspec']:\n edecl['attrspec'].append(a)\n else:\n edecl['typespec']=copy.copy(typespec)\n edecl['kindselector']=copy.copy(kindselect)\n edecl['charselector']=copy.copy(charselect)\n edecl['typename']=typename\n edecl['attrspec']=copy.copy(attrspec)\n if m.group('after'):\n m1=lenarraypattern.match(markouterparen(m.group('after')))\n if m1:\n d1=m1.groupdict()\n for lk in ['len','array','init']:\n if d1[lk+'2'] is not None: d1[lk]=d1[lk+'2']; del d1[lk+'2']\n for k in d1.keys():\n if d1[k] is not None: d1[k]=unmarkouterparen(d1[k])\n else: del d1[k]\n if d1.has_key('len') and d1.has_key('array'):\n if d1['len']=='':\n d1['len']=d1['array']\n del d1['array']\n else:\n d1['array']=d1['array']+','+d1['len']\n del d1['len']\n errmess('updatevars: \"%s %s\" is mapped to \"%s %s(%s)\"\\n'%(typespec,e,typespec,ename,d1['array']))\n if d1.has_key('array'):\n dm = 'dimension(%s)'%d1['array']\n if not edecl.has_key('attrspec') or (not edecl['attrspec']):\n edecl['attrspec']=[dm]\n else:\n edecl['attrspec'].append(dm)\n for dm1 in edecl['attrspec']:\n if dm1[:9]=='dimension' and dm1!=dm:\n del edecl['attrspec'][-1]\n errmess('updatevars:%s: attempt to change %r to %r. Ignoring.\\n' \\\n % (ename,dm1,dm))\n break\n \n if d1.has_key('len'):\n if typespec in ['complex','integer','logical','real']:\n if (not edecl.has_key('kindselector')) or (not edecl['kindselector']):\n edecl['kindselector']={}\n edecl['kindselector']['*']=d1['len']\n elif typespec == 'character':\n if (not edecl.has_key('charselector')) or (not edecl['charselector']): edecl['charselector']={}\n if edecl['charselector'].has_key('len'): del edecl['charselector']['len']\n edecl['charselector']['*']=d1['len']\n if d1.has_key('init'):\n if edecl.has_key('=') and (not edecl['=']==d1['init']):\n outmess('updatevars: attempt to change the init expression of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['='],d1['init']))\n else:\n edecl['=']=d1['init']\n else:\n outmess('updatevars: could not crack entity declaration \"%s\". Ignoring.\\n'%(ename+m.group('after')))\n for k in edecl.keys():\n if not edecl[k]: del edecl[k]\n groupcache[groupcounter]['vars'][ename]=edecl\n if groupcache[groupcounter].has_key('varnames'):\n groupcache[groupcounter]['varnames'].append(ename)\n last_name = ename\n return last_name\n\ndef cracktypespec(typespec,selector):\n kindselect=None\n charselect=None\n typename=None\n if selector:\n if typespec in ['complex','integer','logical','real']:\n kindselect=kindselector.match(selector)\n if not kindselect:\n outmess('cracktypespec: no kindselector pattern found for %s\\n'%(`selector`))\n return\n kindselect=kindselect.groupdict()\n kindselect['*']=kindselect['kind2']\n del kindselect['kind2']\n for k in kindselect.keys():\n if not kindselect[k]: del kindselect[k]\n for k,i in kindselect.items():\n kindselect[k] = rmbadname1(i)\n elif typespec=='character':\n charselect=charselector.match(selector)\n if not charselect:\n outmess('cracktypespec: no charselector pattern found for %s\\n'%(`selector`))\n return\n charselect=charselect.groupdict()\n charselect['*']=charselect['charlen']\n del charselect['charlen']\n if charselect['lenkind']:\n lenkind=lenkindpattern.match(markoutercomma(charselect['lenkind']))\n lenkind=lenkind.groupdict()\n for lk in ['len','kind']:\n if lenkind[lk+'2']:\n lenkind[lk]=lenkind[lk+'2']\n charselect[lk]=lenkind[lk]\n del lenkind[lk+'2']\n del charselect['lenkind']\n for k in charselect.keys():\n if not charselect[k]: del charselect[k]\n for k,i in charselect.items():\n charselect[k] = rmbadname1(i)\n elif typespec=='type':\n typename=re.match(r'\\s*\\(\\s*(?P\\w+)\\s*\\)',selector,re.I)\n if typename: typename=typename.group('name')\n else: outmess('cracktypespec: no typename found in %s\\n'%(`typespec+selector`))\n else:\n outmess('cracktypespec: no selector used for %s\\n'%(`selector`))\n return kindselect,charselect,typename\n######\ndef setattrspec(decl,attr,force=0):\n if not decl: decl={}\n if not attr: return decl\n if not decl.has_key('attrspec'):\n decl['attrspec']=[attr]\n return decl\n if force: decl['attrspec'].append(attr)\n if attr in decl['attrspec']: return decl\n if attr=='static' and 'automatic' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='automatic' and 'static' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='public' and 'private' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='private' and 'public' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n else:\n decl['attrspec'].append(attr)\n return decl\ndef setkindselector(decl,sel,force=0):\n if not decl: decl={}\n if not sel: return decl\n if not decl.has_key('kindselector'):\n decl['kindselector']=sel\n return decl\n for k in sel.keys():\n if force or not decl['kindselector'].has_key(k):\n decl['kindselector'][k]=sel[k]\n return decl\ndef setcharselector(decl,sel,force=0):\n if not decl: decl={}\n if not sel: return decl\n if not decl.has_key('charselector'):\n decl['charselector']=sel\n return decl\n for k in sel.keys():\n if force or not decl['charselector'].has_key(k):\n decl['charselector'][k]=sel[k]\n return decl\ndef getblockname(block,unknown='unknown'):\n if block.has_key('name'): return block['name']\n return unknown\n###### post processing\ndef setmesstext(block):\n global filepositiontext\n try: filepositiontext='In: %s:%s\\n'%(block['from'],block['name'])\n except: pass\n\ndef get_usedict(block):\n usedict = {}\n if block.has_key('parent_block'):\n usedict = get_usedict(block['parent_block'])\n if block.has_key('use'):\n usedict.update(block['use'])\n return usedict\n\ndef get_useparameters(block, param_map=None):\n global f90modulevars\n if param_map is None:\n param_map = {}\n usedict = get_usedict(block)\n if not usedict:\n return param_map\n for usename,mapping in usedict.items():\n usename = string.lower(usename)\n if not f90modulevars.has_key(usename):\n continue\n mvars = f90modulevars[usename]\n params = get_parameters(mvars)\n if not params:\n continue\n # XXX: apply mapping\n if mapping:\n errmess('get_useparameters: mapping for %s not impl.' % (mapping))\n for k,v in params.items():\n if param_map.has_key(k):\n outmess('get_useparameters: overriding parameter %s with'\\\n ' value from module %s' % (`k`,`usename`))\n param_map[k] = v\n return param_map\n\ndef postcrack2(block,tab='',param_map=None):\n global f90modulevars\n if not f90modulevars:\n return block\n if type(block)==types.ListType:\n ret = []\n for g in block:\n g = postcrack2(g,tab=tab+'\\t',param_map=param_map)\n ret.append(g)\n return ret\n setmesstext(block)\n outmess('%sBlock: %s\\n'%(tab,block['name']),0)\n\n if param_map is None:\n param_map = get_useparameters(block)\n\n if param_map is not None and block.has_key('vars'):\n vars = block['vars']\n for n in vars.keys():\n var = vars[n]\n if var.has_key('kindselector'):\n kind = var['kindselector']\n if kind.has_key('kind'):\n val = kind['kind']\n if param_map.has_key(val):\n kind['kind'] = param_map[val]\n new_body = []\n for b in block['body']:\n b = postcrack2(b,tab=tab+'\\t',param_map=param_map)\n new_body.append(b)\n block['body'] = new_body\n\n return block\n\ndef postcrack(block,args=None,tab=''):\n \"\"\"\n TODO:\n function return values\n determine expression types if in argument list\n \"\"\"\n global usermodules,onlyfunctions\n if type(block)==types.ListType:\n gret=[]\n uret=[]\n for g in block:\n setmesstext(g)\n g=postcrack(g,tab=tab+'\\t')\n if g.has_key('name') and string.find(g['name'],'__user__')>=0: # sort user routines to appear first\n uret.append(g)\n else:\n gret.append(g)\n return uret+gret\n setmesstext(block)\n if (not type(block)==types.DictType) and not block.has_key('block'):\n raise 'postcrack: Expected block dictionary instead of ',block\n if block.has_key('name') and not block['name']=='unknown_interface':\n outmess('%sBlock: %s\\n'%(tab,block['name']),0)\n blocktype=block['block']\n block=analyzeargs(block)\n block=analyzecommon(block)\n block['vars']=analyzevars(block)\n block['sortvars']=sortvarnames(block['vars'])\n if block.has_key('args') and block['args']:\n args=block['args']\n block['body']=analyzebody(block,args,tab=tab)\n\n userisdefined=[]\n## fromuser = []\n if block.has_key('use'):\n useblock=block['use']\n for k in useblock.keys():\n if string.find(k,'__user__')>=0:\n userisdefined.append(k)\n## if useblock[k].has_key('map'):\n## for n in useblock[k]['map'].values():\n## if n not in fromuser: fromuser.append(n)\n else: useblock={}\n name=''\n if block.has_key('name'):name=block['name']\n if block.has_key('externals') and block['externals']:# and not userisdefined: # Build a __user__ module\n interfaced=[]\n if block.has_key('interfaced'): interfaced=block['interfaced']\n mvars=copy.copy(block['vars'])\n if name: mname=name+'__user__routines'\n else: mname='unknown__user__routines'\n if mname in userisdefined:\n i=1\n while '%s_%i'%(mname,i) in userisdefined: i=i+1\n mname='%s_%i'%(mname,i)\n interface={'block':'interface','body':[],'vars':{},'name':name+'_user_interface'}\n for e in block['externals']:\n## if e in fromuser:\n## outmess(' Skipping %s that is defined explicitly in another use statement\\n'%(`e`))\n## continue\n if e in interfaced:\n edef=[]\n j=-1\n for b in block['body']:\n j=j+1\n if b['block']=='interface':\n i=-1\n for bb in b['body']:\n i=i+1\n if bb.has_key('name') and bb['name']==e:\n edef=copy.copy(bb)\n del b['body'][i]\n break\n if edef:\n if not b['body']: del block['body'][j]\n del interfaced[interfaced.index(e)]\n break\n interface['body'].append(edef)\n else:\n if mvars.has_key(e) and not isexternal(mvars[e]):\n interface['vars'][e]=mvars[e]\n if interface['vars'] or interface['body']:\n block['interfaced']=interfaced\n mblock={'block':'python module','body':[interface],'vars':{},'name':mname,'interfaced':block['externals']}\n useblock[mname]={}\n usermodules.append(mblock)\n if useblock:\n block['use']=useblock\n return block\n\ndef sortvarnames(vars):\n indep = []\n dep = []\n for v in vars.keys():\n if vars[v].has_key('depend') and vars[v]['depend']:\n dep.append(v)\n #print '%s depends on %s'%(v,vars[v]['depend'])\n else: indep.append(v)\n n = len(dep)\n i = 0\n while dep: #XXX: How to catch dependence cycles correctly?\n v = dep[0]\n fl = 0\n for w in dep[1:]:\n if w in vars[v]['depend']:\n fl = 1\n break\n if fl:\n dep = dep[1:]+[v]\n i = i + 1\n if i>n:\n errmess('sortvarnames: failed to compute dependencies because'\n ' of cyclic dependencies between '\n +string.join(dep,', ')+'\\n')\n indep = indep + dep\n break\n else:\n indep.append(v)\n dep = dep[1:]\n n = len(dep)\n i = 0\n #print indep\n return indep\n\ndef analyzecommon(block):\n if not hascommon(block): return block\n commonvars=[]\n for k in block['common'].keys():\n comvars=[]\n for e in block['common'][k]:\n m=re.match(r'\\A\\s*\\b(?P.*?)\\b\\s*(\\((?P.*?)\\)|)\\s*\\Z',e,re.I)\n if m:\n dims=[]\n if m.group('dims'):\n dims=map(string.strip,string.split(markoutercomma(m.group('dims')),'@,@'))\n n=string.strip(m.group('name'))\n if block['vars'].has_key(n):\n if block['vars'][n].has_key('attrspec'):\n block['vars'][n]['attrspec'].append('dimension(%s)'%(string.join(dims,',')))\n else:\n block['vars'][n]['attrspec']=['dimension(%s)'%(string.join(dims,','))]\n else:\n if dims:\n block['vars'][n]={'attrspec':['dimension(%s)'%(string.join(dims,','))]}\n else: block['vars'][n]={}\n if n not in commonvars: commonvars.append(n)\n else:\n n=e\n errmess('analyzecommon: failed to extract \"[()]\" from \"%s\" in common /%s/.\\n'%(e,k))\n comvars.append(n)\n block['common'][k]=comvars\n if not block.has_key('commonvars'):\n block['commonvars']=commonvars\n else:\n block['commonvars']=block['commonvars']+commonvars\n return block\ndef analyzebody(block,args,tab=''):\n global usermodules,skipfuncs,onlyfuncs,f90modulevars\n setmesstext(block)\n body=[]\n for b in block['body']:\n b['parent_block'] = block\n if b['block'] in ['function','subroutine']:\n if args is not None and b['name'] not in args:\n continue\n else:\n as=b['args']\n if b['name'] in skipfuncs:\n continue\n if onlyfuncs and b['name'] not in onlyfuncs:\n continue\n else: as=args\n b=postcrack(b,as,tab=tab+'\\t')\n if b['block']=='interface' and not b['body']:\n if not b.has_key('f2pyenhancements'):\n continue\n if string.replace(b['block'],' ','')=='pythonmodule':\n usermodules.append(b)\n else:\n if b['block']=='module':\n f90modulevars[b['name']] = b['vars']\n body.append(b)\n return body\ndef buildimplicitrules(block):\n setmesstext(block)\n implicitrules=defaultimplicitrules\n attrrules={}\n if block.has_key('implicit'):\n if block['implicit'] is None:\n implicitrules=None\n if verbose>1:\n outmess('buildimplicitrules: no implicit rules for routine %s.\\n'%`block['name']`)\n else:\n for k in block['implicit'].keys():\n if block['implicit'][k].get('typespec') not in ['static','automatic']:\n implicitrules[k]=block['implicit'][k]\n else:\n attrrules[k]=block['implicit'][k]['typespec']\n return implicitrules,attrrules\n\ndef myeval(e,g=None,l=None):\n r = eval(e,g,l)\n if type(r) in [type(0),type(0.0)]:\n return r\n raise ValueError,'r=%r' % (r)\n\ngetlincoef_re_1 = re.compile(r'\\A\\b\\w+\\b\\Z',re.I)\ndef getlincoef(e,xset): # e = a*x+b ; x in xset\n try:\n c = int(myeval(e,{},{}))\n return 0,c,None\n except: pass\n if getlincoef_re_1.match(e):\n return 1,0,e\n len_e = len(e)\n for x in xset:\n if len(x)>len_e: continue\n re_1 = re.compile(r'(?P.*?)\\b'+x+r'\\b(?P.*)',re.I)\n m = re_1.match(e)\n if m:\n try:\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),0,m1.group('after'))\n m1 = re_1.match(ee)\n b = myeval(ee,{},{})\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),1,m1.group('after'))\n m1 = re_1.match(ee)\n a = myeval(ee,{},{}) - b\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),0.5,m1.group('after'))\n m1 = re_1.match(ee)\n c = myeval(ee,{},{})\n if (a*0.5+b==c):\n return a,b,x\n except: pass\n break \n return None,None,None\n\n_varname_match = re.compile(r'\\A[a-z]\\w*\\Z').match\ndef getarrlen(dl,args,star='*'):\n edl = []\n try: edl.append(myeval(dl[0],{},{}))\n except: edl.append(dl[0])\n try: edl.append(myeval(dl[1],{},{}))\n except: edl.append(dl[1])\n if type(edl[0]) is type(0):\n p1 = 1-edl[0]\n if p1==0: d = str(dl[1])\n elif p1<0: d = '%s-%s'%(dl[1],-p1)\n else: d = '%s+%s'%(dl[1],p1)\n elif type(edl[1]) is type(0):\n p1 = 1+edl[1]\n if p1==0: d='-(%s)' % (dl[0])\n else: d='%s-(%s)' % (p1,dl[0])\n else: d = '%s-(%s)+1'%(dl[1],dl[0])\n try: return `myeval(d,{},{})`,None,None\n except: pass\n d1,d2=getlincoef(dl[0],args),getlincoef(dl[1],args)\n if None not in [d1[0],d2[0]]:\n if (d1[0],d2[0])==(0,0):\n return `d2[1]-d1[1]+1`,None,None\n b = d2[1] - d1[1] + 1\n d1 = (d1[0],0,d1[2])\n d2 = (d2[0],b,d2[2])\n if d1[0]==0 and d2[2] in args:\n if b<0: return '%s * %s - %s'%(d2[0],d2[2],-b),d2[2],'+%s)/(%s)'%(-b,d2[0])\n elif b: return '%s * %s + %s'%(d2[0],d2[2],b),d2[2],'-%s)/(%s)'%(b,d2[0])\n else: return '%s * %s'%(d2[0],d2[2]),d2[2],')/(%s)'%(d2[0])\n if d2[0]==0 and d1[2] in args:\n\n if b<0: return '%s * %s - %s'%(-d1[0],d1[2],-b),d1[2],'+%s)/(%s)'%(-b,-d1[0])\n elif b: return '%s * %s + %s'%(-d1[0],d1[2],b),d1[2],'-%s)/(%s)'%(b,-d1[0])\n else: return '%s * %s'%(-d1[0],d1[2]),d1[2],')/(%s)'%(-d1[0])\n if d1[2]==d2[2] and d1[2] in args:\n a = d2[0] - d1[0]\n if not a: return `b`,None,None\n if b<0: return '%s * %s - %s'%(a,d1[2],-b),d2[2],'+%s)/(%s)'%(-b,a)\n elif b: return '%s * %s + %s'%(a,d1[2],b),d2[2],'-%s)/(%s)'%(b,a)\n else: return '%s * %s'%(a,d1[2]),d2[2],')/(%s)'%(a)\n if d1[0]==d2[0]==1:\n c = str(d1[2])\n if c not in args:\n if _varname_match(c):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c))\n c = '(%s)'%c\n if b==0: d='%s-%s' % (d2[2],c)\n elif b<0: d='%s-%s-%s' % (d2[2],c,-b)\n else: d='%s-%s+%s' % (d2[2],c,b)\n elif d1[0]==0:\n c2 = str(d2[2])\n if c2 not in args:\n if _varname_match(c2):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c2))\n c2 = '(%s)'%c2\n if d2[0]==1: pass\n elif d2[0]==-1: c2='-%s' %c2\n else: c2='%s*%s'%(d2[0],c2)\n\n if b==0: d=c2\n elif b<0: d='%s-%s' % (c2,-b)\n else: d='%s+%s' % (c2,b)\n elif d2[0]==0:\n c1 = str(d1[2])\n if c1 not in args:\n if _varname_match(c1):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c1))\n c1 = '(%s)'%c1\n if d1[0]==1: c1='-%s'%c1\n elif d1[0]==-1: c1='+%s'%c1\n elif d1[0]<0: c1='+%s*%s'%(-d1[0],c1)\n else: c1 = '-%s*%s' % (d1[0],c1)\n\n if b==0: d=c1\n elif b<0: d='%s-%s' % (c1,-b)\n else: d='%s+%s' % (c1,b)\n else:\n c1 = str(d1[2])\n if c1 not in args:\n if _varname_match(c1):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c1))\n c1 = '(%s)'%c1\n if d1[0]==1: c1='-%s'%c1\n elif d1[0]==-1: c1='+%s'%c1\n elif d1[0]<0: c1='+%s*%s'%(-d1[0],c1)\n else: c1 = '-%s*%s' % (d1[0],c1)\n \n c2 = str(d2[2])\n if c2 not in args:\n if _varname_match(c2):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c2))\n c2 = '(%s)'%c2\n if d2[0]==1: pass\n elif d2[0]==-1: c2='-%s' %c2\n else: c2='%s*%s'%(d2[0],c2)\n\n if b==0: d='%s%s' % (c2,c1)\n elif b<0: d='%s%s-%s' % (c2,c1,-b)\n else: d='%s%s+%s' % (c2,c1,b)\n return d,None,None\n\nword_pattern = re.compile(r'\\b[a-z][\\w$]*\\b',re.I)\n\ndef _get_depend_dict(name, vars, deps):\n if vars.has_key(name):\n words = vars[name].get('depend',[])\n\n if vars[name].has_key('=') and not isstring(vars[name]):\n for word in word_pattern.findall(vars[name]['=']):\n if word not in words and vars.has_key(word):\n words.append(word)\n for word in words[:]:\n for w in deps.get(word,[]) \\\n or _get_depend_dict(word, vars, deps):\n if w not in words:\n words.append(w)\n else:\n outmess('_get_depend_dict: no dependence info for %s\\n' % (`name`))\n words = []\n deps[name] = words\n return words\n\ndef _calc_depend_dict(vars):\n names = vars.keys()\n depend_dict = {}\n for n in names:\n _get_depend_dict(n, vars, depend_dict)\n return depend_dict\n\ndef get_sorted_names(vars):\n \"\"\"\n \"\"\"\n depend_dict = _calc_depend_dict(vars)\n names = []\n for name in depend_dict.keys():\n if not depend_dict[name]:\n names.append(name)\n del depend_dict[name]\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n return [name for name in names if vars.has_key(name)]\n\ndef _kind_func(string):\n #XXX: return something sensible.\n if string[0] in \"'\\\"\":\n string = string[1:-1]\n if real16pattern.match(string):\n return 16\n elif real8pattern.match(string):\n return 8\n return 'kind('+string+')'\n\ndef _selected_int_kind_func(r):\n #XXX: This should be processor dependent\n m = 10**r\n if m<=2**8: return 1\n if m<=2**16: return 2\n if m<=2**32: return 4\n if m<=2**64: return 8\n if m<=2**128: return 16\n return -1\n\ndef get_parameters(vars, global_params={}):\n params = copy.copy(global_params)\n g_params = copy.copy(global_params)\n for name,func in [('kind',_kind_func),\n ('selected_int_kind',_selected_int_kind_func),\n ]:\n if not g_params.has_key(name):\n g_params[name] = func\n param_names = []\n for n in get_sorted_names(vars):\n if vars[n].has_key('attrspec') and 'parameter' in vars[n]['attrspec']:\n param_names.append(n)\n kind_re = re.compile(r'\\bkind\\s*\\(\\s*(?P.*)\\s*\\)',re.I)\n selected_int_kind_re = re.compile(r'\\bselected_int_kind\\s*\\(\\s*(?P.*)\\s*\\)',re.I)\n for n in param_names:\n if vars[n].has_key('='):\n v = vars[n]['=']\n if islogical(vars[n]):\n v = v.lower()\n for repl in [\n ('.false.','False'),\n ('.true.','True'),\n #TODO: test .eq., .neq., etc replacements.\n ]:\n v = v.replace(*repl)\n v = kind_re.sub(r'kind(\"\\1\")',v)\n v = selected_int_kind_re.sub(r'selected_int_kind(\\1)',v)\n if isinteger(vars[n]) and not selected_int_kind_re.match(v):\n v = v.split('_')[0]\n if isdouble(vars[n]):\n tt = list(v)\n for m in real16pattern.finditer(v):\n tt[m.start():m.end()] = list(\\\n v[m.start():m.end()].lower().replace('d', 'e'))\n v = string.join(tt,'')\n if iscomplex(vars[n]):\n if v[0]=='(' and v[-1]==')':\n l = markoutercomma(v[1:-1]).split('@,@')\n print n,params\n try:\n params[n] = eval(v,g_params,params)\n except Exception,msg:\n params[n] = v\n #print params\n outmess('get_parameters: got \"%s\" on %s\\n' % (msg,`v`))\n if isstring(vars[n]) and type(params[n]) is type(0):\n params[n] = chr(params[n])\n nl = string.lower(n)\n if nl!=n:\n params[nl] = params[n]\n else:\n print vars[n]\n outmess('get_parameters:parameter %s does not have value?!\\n'%(`n`))\n return params\n\ndef _eval_length(length,params):\n if length in ['(:)','(*)','*']:\n return '(*)'\n return _eval_scalar(length,params)\n\n_is_kind_number = re.compile('\\d+_').match\n\ndef _eval_scalar(value,params):\n if _is_kind_number(value):\n value = value.split('_')[0]\n try:\n value = str(eval(value,{},params))\n except (NameError, SyntaxError):\n return value\n except Exception,msg:\n errmess('\"%s\" in evaluating %r '\\\n '(available names: %s)\\n' \\\n % (msg,value,params.keys()))\n return value\n\ndef analyzevars(block):\n global f90modulevars\n setmesstext(block)\n implicitrules,attrrules=buildimplicitrules(block)\n vars=copy.copy(block['vars'])\n if block['block']=='function' and not vars.has_key(block['name']):\n vars[block['name']]={}\n if block['vars'].has_key(''):\n del vars['']\n if block['vars'][''].has_key('attrspec'):\n gen=block['vars']['']['attrspec']\n for n in vars.keys():\n for k in ['public','private']:\n if k in gen:\n vars[n]=setattrspec(vars[n],k)\n svars=[]\n args = block['args']\n for a in args:\n try:\n vars[a]\n svars.append(a)\n except KeyError:\n pass\n for n in vars.keys():\n if n not in args: svars.append(n)\n\n params = get_parameters(vars, get_useparameters(block))\n\n dep_matches = {}\n name_match = re.compile(r'\\w[\\w\\d_$]*').match\n for v in vars.keys():\n m = name_match(v)\n if m:\n n = v[m.start():m.end()]\n try:\n dep_matches[n]\n except KeyError:\n dep_matches[n] = re.compile(r'.*\\b%s\\b'%(v),re.I).match\n for n in svars:\n if n[0] in attrrules.keys():\n vars[n]=setattrspec(vars[n],attrrules[n[0]])\n if not vars[n].has_key('typespec'):\n if not(vars[n].has_key('attrspec') and 'external' in vars[n]['attrspec']):\n if implicitrules:\n ln0 = string.lower(n[0])\n for k in implicitrules[ln0].keys():\n if k=='typespec' and implicitrules[ln0][k]=='undefined':\n continue\n if not vars[n].has_key(k):\n vars[n][k]=implicitrules[ln0][k]\n elif k=='attrspec':\n for l in implicitrules[ln0][k]:\n vars[n]=setattrspec(vars[n],l)\n elif n in block['args']:\n outmess('analyzevars: typespec of variable %s is not defined in routine %s.\\n'%(`n`,block['name']))\n\n if vars[n].has_key('charselector'):\n if vars[n]['charselector'].has_key('len'):\n l = vars[n]['charselector']['len']\n try:\n l = str(eval(l,{},params))\n except:\n pass\n vars[n]['charselector']['len'] = l\n\n if vars[n].has_key('kindselector'):\n if vars[n]['kindselector'].has_key('kind'):\n l = vars[n]['kindselector']['kind']\n try:\n l = str(eval(l,{},params))\n except:\n pass\n vars[n]['kindselector']['kind'] = l\n\n savelindims = {}\n if vars[n].has_key('attrspec'):\n attr=vars[n]['attrspec']\n attr.reverse()\n vars[n]['attrspec']=[]\n dim,intent,depend,check,note=None,None,None,None,None\n for a in attr:\n if a[:9]=='dimension': dim=(string.strip(a[9:]))[1:-1]\n elif a[:6]=='intent': intent=(string.strip(a[6:]))[1:-1]\n elif a[:6]=='depend': depend=(string.strip(a[6:]))[1:-1]\n elif a[:5]=='check': check=(string.strip(a[5:]))[1:-1]\n elif a[:4]=='note': note=(string.strip(a[4:]))[1:-1]\n else: vars[n]=setattrspec(vars[n],a)\n if intent:\n if not vars[n].has_key('intent'): vars[n]['intent']=[]\n for c in map(string.strip,string.split(markoutercomma(intent),'@,@')):\n if not c in vars[n]['intent']:\n vars[n]['intent'].append(c)\n intent=None\n if note:\n note=string.replace(note,'\\\\n\\\\n','\\n\\n')\n note=string.replace(note,'\\\\n ','\\n')\n if not vars[n].has_key('note'): vars[n]['note']=[note]\n else: vars[n]['note'].append(note)\n note=None\n if depend is not None:\n if not vars[n].has_key('depend'): vars[n]['depend']=[]\n for c in rmbadname(map(string.strip,string.split(markoutercomma(depend),'@,@'))):\n if c not in vars[n]['depend']:\n vars[n]['depend'].append(c)\n depend=None\n if check is not None:\n if not vars[n].has_key('check'): vars[n]['check']=[]\n for c in map(string.strip,string.split(markoutercomma(check),'@,@')):\n if not c in vars[n]['check']:\n vars[n]['check'].append(c)\n check=None\n if dim and not vars[n].has_key('dimension'):\n vars[n]['dimension']=[]\n for d in rmbadname(map(string.strip,string.split(markoutercomma(dim),'@,@'))):\n star = '*'\n if d==':': star=':'\n if params.has_key(d):\n d = str(params[d])\n for p in params.keys():\n m = re.match(r'(?P.*?)\\b'+p+r'\\b(?P.*)',d,re.I)\n if m:\n #outmess('analyzevars:replacing parameter %s in %s (dimension of %s) with %s\\n'%(`p`,`d`,`n`,`params[p]`))\n d = m.group('before')+str(params[p])+m.group('after')\n if d==star:\n dl = [star]\n else:\n dl=string.split(markoutercomma(d,':'),'@:@')\n if len(dl)==2 and '*' in dl: # e.g. dimension(5:*)\n dl = ['*']\n d = '*'\n if len(dl)==1 and not dl[0]==star: dl = ['1',dl[0]]\n if len(dl)==2:\n d,v,di = getarrlen(dl,block['vars'].keys())\n if d[:4] == '1 * ': d = d[4:]\n if di and di[-4:] == '/(1)': di = di[:-4]\n if v: savelindims[d] = v,di\n vars[n]['dimension'].append(d)\n if vars[n].has_key('dimension'):\n if isintent_c(vars[n]):\n shape_macro = 'shape'\n else:\n shape_macro = 'shape'#'fshape'\n if isstringarray(vars[n]):\n if vars[n].has_key('charselector'):\n d = vars[n]['charselector']\n if d.has_key('*'):\n d = d['*']\n errmess('analyzevars: character array \"character*%s %s(%s)\" is considered as \"character %s(%s)\"; \"intent(c)\" is forced.\\n'\\\n %(d,n,\n ','.join(vars[n]['dimension']),\n n,','.join(vars[n]['dimension']+[d])))\n vars[n]['dimension'].append(d)\n del vars[n]['charselector']\n if not vars[n].has_key('intent'):\n vars[n]['intent'] = []\n if 'c' not in vars[n]['intent']:\n vars[n]['intent'].append('c')\n else:\n errmess(\"analyzevars: charselector=%r unhandled.\" % (d))\n if not vars[n].has_key('check') and block.has_key('args') and n in block['args']:\n flag=not vars[n].has_key('depend')\n if flag: vars[n]['depend']=[]\n vars[n]['check']=[]\n if vars[n].has_key('dimension'):\n #/----< no check\n #vars[n]['check'].append('rank(%s)==%s'%(n,len(vars[n]['dimension'])))\n i=-1; ni=len(vars[n]['dimension'])\n for d in vars[n]['dimension']:\n ddeps=[] # dependecies of 'd'\n ad=''\n pd=''\n #origd = d\n if not vars.has_key(d):\n if savelindims.has_key(d):\n pd,ad='(',savelindims[d][1]\n d = savelindims[d][0]\n else:\n for r in block['args']:\n #for r in block['vars'].keys():\n if not vars.has_key(r): continue\n if re.match(r'.*?\\b'+r+r'\\b',d,re.I):\n ddeps.append(r)\n if vars.has_key(d):\n if vars[d].has_key('attrspec'):\n for aa in vars[d]['attrspec']:\n if aa[:6]=='depend':\n ddeps=ddeps+string.split((string.strip(aa[6:]))[1:-1],',')\n if vars[d].has_key('depend'):\n ddeps=ddeps+vars[d]['depend']\n i=i+1\n if vars.has_key(d) and (not vars[d].has_key('depend')) \\\n and (not vars[d].has_key('=')) and (d not in vars[n]['depend']) \\\n and l_or(isintent_in,isintent_inout,isintent_inplace)(vars[n]):\n vars[d]['depend']=[n]\n if ni>1:\n vars[d]['=']='%s%s(%s,%s)%s'% (pd,shape_macro,n,i,ad)\n else:\n vars[d]['=']='%slen(%s)%s'% (pd,n,ad)\n # /---< no check\n if 1 and not vars[d].has_key('check'):\n if ni>1:\n vars[d]['check']=['%s%s(%s,%i)%s==%s'\\\n %(pd,shape_macro,n,i,ad,d)]\n else:\n vars[d]['check']=['%slen(%s)%s>=%s'%(pd,n,ad,d)]\n if not vars[d].has_key('attrspec'): vars[d]['attrspec']=['optional']\n if ('optional' not in vars[d]['attrspec']) and\\\n ('required' not in vars[d]['attrspec']):\n vars[d]['attrspec'].append('optional')\n elif d not in ['*',':']:\n #/----< no check \n #if ni>1: vars[n]['check'].append('shape(%s,%i)==%s'%(n,i,d))\n #else: vars[n]['check'].append('len(%s)>=%s'%(n,d))\n if flag: \n if vars.has_key(d):\n if n not in ddeps:\n vars[n]['depend'].append(d)\n else:\n vars[n]['depend'] = vars[n]['depend'] + ddeps\n elif isstring(vars[n]):\n length='1'\n if vars[n].has_key('charselector'):\n if vars[n]['charselector'].has_key('*'):\n length = _eval_length(vars[n]['charselector']['*'],\n params)\n vars[n]['charselector']['*']=length\n elif vars[n]['charselector'].has_key('len'):\n length = _eval_length(vars[n]['charselector']['len'],\n params)\n del vars[n]['charselector']['len']\n vars[n]['charselector']['*']=length\n\n if not vars[n]['check']: del vars[n]['check']\n if flag and not vars[n]['depend']: del vars[n]['depend']\n if vars[n].has_key('='):\n if not vars[n].has_key('attrspec'): vars[n]['attrspec']=[]\n if ('optional' not in vars[n]['attrspec']) and \\\n ('required' not in vars[n]['attrspec']):\n vars[n]['attrspec'].append('optional')\n if not vars[n].has_key('depend'):\n vars[n]['depend']=[]\n for v,m in dep_matches.items():\n if m(vars[n]['=']): vars[n]['depend'].append(v)\n if not vars[n]['depend']: del vars[n]['depend']\n if isscalar(vars[n]):\n vars[n]['='] = _eval_scalar(vars[n]['='],params)\n\n for n in vars.keys():\n if n==block['name']: # n is block name\n if vars[n].has_key('note'):\n block['note']=vars[n]['note']\n if block['block']=='function':\n if block.has_key('result') and vars.has_key(block['result']):\n vars[n]=appenddecl(vars[n],vars[block['result']])\n if block.has_key('prefix'):\n pr=block['prefix']; ispure=0; isrec=1\n pr1=string.replace(pr,'pure','')\n ispure=(not pr==pr1)\n pr=string.replace(pr1,'recursive','')\n isrec=(not pr==pr1)\n m=typespattern[0].match(pr)\n if m:\n typespec,selector,attr,edecl=cracktypespec0(m.group('this'),m.group('after'))\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n vars[n]['typespec']=typespec\n if kindselect:\n if kindselect.has_key('kind'):\n try:\n kindselect['kind'] = eval(kindselect['kind'],{},params)\n except:\n pass\n vars[n]['kindselector']=kindselect\n if charselect: vars[n]['charselector']=charselect\n if typename: vars[n]['typename']=typename\n if ispure: vars[n]=setattrspec(vars[n],'pure')\n if isrec: vars[n]=setattrspec(vars[n],'recursive')\n else:\n outmess('analyzevars: prefix (%s) were not used\\n'%`block['prefix']`)\n if not block['block'] in ['module','pythonmodule','python module','block data']:\n if block.has_key('commonvars'):\n neededvars=copy.copy(block['args']+block['commonvars'])\n else:\n neededvars=copy.copy(block['args'])\n for n in vars.keys():\n if l_or(isintent_callback,isintent_aux)(vars[n]):\n neededvars.append(n)\n if block.has_key('entry'):\n neededvars.extend(block['entry'].keys())\n for k in block['entry'].keys():\n for n in block['entry'][k]:\n if n not in neededvars:\n neededvars.append(n)\n if block['block']=='function':\n if block.has_key('result'):\n neededvars.append(block['result'])\n else:\n neededvars.append(block['name'])\n if block['block'] in ['subroutine','function']:\n name = block['name']\n if vars.has_key(name) and vars[name].has_key('intent'):\n block['intent'] = vars[name]['intent']\n if block['block'] == 'type':\n neededvars.extend(vars.keys())\n for n in vars.keys():\n if n not in neededvars:\n del vars[n]\n return vars\nanalyzeargs_re_1 = re.compile(r'\\A[a-z]+[\\w$]*\\Z',re.I)\ndef analyzeargs(block):\n setmesstext(block)\n implicitrules,attrrules=buildimplicitrules(block)\n if not block.has_key('args'): block['args']=[]\n args=[]\n re_1 = analyzeargs_re_1\n for a in block['args']:\n if not re_1.match(a): # `a` is an expression\n at=determineexprtype(a,block['vars'],implicitrules)\n na='e_'\n for c in a:\n if c not in string.lowercase+string.digits: c='_'\n na=na+c\n if na[-1]=='_': na=na+'e'\n else: na=na+'_e'\n a=na\n while block['vars'].has_key(a) or a in block['args']: a=a+'r'\n block['vars'][a]=at \n args.append(a)\n if not block['vars'].has_key(a):\n block['vars'][a]={}\n if block.has_key('externals') and a in block['externals']+block['interfaced']:\n block['vars'][a]=setattrspec(block['vars'][a],'external')\n block['args']=args\n\n if block.has_key('entry'):\n for k,args1 in block['entry'].items():\n for a in args1:\n if not block['vars'].has_key(a):\n block['vars'][a]={}\n\n for b in block['body']:\n if b['name'] in args:\n if not block.has_key('externals'): block['externals']=[]\n if b['name'] not in block['externals']:\n block['externals'].append(b['name'])\n if block.has_key('result') and not block['vars'].has_key(block['result']):\n block['vars'][block['result']]={}\n return block\ndetermineexprtype_re_1 = re.compile(r'\\A\\(.+?[,].+?\\)\\Z',re.I)\ndetermineexprtype_re_2 = re.compile(r'\\A[+-]?\\d+(_(P[\\w]+)|)\\Z',re.I)\ndetermineexprtype_re_3 = re.compile(r'\\A[+-]?[\\d.]+[\\d+-de.]*(_(P[\\w]+)|)\\Z',re.I)\ndetermineexprtype_re_4 = re.compile(r'\\A\\(.*\\)\\Z',re.I)\ndetermineexprtype_re_5 = re.compile(r'\\A(?P\\w+)\\s*\\(.*?\\)\\s*\\Z',re.I)\ndef _ensure_exprdict(r):\n if type(r) is type(0):\n return {'typespec':'integer'}\n if type(r) is type(0.0):\n return {'typespec':'real'}\n if type(r) is type(0j):\n return {'typespec':'complex'}\n assert type(r) is type({}),`r`\n return r\n\ndef determineexprtype(expr,vars,rules={}):\n if vars.has_key(expr):\n return _ensure_exprdict(vars[expr])\n expr=string.strip(expr)\n if determineexprtype_re_1.match(expr):\n return {'typespec':'complex'}\n m=determineexprtype_re_2.match(expr)\n if m:\n if m.groupdict().has_key('name') and m.group('name'):\n outmess('determineexprtype: selected kind types not supported (%s)\\n'%`expr`)\n return {'typespec':'integer'}\n m = determineexprtype_re_3.match(expr)\n if m:\n if m.groupdict().has_key('name') and m.group('name'):\n outmess('determineexprtype: selected kind types not supported (%s)\\n'%`expr`)\n return {'typespec':'real'}\n for op in ['+','-','*','/']:\n for e in map(string.strip,string.split(markoutercomma(expr,comma=op),'@'+op+'@')):\n if vars.has_key(e):\n return _ensure_exprdict(vars[e])\n t={}\n if determineexprtype_re_4.match(expr): # in parenthesis\n t=determineexprtype(expr[1:-1],vars,rules)\n else:\n m = determineexprtype_re_5.match(expr)\n if m:\n rn=m.group('name')\n t=determineexprtype(m.group('name'),vars,rules)\n if t and t.has_key('attrspec'): del t['attrspec']\n if not t:\n if rules.has_key(rn[0]):\n return _ensure_exprdict(rules[rn[0]])\n if expr[0] in '\\'\"':\n return {'typespec':'character','charselector':{'*':'*'}}\n if not t:\n outmess('determineexprtype: could not determine expressions (%s) type.\\n'%(`expr`))\n return t\n######\ndef crack2fortrangen(block,tab='\\n'):\n setmesstext(block)\n ret=''\n if type(block) is type([]):\n for g in block:\n ret=ret+crack2fortrangen(g,tab)\n return ret\n prefix=''\n name=''\n args=''\n blocktype=block['block']\n if blocktype=='program': return ''\n al=[]\n if block.has_key('name'): name=block['name']\n if block.has_key('args'):\n vars = block['vars']\n al = [a for a in block['args'] if not isintent_callback(vars[a])]\n if block['block']=='function' or al:\n args='(%s)'%string.join(al,',')\n f2pyenhancements = ''\n if block.has_key('f2pyenhancements'):\n for k in block['f2pyenhancements'].keys():\n f2pyenhancements = '%s%s%s %s'%(f2pyenhancements,tab+tabchar,k,block['f2pyenhancements'][k])\n intent_lst = block.get('intent',[])[:]\n if blocktype=='function' and 'callback' in intent_lst:\n intent_lst.remove('callback')\n if intent_lst:\n f2pyenhancements = '%s%sintent(%s) %s'%\\\n (f2pyenhancements,tab+tabchar,\n string.join(intent_lst,','),name)\n use=''\n if block.has_key('use'):\n use=use2fortran(block['use'],tab+tabchar)\n common=''\n if block.has_key('common'):\n common=common2fortran(block['common'],tab+tabchar)\n if name=='unknown_interface': name=''\n result=''\n if block.has_key('result'):\n result=' result (%s)'%block['result']\n if block['result'] not in al:\n al.append(block['result'])\n #if block.has_key('prefix'): prefix=block['prefix']+' '\n body=crack2fortrangen(block['body'],tab+tabchar)\n vars=vars2fortran(block,block['vars'],al,tab+tabchar)\n mess=''\n if block.has_key('from'):\n mess='! in %s'%block['from']\n if block.has_key('entry'):\n entry_stmts = ''\n for k,i in block['entry'].items():\n entry_stmts = '%s%sentry %s(%s)' \\\n % (entry_stmts,tab+tabchar,k,string.join(i,','))\n body = body + entry_stmts\n if blocktype=='block data' and name=='_BLOCK_DATA_':\n name = ''\n ret='%s%s%s %s%s%s %s%s%s%s%s%s%send %s %s'%(tab,prefix,blocktype,name,args,result,mess,f2pyenhancements,use,vars,common,body,tab,blocktype,name)\n return ret\ndef common2fortran(common,tab=''):\n ret=''\n for k in common.keys():\n if k=='_BLNK_':\n ret='%s%scommon %s'%(ret,tab,string.join(common[k],','))\n else:\n ret='%s%scommon /%s/ %s'%(ret,tab,k,string.join(common[k],','))\n return ret\ndef use2fortran(use,tab=''):\n ret=''\n for m in use.keys():\n ret='%s%suse %s,'%(ret,tab,m)\n if use[m]=={}:\n if ret and ret[-1]==',': ret=ret[:-1]\n continue\n if use[m].has_key('only') and use[m]['only']:\n ret='%s,only:'%(ret)\n if use[m].has_key('map') and use[m]['map']:\n c=' '\n for k in use[m]['map'].keys():\n if k==use[m]['map'][k]:\n ret='%s%s%s'%(ret,c,k); c=','\n else:\n ret='%s%s%s=>%s'%(ret,c,k,use[m]['map'][k]); c=','\n if ret and ret[-1]==',': ret=ret[:-1]\n return ret\ndef true_intent_list(var):\n lst = var['intent']\n ret = []\n for intent in lst:\n try:\n exec('c = isintent_%s(var)' % intent)\n except NameError:\n c = 0\n if c:\n ret.append(intent)\n return ret\ndef vars2fortran(block,vars,args,tab=''):\n \"\"\"\n TODO:\n public sub\n ...\n \"\"\"\n setmesstext(block)\n ret=''\n nout=[]\n for a in args:\n if block['vars'].has_key(a): nout.append(a)\n if block.has_key('commonvars'):\n for a in block['commonvars']:\n if vars.has_key(a):\n if a not in nout: nout.append(a)\n else: errmess('vars2fortran: Confused?!: \"%s\" is not defined in vars.\\n'%a)\n if block.has_key('varnames'):\n nout.extend(block['varnames'])\n for a in vars.keys():\n if a not in nout: nout.append(a)\n for a in nout:\n if vars[a].has_key('depend'):\n for d in vars[a]['depend']:\n if vars.has_key(d) and vars[d].has_key('depend') and a in vars[d]['depend']:\n errmess('vars2fortran: Warning: cross-dependence between variables \"%s\" and \"%s\"\\n'%(a,d))\n if block.has_key('externals') and a in block['externals']:\n if isintent_callback(vars[a]):\n ret='%s%sintent(callback) %s'%(ret,tab,a)\n ret='%s%sexternal %s'%(ret,tab,a)\n if isoptional(vars[a]):\n ret='%s%soptional %s'%(ret,tab,a)\n if vars.has_key(a) and not vars[a].has_key('typespec'):\n continue\n cont=1\n for b in block['body']:\n if a==b['name'] and b['block']=='function': cont=0;break\n if cont: continue\n if not vars.has_key(a):\n show(vars)\n outmess('vars2fortran: No definition for argument \"%s\".\\n'%a)\n continue\n if a==block['name'] and not block['block']=='function':\n continue\n if not vars[a].has_key('typespec'):\n if vars[a].has_key('attrspec') and 'external' in vars[a]['attrspec']:\n if a in args:\n ret='%s%sexternal %s'%(ret,tab,a)\n continue\n show(vars[a])\n outmess('vars2fortran: No typespec for argument \"%s\".\\n'%a)\n continue\n vardef=vars[a]['typespec']\n if vardef=='type' and vars[a].has_key('typename'):\n vardef='%s(%s)'%(vardef,vars[a]['typename'])\n selector={}\n if vars[a].has_key('kindselector'): selector=vars[a]['kindselector']\n elif vars[a].has_key('charselector'): selector=vars[a]['charselector']\n if selector.has_key('*'):\n if selector['*'] in ['*',':']:\n vardef='%s*(%s)'%(vardef,selector['*'])\n else:\n vardef='%s*%s'%(vardef,selector['*'])\n else:\n if selector.has_key('len'):\n vardef='%s(len=%s'%(vardef,selector['len'])\n if selector.has_key('kind'):\n vardef='%s,kind=%s)'%(vardef,selector['kind'])\n else:\n vardef='%s)'%(vardef)\n elif selector.has_key('kind'):\n vardef='%s(kind=%s)'%(vardef,selector['kind'])\n c=' '\n if vars[a].has_key('attrspec'):\n attr=[]\n for l in vars[a]['attrspec']:\n if l not in ['external']:\n attr.append(l)\n if attr:\n vardef='%s %s'%(vardef,string.join(attr,','))\n c=','\n if vars[a].has_key('dimension'):\n# if not isintent_c(vars[a]):\n# vars[a]['dimension'].reverse()\n vardef='%s%sdimension(%s)'%(vardef,c,string.join(vars[a]['dimension'],','))\n c=','\n if vars[a].has_key('intent'):\n lst = true_intent_list(vars[a])\n if lst:\n vardef='%s%sintent(%s)'%(vardef,c,string.join(lst,','))\n c=','\n if vars[a].has_key('check'):\n vardef='%s%scheck(%s)'%(vardef,c,string.join(vars[a]['check'],','))\n c=','\n if vars[a].has_key('depend'):\n vardef='%s%sdepend(%s)'%(vardef,c,string.join(vars[a]['depend'],','))\n c=','\n if vars[a].has_key('='):\n v = vars[a]['=']\n if vars[a]['typespec'] in ['complex','double complex']:\n try:\n v = eval(v)\n v = '(%s,%s)' % (v.real,v.imag)\n except:\n pass\n vardef='%s :: %s=%s'%(vardef,a,v)\n else:\n vardef='%s :: %s'%(vardef,a)\n ret='%s%s%s'%(ret,tab,vardef)\n return ret\n######\n\ndef crackfortran(files):\n global usermodules\n outmess('Reading fortran codes...\\n',0)\n readfortrancode(files,crackline)\n outmess('Post-processing...\\n',0)\n usermodules=[]\n postlist=postcrack(grouplist[0])\n outmess('Post-processing (stage 2)...\\n',0)\n postlist=postcrack2(postlist)\n return usermodules+postlist\ndef crack2fortran(block):\n global f2py_version\n pyf=crack2fortrangen(block)+'\\n'\n header=\"\"\"! -*- f90 -*-\n! Note: the context of this file is case sensitive.\n\"\"\"\n footer=\"\"\"\n! This file was auto-generated with f2py (version:%s).\n! See http://cens.ioc.ee/projects/f2py2e/\n\"\"\"%(f2py_version)\n return header+pyf+footer\n\nif __name__ == \"__main__\":\n files=[]\n funcs=[]\n f=1;f2=0;f3=0\n showblocklist=0\n for l in sys.argv[1:]:\n if l=='': pass\n elif l[0]==':':\n f=0\n elif l=='-quiet':\n quiet=1\n verbose=0\n elif l=='-verbose':\n verbose=2\n quiet=0\n elif l=='-fix':\n if strictf77:\n outmess('Use option -f90 before -fix if Fortran 90 code is in fix form.\\n',0)\n skipemptyends=1\n sourcecodeform='fix'\n elif l=='-skipemptyends':\n skipemptyends=1\n elif l=='--ignore-contains':\n ignorecontains=1\n elif l=='-f77':\n strictf77=1\n sourcecodeform='fix'\n elif l=='-f90':\n strictf77=0\n sourcecodeform='free'\n skipemptyends=1\n elif l=='-h':\n f2=1\n elif l=='-show':\n showblocklist=1\n elif l=='-m':\n f3=1\n elif l[0]=='-':\n errmess('Unknown option %s\\n'%`l`)\n elif f2:\n f2=0\n pyffilename=l\n elif f3:\n f3=0\n f77modulename=l\n elif f:\n try:\n open(l).close()\n files.append(l)\n except IOError,detail:\n errmess('IOError: %s\\n'%str(detail))\n else:\n funcs.append(l)\n if not strictf77 and f77modulename and not skipemptyends:\n outmess(\"\"\"\\\n Warning: You have specifyied module name for non Fortran 77 code\n that should not need one (expect if you are scanning F90 code\n for non module blocks but then you should use flag -skipemptyends\n and also be sure that the files do not contain programs without program statement).\n\"\"\",0)\n\n postlist=crackfortran(files,funcs)\n if pyffilename:\n outmess('Writing fortran code to file %s\\n'%`pyffilename`,0)\n pyf=crack2fortran(postlist)\n f=open(pyffilename,'w')\n f.write(pyf)\n f.close()\n if showblocklist:\n show(postlist)\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncrackfortran --- read fortran (77,90) code and extract declaration information.\n Usage is explained in the comment block below.\n\nCopyright 1999-2004 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/09/27 07:13:49 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.177 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\n\"\"\"\n Usage of crackfortran:\n ======================\n Command line keys: -quiet,-verbose,-fix,-f77,-f90,-show,-h \n -m ,--ignore-contains\n Functions: crackfortran, crack2fortran\n The following Fortran statements/constructions are supported\n (or will be if needed):\n block data,byte,call,character,common,complex,contains,data,\n dimension,double complex,double precision,end,external,function,\n implicit,integer,intent,interface,intrinsic,\n logical,module,optional,parameter,private,public,\n program,real,(sequence?),subroutine,type,use,virtual,\n include,pythonmodule\n Note: 'virtual' is mapped to 'dimension'.\n Note: 'implicit integer (z) static (z)' is 'implicit static (z)' (this is minor bug).\n Note: code after 'contains' will be ignored until its scope ends.\n Note: 'common' statement is extended: dimensions are moved to variable definitions\n Note: f2py directive: f2py is read as \n Note: pythonmodule is introduced to represent Python module\n\n Usage:\n `postlist=crackfortran(files,funcs)`\n `postlist` contains declaration information read from the list of files `files`.\n `crack2fortran(postlist)` returns a fortran code to be saved to pyf-file\n\n `postlist` has the following structure:\n *** it is a list of dictionaries containing `blocks':\n B = {'block','body','vars','parent_block'[,'name','prefix','args','result',\n 'implicit','externals','interfaced','common','sortvars',\n 'commonvars','note']}\n B['block'] = 'interface' | 'function' | 'subroutine' | 'module' |\n 'program' | 'block data' | 'type' | 'pythonmodule'\n B['body'] --- list containing `subblocks' with the same structure as `blocks'\n B['parent_block'] --- dictionary of a parent block:\n C['body'][]['parent_block'] is C\n B['vars'] --- dictionary of variable definitions\n B['sortvars'] --- dictionary of variable definitions sorted by dependence (independent first)\n B['name'] --- name of the block (not if B['block']=='interface')\n B['prefix'] --- prefix string (only if B['block']=='function')\n B['args'] --- list of argument names if B['block']== 'function' | 'subroutine'\n B['result'] --- name of the return value (only if B['block']=='function')\n B['implicit'] --- dictionary {'a':,'b':...} | None\n B['externals'] --- list of variables being external\n B['interfaced'] --- list of variables being external and defined\n B['common'] --- dictionary of common blocks (list of objects)\n B['commonvars'] --- list of variables used in common blocks (dimensions are moved to variable definitions)\n B['from'] --- string showing the 'parents' of the current block\n B['use'] --- dictionary of modules used in current block:\n {:{['only':<0|1>],['map':{:,...}]}}\n B['note'] --- list of LaTeX comments on the block\n B['f2pyenhancements'] --- optional dictionary\n {'threadsafe':'','fortranname':,\n 'callstatement':|,\n 'callprotoargument':,\n 'usercode':|,\n 'pymethoddef:'\n }\n B['entry'] --- dictionary {entryname:argslist,..}\n B['varnames'] --- list of variable names given in the order of reading the\n Fortran code, useful for derived types.\n *** Variable definition is a dictionary\n D = B['vars'][] =\n {'typespec'[,'attrspec','kindselector','charselector','=','typename']}\n D['typespec'] = 'byte' | 'character' | 'complex' | 'double complex' |\n 'double precision' | 'integer' | 'logical' | 'real' | 'type'\n D['attrspec'] --- list of attributes (e.g. 'dimension()',\n 'external','intent(in|out|inout|hide|c|callback|cache)',\n 'optional','required', etc)\n K = D['kindselector'] = {['*','kind']} (only if D['typespec'] =\n 'complex' | 'integer' | 'logical' | 'real' )\n C = D['charselector'] = {['*','len','kind']}\n (only if D['typespec']=='character')\n D['='] --- initialization expression string\n D['typename'] --- name of the type if D['typespec']=='type'\n D['dimension'] --- list of dimension bounds\n D['intent'] --- list of intent specifications\n D['depend'] --- list of variable names on which current variable depends on\n D['check'] --- list of C-expressions; if C-expr returns zero, exception is raised\n D['note'] --- list of LaTeX comments on the variable\n *** Meaning of kind/char selectors (few examples):\n D['typespec>']*K['*']\n D['typespec'](kind=K['kind'])\n character*C['*']\n character(len=C['len'],kind=C['kind'])\n (see also fortran type declaration statement formats below)\n\n Fortran 90 type declaration statement format (F77 is subset of F90)\n====================================================================\n (Main source: IBM XL Fortran 5.1 Language Reference Manual)\n type declaration = [[]::] \n = byte |\n character[] |\n complex[] |\n double complex |\n double precision |\n integer[] |\n logical[] |\n real[] |\n type()\n = * |\n ([len=][,[kind=]]) |\n (kind=[,len=])\n = * |\n ([kind=])\n = comma separated list of attributes.\n Only the following attributes are used in\n building up the interface:\n external\n (parameter --- affects '=' key)\n optional\n intent\n Other attributes are ignored.\n = in | out | inout\n = comma separated list of dimension bounds.\n = [[*][()] | [()]*]\n [// | =] [,]\n\n In addition, the following attributes are used: check,depend,note\n\n TODO:\n * Apply 'parameter' attribute (e.g. 'integer parameter :: i=2' 'real x(i)'\n -> 'real x(2)')\n The above may be solved by creating appropriate preprocessor program, for example.\n\"\"\"\n#\nimport sys,string,fileinput,re,pprint,os,copy\nfrom auxfuncs import *\n\n# Global flags:\nstrictf77=1 # Ignore `!' comments unless line[0]=='!'\nsourcecodeform='fix' # 'fix','free'\nquiet=0 # Be verbose if 0 (Obsolete: not used any more)\nverbose=1 # Be quiet if 0, extra verbose if > 1.\ntabchar=4*' '\npyffilename=''\nf77modulename=''\nskipemptyends=0 # for old F77 programs without 'program' statement\nignorecontains=1\ndolowercase=1\ndebug=[]\n## do_analyze = 1\n\n###### global variables\n\n## use reload(crackfortran) to reset these variables\n\ngroupcounter=0\ngrouplist={groupcounter:[]}\nneededmodule=-1\nexpectbegin=1\nskipblocksuntil=-1\nusermodules=[]\nf90modulevars={}\ngotnextfile=1\nfilepositiontext=''\ncurrentfilename=''\nskipfunctions=[]\nskipfuncs=[]\nonlyfuncs=[]\ninclude_paths=[]\nprevious_context = None\n\n###### Some helper functions\ndef show(o,f=0):pprint.pprint(o)\nerrmess=sys.stderr.write\ndef outmess(line,flag=1):\n global filepositiontext\n if not verbose: return\n if not quiet:\n if flag:sys.stdout.write(filepositiontext)\n sys.stdout.write(line)\nre._MAXCACHE=50\ndefaultimplicitrules={}\nfor c in \"abcdefghopqrstuvwxyz$_\": defaultimplicitrules[c]={'typespec':'real'}\nfor c in \"ijklmn\": defaultimplicitrules[c]={'typespec':'integer'}\ndel c\nbadnames={}\ninvbadnames={}\nfor n in ['int','double','float','char','short','long','void','case','while',\n 'return','signed','unsigned','if','for','typedef','sizeof','union',\n 'struct','static','register','new','break','do','goto','switch',\n 'continue','else','inline','extern','delete','const','auto',\n 'len','rank','shape','index','slen','size','_i',\n 'flen','fshape',\n 'string','complex_double','float_double','stdin','stderr','stdout',\n 'type','default']:\n badnames[n]=n+'_bn'\n invbadnames[n+'_bn']=n\ndef rmbadname1(name):\n if badnames.has_key(name):\n errmess('rmbadname1: Replacing \"%s\" with \"%s\".\\n'%(name,badnames[name]))\n return badnames[name]\n return name\ndef rmbadname(names): return map(rmbadname1,names)\n\ndef undo_rmbadname1(name):\n if invbadnames.has_key(name):\n errmess('undo_rmbadname1: Replacing \"%s\" with \"%s\".\\n'\\\n %(name,invbadnames[name]))\n return invbadnames[name]\n return name\ndef undo_rmbadname(names): return map(undo_rmbadname1,names)\n\ndef getextension(name):\n i=string.rfind(name,'.')\n if i==-1: return ''\n if '\\\\' in name[i:]: return ''\n if '/' in name[i:]: return ''\n return name[i+1:]\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\n\n####### Read fortran (77,90) code\ndef readfortrancode(ffile,dowithline=show,istop=1):\n \"\"\"\n Read fortran codes from files and\n 1) Get rid of comments, line continuations, and empty lines; lower cases.\n 2) Call dowithline(line) on every line.\n 3) Recursively call itself when statement \\\"include ''\\\" is met.\n \"\"\"\n global gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase,include_paths\n if not istop:\n saveglobals=gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase\n if ffile==[]: return\n localdolowercase = dolowercase\n cont=0\n finalline=''\n ll=''\n commentline=re.compile(r'(?P([^\"]*\"[^\"]*\"[^\"!]*|[^\\']*\\'[^\\']*\\'[^\\'!]*|[^!]*))!{1}(?P.*)')\n includeline=re.compile(r'\\s*include\\s*(\\'|\")(?P[^\\'\"]*)(\\'|\")',re.I)\n cont1=re.compile(r'(?P.*)&\\s*\\Z')\n cont2=re.compile(r'(\\s*&|)(?P.*)')\n mline_mark = re.compile(r\".*?'''\")\n if istop: dowithline('',-1)\n ll,l1='',''\n spacedigits=[' ']+map(str,range(10))\n filepositiontext=''\n fin=fileinput.FileInput(ffile)\n while 1:\n l=fin.readline()\n if not l: break\n if fin.isfirstline():\n filepositiontext=''\n currentfilename=fin.filename()\n gotnextfile=1\n l1=l\n strictf77=0\n sourcecodeform='fix'\n ext = os.path.splitext(currentfilename)[1]\n if is_f_file(currentfilename) and \\\n not (_has_f90_header(l) or _has_fix_header(l)):\n strictf77=1 \n elif is_free_format(currentfilename) and not _has_fix_header(l):\n sourcecodeform='free'\n if strictf77: beginpattern=beginpattern77\n else: beginpattern=beginpattern90\n outmess('\\tReading file %s (format:%s%s)\\n'\\\n %(`currentfilename`,sourcecodeform,\n strictf77 and ',strict' or ''))\n\n l=string.expandtabs(l).replace('\\xa0',' ')\n while not l=='': # Get rid of newline characters\n if l[-1] not in \"\\n\\r\\f\": break\n l=l[:-1]\n if not strictf77:\n r=commentline.match(l)\n if r:\n l=r.group('line')+' ' # Strip comments starting with `!'\n rl=r.group('rest')\n if string.lower(rl[:4])=='f2py': # f2py directive\n l = l + 4*' '\n r=commentline.match(rl[4:])\n if r: l=l+r('line')\n else: l = l + rl[4:]\n if string.strip(l)=='': # Skip empty line\n cont=0\n continue\n if sourcecodeform=='fix':\n if l[0] in ['*','c','!','C','#']:\n if string.lower(l[1:5])=='f2py': # f2py directive\n l=' '+l[5:]\n else: # Skip comment line\n cont=0\n continue\n elif strictf77:\n if len(l)>72: l=l[:72]\n if not (l[0] in spacedigits):\n raise 'readfortrancode: Found non-(space,digit) char in the first column.\\n\\tAre you sure that this code is in fix form?\\n\\tline=%s'%`l`\n\n if (not cont or strictf77) and (len(l)>5 and not l[5]==' '):\n # Continuation of a previous line\n ll=ll+l[6:]\n finalline=''\n origfinalline=''\n else:\n if not strictf77:\n # F90 continuation\n r=cont1.match(l)\n if r: l=r.group('line') # Continuation follows ..\n if cont:\n ll=ll+cont2.match(l).group('line')\n finalline=''\n origfinalline=''\n else:\n l=' '+l[5:] # clean up line beginning from possible digits.\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline=ll\n ll=l\n cont=(r is not None)\n else:\n l=' '+l[5:] # clean up line beginning from possible digits.\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline =ll\n ll=l\n\n elif sourcecodeform=='free':\n if not cont and ext=='.pyf' and mline_mark.match(l):\n l = l + '\\n'\n while 1:\n lc = fin.readline()\n if not lc:\n errmess('Unexpected end of file when reading multiline\\n')\n break\n l = l + lc\n if mline_mark.match(lc):\n break\n l = l.rstrip()\n r=cont1.match(l)\n if r: l=r.group('line') # Continuation follows ..\n if cont:\n ll=ll+cont2.match(l).group('line')\n finalline=''\n origfinalline=''\n else:\n if localdolowercase: finalline=string.lower(ll)\n else: finalline=ll\n origfinalline =ll\n ll=l\n cont=(r is not None)\n else:\n raise ValueError,\"Flag sourcecodeform must be either 'fix' or 'free': %s\"%`sourcecodeform`\n filepositiontext='Line #%d in %s:\"%s\"\\n\\t' % (fin.filelineno()-1,currentfilename,l1)\n m=includeline.match(origfinalline)\n if m:\n fn=m.group('name')\n if os.path.isfile(fn):\n readfortrancode(fn,dowithline=dowithline,istop=0)\n else:\n include_dirs = [os.path.dirname(currentfilename)] + include_paths\n foundfile = 0\n for inc_dir in include_dirs:\n fn1 = os.path.join(inc_dir,fn)\n if os.path.isfile(fn1):\n foundfile = 1\n readfortrancode(fn1,dowithline=dowithline,istop=0)\n break\n if not foundfile:\n outmess('readfortrancode: could not find include file %s. Ignoring.\\n'%(`fn`))\n else:\n dowithline(finalline)\n l1=ll\n if localdolowercase:\n finalline=string.lower(ll)\n else: finalline=ll\n origfinalline = ll\n filepositiontext='Line #%d in %s:\"%s\"\\n\\t' % (fin.filelineno()-1,currentfilename,l1)\n m=includeline.match(origfinalline)\n if m:\n fn=m.group('name')\n fn1=os.path.join(os.path.dirname(currentfilename),fn)\n if os.path.isfile(fn):\n readfortrancode(fn,dowithline=dowithline,istop=0)\n elif os.path.isfile(fn1):\n readfortrancode(fn1,dowithline=dowithline,istop=0)\n else:\n outmess('readfortrancode: could not find include file %s. Ignoring.\\n'%(`fn`))\n else:\n dowithline(finalline)\n filepositiontext=''\n fin.close()\n if istop: dowithline('',1)\n else:\n gotnextfile,filepositiontext,currentfilename,sourcecodeform,strictf77,\\\n beginpattern,quiet,verbose,dolowercase=saveglobals\n\n########### Crack line\nbeforethisafter=r'\\s*(?P%s(?=\\s*(\\b(%s)\\b)))'+ \\\n r'\\s*(?P(\\b(%s)\\b))'+ \\\n r'\\s*(?P%s)\\s*\\Z'\n##\nfortrantypes='character|logical|integer|real|complex|double\\s*(precision\\s*(complex|)|complex)|type(?=\\s*\\([\\w\\s,=(*)]*\\))|byte'\ntypespattern=re.compile(beforethisafter%('',fortrantypes,fortrantypes,'.*'),re.I),'type'\ntypespattern4implicit=re.compile(beforethisafter%('',fortrantypes+'|static|automatic|undefined',fortrantypes+'|static|automatic|undefined','.*'),re.I)\n#\nfunctionpattern=re.compile(beforethisafter%('([a-z]+[\\w\\s(=*+-/)]*?|)','function','function','.*'),re.I),'begin'\nsubroutinepattern=re.compile(beforethisafter%('[a-z\\s]*?','subroutine','subroutine','.*'),re.I),'begin'\n#modulepattern=re.compile(beforethisafter%('[a-z\\s]*?','module','module','.*'),re.I),'begin'\n#\ngroupbegins77=r'program|block\\s*data'\nbeginpattern77=re.compile(beforethisafter%('',groupbegins77,groupbegins77,'.*'),re.I),'begin'\ngroupbegins90=groupbegins77+r'|module|python\\s*module|interface|type(?!\\s*\\()'\nbeginpattern90=re.compile(beforethisafter%('',groupbegins90,groupbegins90,'.*'),re.I),'begin'\ngroupends=r'end|endprogram|endblockdata|endmodule|endpythonmodule|endinterface'\nendpattern=re.compile(beforethisafter%('',groupends,groupends,'[\\w\\s]*'),re.I),'end'\n#endifs='end\\s*(if|do|where|select|while|forall)'\nendifs='(end\\s*(if|do|where|select|while|forall))|(module\\s*procedure)'\nendifpattern=re.compile(beforethisafter%('[\\w]*?',endifs,endifs,'[\\w\\s]*'),re.I),'endif'\n#\nimplicitpattern=re.compile(beforethisafter%('','implicit','implicit','.*'),re.I),'implicit'\ndimensionpattern=re.compile(beforethisafter%('','dimension|virtual','dimension|virtual','.*'),re.I),'dimension'\nexternalpattern=re.compile(beforethisafter%('','external','external','.*'),re.I),'external'\noptionalpattern=re.compile(beforethisafter%('','optional','optional','.*'),re.I),'optional'\nrequiredpattern=re.compile(beforethisafter%('','required','required','.*'),re.I),'required'\npublicpattern=re.compile(beforethisafter%('','public','public','.*'),re.I),'public'\nprivatepattern=re.compile(beforethisafter%('','private','private','.*'),re.I),'private'\nintrisicpattern=re.compile(beforethisafter%('','intrisic','intrisic','.*'),re.I),'intrisic'\nintentpattern=re.compile(beforethisafter%('','intent|depend|note|check','intent|depend|note|check','\\s*\\(.*?\\).*'),re.I),'intent'\nparameterpattern=re.compile(beforethisafter%('','parameter','parameter','\\s*\\(.*'),re.I),'parameter'\ndatapattern=re.compile(beforethisafter%('','data','data','.*'),re.I),'data'\ncallpattern=re.compile(beforethisafter%('','call','call','.*'),re.I),'call'\nentrypattern=re.compile(beforethisafter%('','entry','entry','.*'),re.I),'entry'\ncallfunpattern=re.compile(beforethisafter%('','callfun','callfun','.*'),re.I),'callfun'\ncommonpattern=re.compile(beforethisafter%('','common','common','.*'),re.I),'common'\nusepattern=re.compile(beforethisafter%('','use','use','.*'),re.I),'use'\ncontainspattern=re.compile(beforethisafter%('','contains','contains',''),re.I),'contains'\nformatpattern=re.compile(beforethisafter%('','format','format','.*'),re.I),'format'\n## Non-fortran and f2py-specific statements\nf2pyenhancementspattern=re.compile(beforethisafter%('','threadsafe|fortranname|callstatement|callprotoargument|usercode|pymethoddef','threadsafe|fortranname|callstatement|callprotoargument|usercode|pymethoddef','.*'),re.I|re.S),'f2pyenhancements'\nmultilinepattern = re.compile(r\"\\s*(?P''')(?P.*?)(?P''')\\s*\\Z\",re.S),'multiline'\n##\n\ndef _simplifyargs(argsline):\n a = []\n for n in string.split(markoutercomma(argsline),'@,@'):\n for r in '(),':\n n = string.replace(n,r,'_')\n a.append(n)\n return string.join(a,',')\n\ncrackline_re_1 = re.compile(r'\\s*(?P\\b[a-z]+[\\w]*\\b)\\s*[=].*',re.I)\ndef crackline(line,reset=0):\n \"\"\"\n reset=-1 --- initialize\n reset=0 --- crack the line\n reset=1 --- final check if mismatch of blocks occured\n\n Cracked data is saved in grouplist[0].\n \"\"\"\n global beginpattern,groupcounter,groupname,groupcache,grouplist,gotnextfile,\\\n filepositiontext,currentfilename,neededmodule,expectbegin,skipblocksuntil,\\\n skipemptyends,previous_context\n if ';' in line and not (f2pyenhancementspattern[0].match(line) or\n multilinepattern[0].match(line)):\n for l in line.split(';'):\n assert reset==0,`reset` # XXX: non-zero reset values need testing\n crackline(l,reset)\n return\n if reset<0:\n groupcounter=0\n groupname={groupcounter:''}\n groupcache={groupcounter:{}}\n grouplist={groupcounter:[]}\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['block']=''\n groupcache[groupcounter]['name']=''\n neededmodule=-1\n skipblocksuntil=-1\n return\n if reset>0:\n fl=0\n if f77modulename and neededmodule==groupcounter: fl=2\n while groupcounter>fl:\n outmess('crackline: groupcounter=%s groupname=%s\\n'%(`groupcounter`,`groupname`))\n outmess('crackline: Mismatch of blocks encountered. Trying to fix it by assuming \"end\" statement.\\n')\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1\n if f77modulename and neededmodule==groupcounter:\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end interface\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end module\n neededmodule=-1\n return\n if line=='': return\n flag=0\n for pat in [dimensionpattern,externalpattern,intentpattern,optionalpattern,\n requiredpattern,\n parameterpattern,datapattern,publicpattern,privatepattern,\n intrisicpattern,\n endifpattern,endpattern,\n formatpattern,\n beginpattern,functionpattern,subroutinepattern,\n implicitpattern,typespattern,commonpattern,\n callpattern,usepattern,containspattern,\n entrypattern,\n f2pyenhancementspattern,\n multilinepattern\n ]:\n m = pat[0].match(line)\n if m:\n break\n flag=flag+1\n if not m:\n re_1 = crackline_re_1\n if 0<=skipblocksuntil<=groupcounter:return\n if groupcache[groupcounter].has_key('externals'):\n for name in groupcache[groupcounter]['externals']:\n if invbadnames.has_key(name):\n name=invbadnames[name]\n if groupcache[groupcounter].has_key('interfaced') and name in groupcache[groupcounter]['interfaced']: continue\n m1=re.match(r'(?P[^\"]*)\\b%s\\b\\s*@\\(@(?P[^@]*)@\\)@.*\\Z'%name,markouterparen(line),re.I)\n if m1:\n m2 = re_1.match(m1.group('before'))\n a = _simplifyargs(m1.group('args'))\n if m2:\n line='callfun %s(%s) result (%s)'%(name,a,m2.group('result'))\n else: line='callfun %s(%s)'%(name,a)\n m = callfunpattern[0].match(line)\n if not m:\n outmess('crackline: could not resolve function call for line=%s.\\n'%`line`)\n return\n analyzeline(m,'callfun',line)\n return\n if verbose>1:\n previous_context = None\n outmess('crackline:%d: No pattern for line\\n'%(groupcounter))\n return\n elif pat[1]=='end':\n if 0<=skipblocksuntil(@\\(@.*?@\\)@|[*][\\d*]+|[*]\\s*@\\(@.*?@\\)@|))(?P.*)\\Z',re.I)\nnameargspattern=re.compile(r'\\s*(?P\\b[\\w$]+\\b)\\s*(@\\(@\\s*(?P[\\w\\s,]*)\\s*@\\)@|)\\s*(result(\\s*@\\(@\\s*(?P\\b[\\w$]+\\b)\\s*@\\)@|))*\\s*\\Z',re.I)\ncallnameargspattern=re.compile(r'\\s*(?P\\b[\\w$]+\\b)\\s*@\\(@\\s*(?P.*)\\s*@\\)@\\s*\\Z',re.I)\nreal16pattern = re.compile(r'([-+]?(?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+))[dD]((?:[-+]?\\d+)?)')\nreal8pattern = re.compile(r'([-+]?((?:\\d+(?:\\.\\d*)?|\\d*\\.\\d+))[eE]((?:[-+]?\\d+)?)|(\\d+\\.\\d*))')\n\n_intentcallbackpattern = re.compile(r'intent\\s*\\(.*?\\bcallback\\b',re.I)\ndef _is_intent_callback(vdecl):\n for a in vdecl.get('attrspec',[]):\n if _intentcallbackpattern.match(a):\n return 1\n return 0\n\ndef _resolvenameargspattern(line):\n line = markouterparen(line)\n m1=nameargspattern.match(line)\n if m1: return m1.group('name'),m1.group('args'),m1.group('result')\n m1=callnameargspattern.match(line)\n if m1: return m1.group('name'),m1.group('args'),None\n return None,[],None\n \ndef analyzeline(m,case,line):\n global groupcounter,groupname,groupcache,grouplist,filepositiontext,\\\n currentfilename,f77modulename,neededinterface,neededmodule,expectbegin,\\\n gotnextfile,previous_context\n block=m.group('this')\n if case != 'multiline':\n previous_context = None\n if expectbegin and case not in ['begin','call','callfun','type'] \\\n and not skipemptyends and groupcounter<1:\n newname=string.split(os.path.basename(currentfilename),'.')[0]\n outmess('analyzeline: no group yet. Creating program group with name \"%s\".\\n'%newname)\n gotnextfile=0\n groupcounter=groupcounter+1\n groupname[groupcounter]='program'\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['block']='program'\n groupcache[groupcounter]['name']=newname\n groupcache[groupcounter]['from']='fromsky'\n expectbegin=0\n if case in ['begin','call','callfun']:\n # Crack line => block,name,args,result\n block = block.lower()\n if re.match(r'block\\s*data',block,re.I): block='block data'\n if re.match(r'python\\s*module',block,re.I): block='python module'\n name,args,result = _resolvenameargspattern(m.group('after'))\n if name is None:\n if block=='block data':\n name = '_BLOCK_DATA_'\n else:\n name = ''\n if block not in ['interface','block data']:\n outmess('analyzeline: No name/args pattern found for line.\\n')\n\n previous_context = (block,name,groupcounter)\n if args: args=rmbadname(map(string.strip,string.split(markoutercomma(args),'@,@')))\n else: args=[]\n if '' in args:\n while '' in args:\n args.remove('')\n outmess('analyzeline: argument list is malformed (missing argument).\\n')\n \n # end of crack line => block,name,args,result\n needmodule=0\n needinterface=0\n\n if case in ['call','callfun']:\n needinterface=1\n if not groupcache[groupcounter].has_key('args'): return\n if name not in groupcache[groupcounter]['args']:\n return\n for it in grouplist[groupcounter]:\n if it['name']==name: return\n if name in groupcache[groupcounter]['interfaced']: return\n block={'call':'subroutine','callfun':'function'}[case]\n if f77modulename and neededmodule==-1 and groupcounter<=1:\n neededmodule=groupcounter+2\n needmodule=1\n needinterface=1 \n # Create new block(s)\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n if needmodule:\n if verbose>1:\n outmess('analyzeline: Creating module block %s\\n'%`f77modulename`,0)\n groupname[groupcounter]='module'\n groupcache[groupcounter]['block']='python module'\n groupcache[groupcounter]['name']=f77modulename\n groupcache[groupcounter]['from']=''\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n if needinterface:\n if verbose>1:\n outmess('analyzeline: Creating additional interface block.\\n',0)\n groupname[groupcounter]='interface'\n groupcache[groupcounter]['block']='interface'\n groupcache[groupcounter]['name']='unknown_interface'\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],groupcache[groupcounter-1]['name'])\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcounter=groupcounter+1\n groupcache[groupcounter]={}\n grouplist[groupcounter]=[]\n groupname[groupcounter]=block\n groupcache[groupcounter]['block']=block\n if not name: name='unknown_'+block\n groupcache[groupcounter]['prefix']=m.group('before')\n groupcache[groupcounter]['name']=rmbadname1(name)\n groupcache[groupcounter]['result']=result\n if groupcounter==1:\n groupcache[groupcounter]['from']=currentfilename\n else:\n if f77modulename and groupcounter==3:\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],currentfilename)\n else:\n groupcache[groupcounter]['from']='%s:%s'%(groupcache[groupcounter-1]['from'],groupcache[groupcounter-1]['name'])\n for k in groupcache[groupcounter].keys():\n if not groupcache[groupcounter][k]: del groupcache[groupcounter][k]\n groupcache[groupcounter]['args']=args\n groupcache[groupcounter]['body']=[]\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['interfaced']=[]\n groupcache[groupcounter]['vars']={}\n groupcache[groupcounter]['entry']={}\n # end of creation\n if block=='type':\n groupcache[groupcounter]['varnames'] = []\n\n if case in ['call','callfun']: # set parents variables\n if name not in groupcache[groupcounter-2]['externals']:\n groupcache[groupcounter-2]['externals'].append(name)\n groupcache[groupcounter]['vars']=copy.deepcopy(groupcache[groupcounter-2]['vars'])\n #try: del groupcache[groupcounter]['vars'][groupcache[groupcounter-2]['name']]\n #except: pass\n try: del groupcache[groupcounter]['vars'][name][groupcache[groupcounter]['vars'][name]['attrspec'].index('external')]\n except: pass\n if block in ['function','subroutine']: # set global attributes\n try: groupcache[groupcounter]['vars'][name]=appenddecl(groupcache[groupcounter]['vars'][name],groupcache[groupcounter-2]['vars'][''])\n except: pass\n if case=='callfun': # return type\n if result and groupcache[groupcounter]['vars'].has_key(result):\n if not name==result:\n groupcache[groupcounter]['vars'][name]=appenddecl(groupcache[groupcounter]['vars'][name],groupcache[groupcounter]['vars'][result])\n #if groupcounter>1: # name is interfaced\n try: groupcache[groupcounter-2]['interfaced'].append(name)\n except: pass\n if block=='function':\n t=typespattern[0].match(m.group('before')+' '+name)\n if t:\n typespec,selector,attr,edecl=cracktypespec0(t.group('this'),t.group('after'))\n updatevars(typespec,selector,attr,edecl)\n if case in ['call','callfun']:\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end routine\n grouplist[groupcounter-1].append(groupcache[groupcounter])\n grouplist[groupcounter-1][-1]['body']=grouplist[groupcounter]\n del grouplist[groupcounter]\n groupcounter=groupcounter-1 # end interface\n elif case=='entry':\n name,args,result=_resolvenameargspattern(m.group('after'))\n if name is not None:\n if args:\n args=rmbadname(map(string.strip,string.split(markoutercomma(args),'@,@')))\n else: args=[] \n assert result is None,`result`\n groupcache[groupcounter]['entry'][name] = args\n previous_context = ('entry',name,groupcounter)\n elif case=='type':\n typespec,selector,attr,edecl=cracktypespec0(block,m.group('after'))\n last_name = updatevars(typespec,selector,attr,edecl)\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case in ['dimension','intent','optional','required','external','public','private','intrisic']:\n edecl=groupcache[groupcounter]['vars']\n ll=m.group('after')\n i=string.find(ll,'::')\n if i<0 and case=='intent':\n i=string.find(markouterparen(ll),'@)@')-2\n ll=ll[:i+1]+'::'+ll[i+1:]\n i=string.find(ll,'::')\n if ll[i:]=='::' and groupcache[groupcounter].has_key('args'):\n outmess('All arguments will have attribute %s%s\\n'%(m.group('this'),ll[:i]))\n ll = ll + string.join(groupcache[groupcounter]['args'],',')\n if i<0:i=0;pl=''\n else: pl=string.strip(ll[:i]);ll=ll[i+2:]\n ch = string.split(markoutercomma(pl),'@,@')\n if len(ch)>1:\n pl = ch[0]\n outmess('analyzeline: cannot handle multiple attributes without type specification. Ignoring %r.\\n' % (','.join(ch[1:])))\n last_name = None\n for e in map(string.strip,string.split(markoutercomma(ll),'@,@')):\n m1=namepattern.match(e)\n if not m1:\n if case in ['public','private']: k=''\n else:\n print m.groupdict()\n outmess('analyzeline: no name pattern found in %s statement for %s. Skipping.\\n'%(case,`e`))\n continue\n else:\n k=rmbadname1(m1.group('name'))\n if not edecl.has_key(k): edecl[k]={}\n if case=='dimension': ap=case+m1.group('after')\n if case=='intent':\n ap=m.group('this')+pl\n if _intentcallbackpattern.match(ap):\n if k not in groupcache[groupcounter]['args']:\n if groupcounter>1 and \\\n string.find(groupcache[groupcounter-2]['name'],\n '__user__')==-1:\n outmess('analyzeline: appending intent(callback) %s'\\\n ' to %s arguments\\n' % (k,groupcache[groupcounter]['name']))\n groupcache[groupcounter]['args'].append(k)\n else:\n errmess('analyzeline: intent(callback) %s is already'\\\n ' in argument list' % (k))\n if case in ['optional','required','public','external','private','intrisic']: ap=case\n if edecl[k].has_key('attrspec'): edecl[k]['attrspec'].append(ap)\n else: edecl[k]['attrspec']=[ap]\n if case=='external':\n if groupcache[groupcounter]['block']=='program':\n outmess('analyzeline: ignoring program arguments\\n')\n continue\n if k not in groupcache[groupcounter]['args']:\n #outmess('analyzeline: ignoring external %s (not in arguments list)\\n'%(`k`))\n continue\n if not groupcache[groupcounter].has_key('externals'):\n groupcache[groupcounter]['externals']=[]\n groupcache[groupcounter]['externals'].append(k)\n last_name = k\n groupcache[groupcounter]['vars']=edecl\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case=='parameter':\n edecl=groupcache[groupcounter]['vars']\n ll=string.strip(m.group('after'))[1:-1]\n last_name = None\n for e in string.split(markoutercomma(ll),'@,@'):\n try:\n k,initexpr=map(string.strip,string.split(e,'='))\n except:\n outmess('analyzeline: could not extract name,expr in parameter statement \"%s\" of \"%s\"\\n'%(e,ll));continue\n params = get_parameters(edecl)\n k=rmbadname1(k)\n if not edecl.has_key(k): edecl[k]={}\n if edecl[k].has_key('=') and (not edecl[k]['=']==initexpr):\n outmess('analyzeline: Overwriting the value of parameter \"%s\" (\"%s\") with \"%s\".\\n'%(k,edecl[k]['='],initexpr))\n t = determineexprtype(initexpr,params)\n if t:\n if t.get('typespec')=='real':\n tt = list(initexpr)\n for m in real16pattern.finditer(initexpr):\n tt[m.start():m.end()] = list(\\\n initexpr[m.start():m.end()].lower().replace('d', 'e'))\n initexpr = \"\".join(tt)\n elif t.get('typespec')=='complex':\n initexpr = initexpr[1:].lower().replace('d','e').\\\n replace(',','+1j*(')\n try:\n v = eval(initexpr,{},params)\n except (SyntaxError,NameError),msg:\n errmess('analyzeline: Failed to evaluate %r. Ignoring: %s\\n'\\\n % (initexpr, msg))\n continue\n edecl[k]['='] = repr(v)\n if edecl[k].has_key('attrspec'):\n edecl[k]['attrspec'].append('parameter')\n else: edecl[k]['attrspec']=['parameter']\n last_name = k\n groupcache[groupcounter]['vars']=edecl\n if last_name is not None:\n previous_context = ('variable',last_name,groupcounter)\n elif case=='implicit':\n if string.lower(string.strip(m.group('after')))=='none':\n groupcache[groupcounter]['implicit']=None\n elif m.group('after'):\n if groupcache[groupcounter].has_key('implicit'):\n impl=groupcache[groupcounter]['implicit']\n else: impl={}\n if impl is None:\n outmess('analyzeline: Overwriting earlier \"implicit none\" statement.\\n')\n impl={}\n for e in string.split(markoutercomma(m.group('after')),'@,@'):\n decl={}\n m1=re.match(r'\\s*(?P.*?)\\s*(\\(\\s*(?P[a-z-, ]+)\\s*\\)\\s*|)\\Z',e,re.I)\n if not m1:\n outmess('analyzeline: could not extract info of implicit statement part \"%s\"\\n'%(e));continue\n m2=typespattern4implicit.match(m1.group('this'))\n if not m2:\n outmess('analyzeline: could not extract types pattern of implicit statement part \"%s\"\\n'%(e));continue\n typespec,selector,attr,edecl=cracktypespec0(m2.group('this'),m2.group('after'))\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n decl['typespec']=typespec\n decl['kindselector']=kindselect\n decl['charselector']=charselect\n decl['typename']=typename\n for k in decl.keys():\n if not decl[k]: del decl[k]\n for r in string.split(markoutercomma(m1.group('after')),'@,@'):\n if '-' in r:\n try: begc,endc=map(string.strip,string.split(r,'-'))\n except:\n outmess('analyzeline: expected \"-\" instead of \"%s\" in range list of implicit statement\\n'%r);continue\n else: begc=endc=string.strip(r)\n if not len(begc)==len(endc)==1:\n outmess('analyzeline: expected \"-\" instead of \"%s\" in range list of implicit statement (2)\\n'%r);continue\n for o in range(ord(begc),ord(endc)+1):\n impl[chr(o)]=decl\n groupcache[groupcounter]['implicit']=impl\n elif case=='data':\n ll=[]\n dl='';il='';f=0;fc=1\n for c in m.group('after'):\n if c==\"'\": fc=not fc\n if c=='/' and fc: f=f+1;continue\n if f==0: dl=dl+c\n elif f==1: il=il+c\n elif f==2:\n dl = dl.strip()\n if dl.startswith(','):\n dl = dl[1:].strip()\n ll.append([dl,il])\n dl=c;il='';f=0\n if f==2:\n dl = dl.strip()\n if dl.startswith(','):\n dl = dl[1:].strip()\n ll.append([dl,il])\n vars={}\n if groupcache[groupcounter].has_key('vars'):\n vars=groupcache[groupcounter]['vars']\n last_name = None\n for l in ll:\n l=map(string.strip,l)\n if l[0][0]==',':l[0]=l[0][1:]\n if l[0][0]=='(':\n outmess('analyzeline: implied-DO list \"%s\" is not supported. Skipping.\\n'%l[0])\n continue\n #if '(' in l[0]:\n # #outmess('analyzeline: ignoring this data statement.\\n')\n # continue\n i=0;j=0;llen=len(l[1])\n for v in rmbadname(map(string.strip,string.split(markoutercomma(l[0]),'@,@'))):\n fc=0\n while (i=3:\n bn = string.strip(bn)\n if not bn: bn='_BLNK_'\n cl.append([bn,ol])\n f=f-2;bn='';ol=''\n if f%2: bn=bn+c\n else: ol=ol+c\n bn = string.strip(bn)\n if not bn: bn='_BLNK_'\n cl.append([bn,ol])\n commonkey={}\n if groupcache[groupcounter].has_key('common'):\n commonkey=groupcache[groupcounter]['common']\n for c in cl:\n if commonkey.has_key(c[0]):\n outmess('analyzeline: previously defined common block encountered. Skipping.\\n')\n continue\n commonkey[c[0]]=[]\n for i in map(string.strip,string.split(markoutercomma(c[1]),'@,@')):\n if i: commonkey[c[0]].append(i)\n groupcache[groupcounter]['common']=commonkey\n previous_context = ('common',bn,groupcounter)\n elif case=='use':\n m1=re.match(r'\\A\\s*(?P\\b[\\w]+\\b)\\s*((,(\\s*\\bonly\\b\\s*:|(?P))\\s*(?P.*))|)\\s*\\Z',m.group('after'),re.I)\n if m1:\n mm=m1.groupdict()\n if not groupcache[groupcounter].has_key('use'): groupcache[groupcounter]['use']={}\n name=m1.group('name')\n groupcache[groupcounter]['use'][name]={}\n isonly=0\n if mm.has_key('list') and mm['list'] is not None:\n if mm.has_key('notonly') and mm['notonly'] is None:isonly=1\n groupcache[groupcounter]['use'][name]['only']=isonly\n ll=map(string.strip,string.split(mm['list'],','))\n rl={}\n for l in ll:\n if '=' in l:\n m2=re.match(r'\\A\\s*(?P\\b[\\w]+\\b)\\s*=\\s*>\\s*(?P\\b[\\w]+\\b)\\s*\\Z',l,re.I)\n if m2: rl[string.strip(m2.group('local'))]=string.strip(m2.group('use'))\n else:\n outmess('analyzeline: Not local=>use pattern found in %s\\n'%`l`)\n else:\n rl[l]=l\n groupcache[groupcounter]['use'][name]['map']=rl\n else:\n pass\n \n else:\n print m.groupdict()\n outmess('analyzeline: Could not crack the use statement.\\n')\n elif case in ['f2pyenhancements']:\n if not groupcache[groupcounter].has_key ('f2pyenhancements'):\n groupcache[groupcounter]['f2pyenhancements'] = {}\n d = groupcache[groupcounter]['f2pyenhancements']\n if m.group('this')=='usercode' and d.has_key('usercode'):\n if type(d['usercode']) is type(''):\n d['usercode'] = [d['usercode']]\n d['usercode'].append(m.group('after'))\n else:\n d[m.group('this')] = m.group('after')\n elif case=='multiline':\n if previous_context is None:\n if verbose:\n outmess('analyzeline: No context for multiline block.\\n')\n return\n gc = groupcounter\n #gc = previous_context[2]\n appendmultiline(groupcache[gc],\n previous_context[:2],\n m.group('this'))\n else:\n if verbose>1:\n print m.groupdict()\n outmess('analyzeline: No code implemented for line.\\n')\n\ndef appendmultiline(group, context_name,ml):\n if not group.has_key('f2pymultilines'):\n group['f2pymultilines'] = {}\n d = group['f2pymultilines']\n if not d.has_key(context_name):\n d[context_name] = []\n d[context_name].append(ml)\n return\n\ndef cracktypespec0(typespec,ll):\n selector=None\n attr=None\n if re.match(r'double\\s*complex',typespec,re.I): typespec='double complex'\n elif re.match(r'double\\s*precision',typespec,re.I): typespec='double precision'\n else: typespec=string.lower(string.strip(typespec))\n m1=selectpattern.match(markouterparen(ll))\n if not m1:\n outmess('cracktypespec0: no kind/char_selector pattern found for line.\\n')\n return\n d=m1.groupdict()\n for k in d.keys(): d[k]=unmarkouterparen(d[k])\n if typespec in ['complex','integer','logical','real','character','type']:\n selector=d['this']\n ll=d['after']\n i=string.find(ll,'::')\n if i>=0:\n attr=string.strip(ll[:i])\n ll=ll[i+2:]\n return typespec,selector,attr,ll\n#####\nnamepattern=re.compile(r'\\s*(?P\\b[\\w]+\\b)\\s*(?P.*)\\s*\\Z',re.I)\nkindselector=re.compile(r'\\s*(\\(\\s*(kind\\s*=)?\\s*(?P.*)\\s*\\)|[*]\\s*(?P.*?))\\s*\\Z',re.I)\ncharselector=re.compile(r'\\s*(\\((?P.*)\\)|[*]\\s*(?P.*))\\s*\\Z',re.I)\nlenkindpattern=re.compile(r'\\s*(kind\\s*=\\s*(?P.*?)\\s*(@,@\\s*len\\s*=\\s*(?P.*)|)|(len\\s*=\\s*|)(?P.*?)\\s*(@,@\\s*(kind\\s*=\\s*|)(?P.*)|))\\s*\\Z',re.I)\nlenarraypattern=re.compile(r'\\s*(@\\(@\\s*(?!/)\\s*(?P.*?)\\s*@\\)@\\s*[*]\\s*(?P.*?)|([*]\\s*(?P.*?)|)\\s*(@\\(@\\s*(?!/)\\s*(?P.*?)\\s*@\\)@|))\\s*(=\\s*(?P.*?)|(@\\(@|)/\\s*(?P.*?)\\s*/(@\\)@|)|)\\s*\\Z',re.I)\ndef removespaces(expr):\n expr=string.strip(expr)\n if len(expr)<=1: return expr\n expr2=expr[0]\n for i in range(1,len(expr)-1):\n if expr[i]==' ' and \\\n ((expr[i+1] in \"()[]{}= \") or (expr[i-1] in \"()[]{}= \")): continue\n expr2=expr2+expr[i]\n expr2=expr2+expr[-1]\n return expr2\ndef markinnerspaces(line):\n l='';f=0\n cc='\\''\n cc1='\"'\n cb=''\n for c in line:\n if cb=='\\\\' and c in ['\\\\','\\'','\"']:\n l=l+c;\n cb=c\n continue \n if f==0 and c in ['\\'','\"']: cc=c; cc1={'\\'':'\"','\"':'\\''}[c]\n if c==cc:f=f+1\n elif c==cc:f=f-1\n elif c==' ' and f==1: l=l+'@_@'; continue\n l=l+c;cb=c\n return l\ndef updatevars(typespec,selector,attrspec,entitydecl):\n global groupcache,groupcounter\n last_name = None\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n if attrspec:\n attrspec=map(string.strip,string.split(markoutercomma(attrspec),'@,@'))\n l = []\n c = re.compile(r'(?P[a-zA-Z]+)')\n for a in attrspec:\n m = c.match(a)\n if m:\n s = string.lower(m.group('start'))\n a = s + a[len(s):]\n l.append(a)\n attrspec = l\n el=map(string.strip,string.split(markoutercomma(entitydecl),'@,@'))\n el1=[]\n for e in el:\n for e1 in map(string.strip,string.split(markoutercomma(removespaces(markinnerspaces(e)),comma=' '),'@ @')):\n if e1: el1.append(string.replace(e1,'@_@',' '))\n for e in el1:\n m=namepattern.match(e)\n if not m:\n outmess('updatevars: no name pattern found for entity=%s. Skipping.\\n'%(`e`))\n continue\n ename=rmbadname1(m.group('name'))\n edecl={}\n if groupcache[groupcounter]['vars'].has_key(ename):\n edecl=groupcache[groupcounter]['vars'][ename].copy()\n has_typespec = edecl.has_key('typespec')\n if not has_typespec:\n edecl['typespec']=typespec\n elif typespec and (not typespec==edecl['typespec']):\n outmess('updatevars: attempt to change the type of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['typespec'],typespec))\n if not edecl.has_key('kindselector'):\n edecl['kindselector']=copy.copy(kindselect)\n elif kindselect:\n for k in kindselect.keys():\n if edecl['kindselector'].has_key(k) and (not kindselect[k]==edecl['kindselector'][k]):\n outmess('updatevars: attempt to change the kindselector \"%s\" of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (k,ename,edecl['kindselector'][k],kindselect[k]))\n else: edecl['kindselector'][k]=copy.copy(kindselect[k])\n if not edecl.has_key('charselector') and charselect:\n if not has_typespec:\n edecl['charselector']=charselect\n else:\n errmess('updatevars:%s: attempt to change empty charselector to %r. Ignoring.\\n' \\\n %(ename,charselect))\n elif charselect:\n for k in charselect.keys():\n if edecl['charselector'].has_key(k) and (not charselect[k]==edecl['charselector'][k]):\n outmess('updatevars: attempt to change the charselector \"%s\" of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (k,ename,edecl['charselector'][k],charselect[k]))\n else: edecl['charselector'][k]=copy.copy(charselect[k])\n if not edecl.has_key('typename'):\n edecl['typename']=typename\n elif typename and (not edecl['typename']==typename):\n outmess('updatevars: attempt to change the typename of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['typename'],typename))\n if not edecl.has_key('attrspec'):\n edecl['attrspec']=copy.copy(attrspec)\n elif attrspec:\n for a in attrspec:\n if a not in edecl['attrspec']:\n edecl['attrspec'].append(a)\n else:\n edecl['typespec']=copy.copy(typespec)\n edecl['kindselector']=copy.copy(kindselect)\n edecl['charselector']=copy.copy(charselect)\n edecl['typename']=typename\n edecl['attrspec']=copy.copy(attrspec)\n if m.group('after'):\n m1=lenarraypattern.match(markouterparen(m.group('after')))\n if m1:\n d1=m1.groupdict()\n for lk in ['len','array','init']:\n if d1[lk+'2'] is not None: d1[lk]=d1[lk+'2']; del d1[lk+'2']\n for k in d1.keys():\n if d1[k] is not None: d1[k]=unmarkouterparen(d1[k])\n else: del d1[k]\n if d1.has_key('len') and d1.has_key('array'):\n if d1['len']=='':\n d1['len']=d1['array']\n del d1['array']\n else:\n d1['array']=d1['array']+','+d1['len']\n del d1['len']\n errmess('updatevars: \"%s %s\" is mapped to \"%s %s(%s)\"\\n'%(typespec,e,typespec,ename,d1['array']))\n if d1.has_key('array'):\n dm = 'dimension(%s)'%d1['array']\n if not edecl.has_key('attrspec') or (not edecl['attrspec']):\n edecl['attrspec']=[dm]\n else:\n edecl['attrspec'].append(dm)\n for dm1 in edecl['attrspec']:\n if dm1[:9]=='dimension' and dm1!=dm:\n del edecl['attrspec'][-1]\n errmess('updatevars:%s: attempt to change %r to %r. Ignoring.\\n' \\\n % (ename,dm1,dm))\n break\n \n if d1.has_key('len'):\n if typespec in ['complex','integer','logical','real']:\n if (not edecl.has_key('kindselector')) or (not edecl['kindselector']):\n edecl['kindselector']={}\n edecl['kindselector']['*']=d1['len']\n elif typespec == 'character':\n if (not edecl.has_key('charselector')) or (not edecl['charselector']): edecl['charselector']={}\n if edecl['charselector'].has_key('len'): del edecl['charselector']['len']\n edecl['charselector']['*']=d1['len']\n if d1.has_key('init'):\n if edecl.has_key('=') and (not edecl['=']==d1['init']):\n outmess('updatevars: attempt to change the init expression of \"%s\" (\"%s\") to \"%s\". Ignoring.\\n' % (ename,edecl['='],d1['init']))\n else:\n edecl['=']=d1['init']\n else:\n outmess('updatevars: could not crack entity declaration \"%s\". Ignoring.\\n'%(ename+m.group('after')))\n for k in edecl.keys():\n if not edecl[k]: del edecl[k]\n groupcache[groupcounter]['vars'][ename]=edecl\n if groupcache[groupcounter].has_key('varnames'):\n groupcache[groupcounter]['varnames'].append(ename)\n last_name = ename\n return last_name\n\ndef cracktypespec(typespec,selector):\n kindselect=None\n charselect=None\n typename=None\n if selector:\n if typespec in ['complex','integer','logical','real']:\n kindselect=kindselector.match(selector)\n if not kindselect:\n outmess('cracktypespec: no kindselector pattern found for %s\\n'%(`selector`))\n return\n kindselect=kindselect.groupdict()\n kindselect['*']=kindselect['kind2']\n del kindselect['kind2']\n for k in kindselect.keys():\n if not kindselect[k]: del kindselect[k]\n for k,i in kindselect.items():\n kindselect[k] = rmbadname1(i)\n elif typespec=='character':\n charselect=charselector.match(selector)\n if not charselect:\n outmess('cracktypespec: no charselector pattern found for %s\\n'%(`selector`))\n return\n charselect=charselect.groupdict()\n charselect['*']=charselect['charlen']\n del charselect['charlen']\n if charselect['lenkind']:\n lenkind=lenkindpattern.match(markoutercomma(charselect['lenkind']))\n lenkind=lenkind.groupdict()\n for lk in ['len','kind']:\n if lenkind[lk+'2']:\n lenkind[lk]=lenkind[lk+'2']\n charselect[lk]=lenkind[lk]\n del lenkind[lk+'2']\n del charselect['lenkind']\n for k in charselect.keys():\n if not charselect[k]: del charselect[k]\n for k,i in charselect.items():\n charselect[k] = rmbadname1(i)\n elif typespec=='type':\n typename=re.match(r'\\s*\\(\\s*(?P\\w+)\\s*\\)',selector,re.I)\n if typename: typename=typename.group('name')\n else: outmess('cracktypespec: no typename found in %s\\n'%(`typespec+selector`))\n else:\n outmess('cracktypespec: no selector used for %s\\n'%(`selector`))\n return kindselect,charselect,typename\n######\ndef setattrspec(decl,attr,force=0):\n if not decl: decl={}\n if not attr: return decl\n if not decl.has_key('attrspec'):\n decl['attrspec']=[attr]\n return decl\n if force: decl['attrspec'].append(attr)\n if attr in decl['attrspec']: return decl\n if attr=='static' and 'automatic' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='automatic' and 'static' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='public' and 'private' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n elif attr=='private' and 'public' not in decl['attrspec']:\n decl['attrspec'].append(attr)\n else:\n decl['attrspec'].append(attr)\n return decl\ndef setkindselector(decl,sel,force=0):\n if not decl: decl={}\n if not sel: return decl\n if not decl.has_key('kindselector'):\n decl['kindselector']=sel\n return decl\n for k in sel.keys():\n if force or not decl['kindselector'].has_key(k):\n decl['kindselector'][k]=sel[k]\n return decl\ndef setcharselector(decl,sel,force=0):\n if not decl: decl={}\n if not sel: return decl\n if not decl.has_key('charselector'):\n decl['charselector']=sel\n return decl\n for k in sel.keys():\n if force or not decl['charselector'].has_key(k):\n decl['charselector'][k]=sel[k]\n return decl\ndef getblockname(block,unknown='unknown'):\n if block.has_key('name'): return block['name']\n return unknown\n###### post processing\ndef setmesstext(block):\n global filepositiontext\n try: filepositiontext='In: %s:%s\\n'%(block['from'],block['name'])\n except: pass\n\ndef get_usedict(block):\n usedict = {}\n if block.has_key('parent_block'):\n usedict = get_usedict(block['parent_block'])\n if block.has_key('use'):\n usedict.update(block['use'])\n return usedict\n\ndef get_useparameters(block, param_map=None):\n global f90modulevars\n if param_map is None:\n param_map = {}\n usedict = get_usedict(block)\n if not usedict:\n return param_map\n for usename,mapping in usedict.items():\n usename = string.lower(usename)\n if not f90modulevars.has_key(usename):\n continue\n mvars = f90modulevars[usename]\n params = get_parameters(mvars)\n if not params:\n continue\n # XXX: apply mapping\n if mapping:\n errmess('get_useparameters: mapping for %s not impl.' % (mapping))\n for k,v in params.items():\n if param_map.has_key(k):\n outmess('get_useparameters: overriding parameter %s with'\\\n ' value from module %s' % (`k`,`usename`))\n param_map[k] = v\n return param_map\n\ndef postcrack2(block,tab='',param_map=None):\n global f90modulevars\n if not f90modulevars:\n return block\n if type(block)==types.ListType:\n ret = []\n for g in block:\n g = postcrack2(g,tab=tab+'\\t',param_map=param_map)\n ret.append(g)\n return ret\n setmesstext(block)\n outmess('%sBlock: %s\\n'%(tab,block['name']),0)\n\n if param_map is None:\n param_map = get_useparameters(block)\n\n if param_map is not None and block.has_key('vars'):\n vars = block['vars']\n for n in vars.keys():\n var = vars[n]\n if var.has_key('kindselector'):\n kind = var['kindselector']\n if kind.has_key('kind'):\n val = kind['kind']\n if param_map.has_key(val):\n kind['kind'] = param_map[val]\n new_body = []\n for b in block['body']:\n b = postcrack2(b,tab=tab+'\\t',param_map=param_map)\n new_body.append(b)\n block['body'] = new_body\n\n return block\n\ndef postcrack(block,args=None,tab=''):\n \"\"\"\n TODO:\n function return values\n determine expression types if in argument list\n \"\"\"\n global usermodules,onlyfunctions\n if type(block)==types.ListType:\n gret=[]\n uret=[]\n for g in block:\n setmesstext(g)\n g=postcrack(g,tab=tab+'\\t')\n if g.has_key('name') and string.find(g['name'],'__user__')>=0: # sort user routines to appear first\n uret.append(g)\n else:\n gret.append(g)\n return uret+gret\n setmesstext(block)\n if (not type(block)==types.DictType) and not block.has_key('block'):\n raise 'postcrack: Expected block dictionary instead of ',block\n if block.has_key('name') and not block['name']=='unknown_interface':\n outmess('%sBlock: %s\\n'%(tab,block['name']),0)\n blocktype=block['block']\n block=analyzeargs(block)\n block=analyzecommon(block)\n block['vars']=analyzevars(block)\n block['sortvars']=sortvarnames(block['vars'])\n if block.has_key('args') and block['args']:\n args=block['args']\n block['body']=analyzebody(block,args,tab=tab)\n\n userisdefined=[]\n## fromuser = []\n if block.has_key('use'):\n useblock=block['use']\n for k in useblock.keys():\n if string.find(k,'__user__')>=0:\n userisdefined.append(k)\n## if useblock[k].has_key('map'):\n## for n in useblock[k]['map'].values():\n## if n not in fromuser: fromuser.append(n)\n else: useblock={}\n name=''\n if block.has_key('name'):name=block['name']\n if block.has_key('externals') and block['externals']:# and not userisdefined: # Build a __user__ module\n interfaced=[]\n if block.has_key('interfaced'): interfaced=block['interfaced']\n mvars=copy.copy(block['vars'])\n if name: mname=name+'__user__routines'\n else: mname='unknown__user__routines'\n if mname in userisdefined:\n i=1\n while '%s_%i'%(mname,i) in userisdefined: i=i+1\n mname='%s_%i'%(mname,i)\n interface={'block':'interface','body':[],'vars':{},'name':name+'_user_interface'}\n for e in block['externals']:\n## if e in fromuser:\n## outmess(' Skipping %s that is defined explicitly in another use statement\\n'%(`e`))\n## continue\n if e in interfaced:\n edef=[]\n j=-1\n for b in block['body']:\n j=j+1\n if b['block']=='interface':\n i=-1\n for bb in b['body']:\n i=i+1\n if bb.has_key('name') and bb['name']==e:\n edef=copy.copy(bb)\n del b['body'][i]\n break\n if edef:\n if not b['body']: del block['body'][j]\n del interfaced[interfaced.index(e)]\n break\n interface['body'].append(edef)\n else:\n if mvars.has_key(e) and not isexternal(mvars[e]):\n interface['vars'][e]=mvars[e]\n if interface['vars'] or interface['body']:\n block['interfaced']=interfaced\n mblock={'block':'python module','body':[interface],'vars':{},'name':mname,'interfaced':block['externals']}\n useblock[mname]={}\n usermodules.append(mblock)\n if useblock:\n block['use']=useblock\n return block\n\ndef sortvarnames(vars):\n indep = []\n dep = []\n for v in vars.keys():\n if vars[v].has_key('depend') and vars[v]['depend']:\n dep.append(v)\n #print '%s depends on %s'%(v,vars[v]['depend'])\n else: indep.append(v)\n n = len(dep)\n i = 0\n while dep: #XXX: How to catch dependence cycles correctly?\n v = dep[0]\n fl = 0\n for w in dep[1:]:\n if w in vars[v]['depend']:\n fl = 1\n break\n if fl:\n dep = dep[1:]+[v]\n i = i + 1\n if i>n:\n errmess('sortvarnames: failed to compute dependencies because'\n ' of cyclic dependencies between '\n +string.join(dep,', ')+'\\n')\n indep = indep + dep\n break\n else:\n indep.append(v)\n dep = dep[1:]\n n = len(dep)\n i = 0\n #print indep\n return indep\n\ndef analyzecommon(block):\n if not hascommon(block): return block\n commonvars=[]\n for k in block['common'].keys():\n comvars=[]\n for e in block['common'][k]:\n m=re.match(r'\\A\\s*\\b(?P.*?)\\b\\s*(\\((?P.*?)\\)|)\\s*\\Z',e,re.I)\n if m:\n dims=[]\n if m.group('dims'):\n dims=map(string.strip,string.split(markoutercomma(m.group('dims')),'@,@'))\n n=string.strip(m.group('name'))\n if block['vars'].has_key(n):\n if block['vars'][n].has_key('attrspec'):\n block['vars'][n]['attrspec'].append('dimension(%s)'%(string.join(dims,',')))\n else:\n block['vars'][n]['attrspec']=['dimension(%s)'%(string.join(dims,','))]\n else:\n if dims:\n block['vars'][n]={'attrspec':['dimension(%s)'%(string.join(dims,','))]}\n else: block['vars'][n]={}\n if n not in commonvars: commonvars.append(n)\n else:\n n=e\n errmess('analyzecommon: failed to extract \"[()]\" from \"%s\" in common /%s/.\\n'%(e,k))\n comvars.append(n)\n block['common'][k]=comvars\n if not block.has_key('commonvars'):\n block['commonvars']=commonvars\n else:\n block['commonvars']=block['commonvars']+commonvars\n return block\ndef analyzebody(block,args,tab=''):\n global usermodules,skipfuncs,onlyfuncs,f90modulevars\n setmesstext(block)\n body=[]\n for b in block['body']:\n b['parent_block'] = block\n if b['block'] in ['function','subroutine']:\n if args is not None and b['name'] not in args:\n continue\n else:\n as=b['args']\n if b['name'] in skipfuncs:\n continue\n if onlyfuncs and b['name'] not in onlyfuncs:\n continue\n else: as=args\n b=postcrack(b,as,tab=tab+'\\t')\n if b['block']=='interface' and not b['body']:\n if not b.has_key('f2pyenhancements'):\n continue\n if string.replace(b['block'],' ','')=='pythonmodule':\n usermodules.append(b)\n else:\n if b['block']=='module':\n f90modulevars[b['name']] = b['vars']\n body.append(b)\n return body\ndef buildimplicitrules(block):\n setmesstext(block)\n implicitrules=defaultimplicitrules\n attrrules={}\n if block.has_key('implicit'):\n if block['implicit'] is None:\n implicitrules=None\n if verbose>1:\n outmess('buildimplicitrules: no implicit rules for routine %s.\\n'%`block['name']`)\n else:\n for k in block['implicit'].keys():\n if block['implicit'][k].get('typespec') not in ['static','automatic']:\n implicitrules[k]=block['implicit'][k]\n else:\n attrrules[k]=block['implicit'][k]['typespec']\n return implicitrules,attrrules\n\ndef myeval(e,g=None,l=None):\n r = eval(e,g,l)\n if type(r) in [type(0),type(0.0)]:\n return r\n raise ValueError,'r=%r' % (r)\n\ngetlincoef_re_1 = re.compile(r'\\A\\b\\w+\\b\\Z',re.I)\ndef getlincoef(e,xset): # e = a*x+b ; x in xset\n try:\n c = int(myeval(e,{},{}))\n return 0,c,None\n except: pass\n if getlincoef_re_1.match(e):\n return 1,0,e\n len_e = len(e)\n for x in xset:\n if len(x)>len_e: continue\n re_1 = re.compile(r'(?P.*?)\\b'+x+r'\\b(?P.*)',re.I)\n m = re_1.match(e)\n if m:\n try:\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),0,m1.group('after'))\n m1 = re_1.match(ee)\n b = myeval(ee,{},{})\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),1,m1.group('after'))\n m1 = re_1.match(ee)\n a = myeval(ee,{},{}) - b\n m1 = re_1.match(e)\n while m1:\n ee = '%s(%s)%s'%(m1.group('before'),0.5,m1.group('after'))\n m1 = re_1.match(ee)\n c = myeval(ee,{},{})\n if (a*0.5+b==c):\n return a,b,x\n except: pass\n break \n return None,None,None\n\n_varname_match = re.compile(r'\\A[a-z]\\w*\\Z').match\ndef getarrlen(dl,args,star='*'):\n edl = []\n try: edl.append(myeval(dl[0],{},{}))\n except: edl.append(dl[0])\n try: edl.append(myeval(dl[1],{},{}))\n except: edl.append(dl[1])\n if type(edl[0]) is type(0):\n p1 = 1-edl[0]\n if p1==0: d = str(dl[1])\n elif p1<0: d = '%s-%s'%(dl[1],-p1)\n else: d = '%s+%s'%(dl[1],p1)\n elif type(edl[1]) is type(0):\n p1 = 1+edl[1]\n if p1==0: d='-(%s)' % (dl[0])\n else: d='%s-(%s)' % (p1,dl[0])\n else: d = '%s-(%s)+1'%(dl[1],dl[0])\n try: return `myeval(d,{},{})`,None,None\n except: pass\n d1,d2=getlincoef(dl[0],args),getlincoef(dl[1],args)\n if None not in [d1[0],d2[0]]:\n if (d1[0],d2[0])==(0,0):\n return `d2[1]-d1[1]+1`,None,None\n b = d2[1] - d1[1] + 1\n d1 = (d1[0],0,d1[2])\n d2 = (d2[0],b,d2[2])\n if d1[0]==0 and d2[2] in args:\n if b<0: return '%s * %s - %s'%(d2[0],d2[2],-b),d2[2],'+%s)/(%s)'%(-b,d2[0])\n elif b: return '%s * %s + %s'%(d2[0],d2[2],b),d2[2],'-%s)/(%s)'%(b,d2[0])\n else: return '%s * %s'%(d2[0],d2[2]),d2[2],')/(%s)'%(d2[0])\n if d2[0]==0 and d1[2] in args:\n\n if b<0: return '%s * %s - %s'%(-d1[0],d1[2],-b),d1[2],'+%s)/(%s)'%(-b,-d1[0])\n elif b: return '%s * %s + %s'%(-d1[0],d1[2],b),d1[2],'-%s)/(%s)'%(b,-d1[0])\n else: return '%s * %s'%(-d1[0],d1[2]),d1[2],')/(%s)'%(-d1[0])\n if d1[2]==d2[2] and d1[2] in args:\n a = d2[0] - d1[0]\n if not a: return `b`,None,None\n if b<0: return '%s * %s - %s'%(a,d1[2],-b),d2[2],'+%s)/(%s)'%(-b,a)\n elif b: return '%s * %s + %s'%(a,d1[2],b),d2[2],'-%s)/(%s)'%(b,a)\n else: return '%s * %s'%(a,d1[2]),d2[2],')/(%s)'%(a)\n if d1[0]==d2[0]==1:\n c = str(d1[2])\n if c not in args:\n if _varname_match(c):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c))\n c = '(%s)'%c\n if b==0: d='%s-%s' % (d2[2],c)\n elif b<0: d='%s-%s-%s' % (d2[2],c,-b)\n else: d='%s-%s+%s' % (d2[2],c,b)\n elif d1[0]==0:\n c2 = str(d2[2])\n if c2 not in args:\n if _varname_match(c2):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c2))\n c2 = '(%s)'%c2\n if d2[0]==1: pass\n elif d2[0]==-1: c2='-%s' %c2\n else: c2='%s*%s'%(d2[0],c2)\n\n if b==0: d=c2\n elif b<0: d='%s-%s' % (c2,-b)\n else: d='%s+%s' % (c2,b)\n elif d2[0]==0:\n c1 = str(d1[2])\n if c1 not in args:\n if _varname_match(c1):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c1))\n c1 = '(%s)'%c1\n if d1[0]==1: c1='-%s'%c1\n elif d1[0]==-1: c1='+%s'%c1\n elif d1[0]<0: c1='+%s*%s'%(-d1[0],c1)\n else: c1 = '-%s*%s' % (d1[0],c1)\n\n if b==0: d=c1\n elif b<0: d='%s-%s' % (c1,-b)\n else: d='%s+%s' % (c1,b)\n else:\n c1 = str(d1[2])\n if c1 not in args:\n if _varname_match(c1):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c1))\n c1 = '(%s)'%c1\n if d1[0]==1: c1='-%s'%c1\n elif d1[0]==-1: c1='+%s'%c1\n elif d1[0]<0: c1='+%s*%s'%(-d1[0],c1)\n else: c1 = '-%s*%s' % (d1[0],c1)\n \n c2 = str(d2[2])\n if c2 not in args:\n if _varname_match(c2):\n outmess('\\tgetarrlen:variable \"%s\" undefined\\n' % (c2))\n c2 = '(%s)'%c2\n if d2[0]==1: pass\n elif d2[0]==-1: c2='-%s' %c2\n else: c2='%s*%s'%(d2[0],c2)\n\n if b==0: d='%s%s' % (c2,c1)\n elif b<0: d='%s%s-%s' % (c2,c1,-b)\n else: d='%s%s+%s' % (c2,c1,b)\n return d,None,None\n\nword_pattern = re.compile(r'\\b[a-z][\\w$]*\\b',re.I)\n\ndef _get_depend_dict(name, vars, deps):\n if vars.has_key(name):\n words = vars[name].get('depend',[])\n\n if vars[name].has_key('=') and not isstring(vars[name]):\n for word in word_pattern.findall(vars[name]['=']):\n if word not in words and vars.has_key(word):\n words.append(word)\n for word in words[:]:\n for w in deps.get(word,[]) \\\n or _get_depend_dict(word, vars, deps):\n if w not in words:\n words.append(w)\n else:\n outmess('_get_depend_dict: no dependence info for %s\\n' % (`name`))\n words = []\n deps[name] = words\n return words\n\ndef _calc_depend_dict(vars):\n names = vars.keys()\n depend_dict = {}\n for n in names:\n _get_depend_dict(n, vars, depend_dict)\n return depend_dict\n\ndef get_sorted_names(vars):\n \"\"\"\n \"\"\"\n depend_dict = _calc_depend_dict(vars)\n names = []\n for name in depend_dict.keys():\n if not depend_dict[name]:\n names.append(name)\n del depend_dict[name]\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n return [name for name in names if vars.has_key(name)]\n\ndef _kind_func(string):\n #XXX: return something sensible.\n if string[0] in \"'\\\"\":\n string = string[1:-1]\n if real16pattern.match(string):\n return 16\n elif real8pattern.match(string):\n return 8\n return 'kind('+string+')'\n\ndef _selected_int_kind_func(r):\n #XXX: This should be processor dependent\n m = 10**r\n if m<=2**8: return 1\n if m<=2**16: return 2\n if m<=2**32: return 4\n if m<=2**64: return 8\n if m<=2**128: return 16\n return -1\n\ndef get_parameters(vars, global_params={}):\n params = copy.copy(global_params)\n g_params = copy.copy(global_params)\n for name,func in [('kind',_kind_func),\n ('selected_int_kind',_selected_int_kind_func),\n ]:\n if not g_params.has_key(name):\n g_params[name] = func\n param_names = []\n for n in get_sorted_names(vars):\n if vars[n].has_key('attrspec') and 'parameter' in vars[n]['attrspec']:\n param_names.append(n)\n kind_re = re.compile(r'\\bkind\\s*\\(\\s*(?P.*)\\s*\\)',re.I)\n selected_int_kind_re = re.compile(r'\\bselected_int_kind\\s*\\(\\s*(?P.*)\\s*\\)',re.I)\n for n in param_names:\n if vars[n].has_key('='):\n v = vars[n]['=']\n if islogical(vars[n]):\n v = v.lower()\n for repl in [\n ('.false.','False'),\n ('.true.','True'),\n #TODO: test .eq., .neq., etc replacements.\n ]:\n v = v.replace(*repl)\n v = kind_re.sub(r'kind(\"\\1\")',v)\n v = selected_int_kind_re.sub(r'selected_int_kind(\\1)',v)\n if isinteger(vars[n]) and not selected_int_kind_re.match(v):\n v = v.split('_')[0]\n if isdouble(vars[n]):\n tt = list(v)\n for m in real16pattern.finditer(v):\n tt[m.start():m.end()] = list(\\\n v[m.start():m.end()].lower().replace('d', 'e'))\n v = string.join(tt,'')\n if iscomplex(vars[n]):\n if v[0]=='(' and v[-1]==')':\n l = markoutercomma(v[1:-1]).split('@,@')\n print n,params\n try:\n params[n] = eval(v,g_params,params)\n except Exception,msg:\n params[n] = v\n #print params\n outmess('get_parameters: got \"%s\" on %s\\n' % (msg,`v`))\n if isstring(vars[n]) and type(params[n]) is type(0):\n params[n] = chr(params[n])\n nl = string.lower(n)\n if nl!=n:\n params[nl] = params[n]\n else:\n print vars[n]\n outmess('get_parameters:parameter %s does not have value?!\\n'%(`n`))\n return params\n\ndef _eval_length(length,params):\n if length in ['(:)','(*)','*']:\n return '(*)'\n return _eval_scalar(length,params)\n\n_is_kind_number = re.compile('\\d+_').match\n\ndef _eval_scalar(value,params):\n if _is_kind_number(value):\n value = value.split('_')[0]\n try:\n value = str(eval(value,{},params))\n except (NameError, SyntaxError):\n return value\n except Exception,msg:\n errmess('\"%s\" in evaluating %r '\\\n '(available names: %s)\\n' \\\n % (msg,value,params.keys()))\n return value\n\ndef analyzevars(block):\n global f90modulevars\n setmesstext(block)\n implicitrules,attrrules=buildimplicitrules(block)\n vars=copy.copy(block['vars'])\n if block['block']=='function' and not vars.has_key(block['name']):\n vars[block['name']]={}\n if block['vars'].has_key(''):\n del vars['']\n if block['vars'][''].has_key('attrspec'):\n gen=block['vars']['']['attrspec']\n for n in vars.keys():\n for k in ['public','private']:\n if k in gen:\n vars[n]=setattrspec(vars[n],k)\n svars=[]\n args = block['args']\n for a in args:\n try:\n vars[a]\n svars.append(a)\n except KeyError:\n pass\n for n in vars.keys():\n if n not in args: svars.append(n)\n\n params = get_parameters(vars, get_useparameters(block))\n\n dep_matches = {}\n name_match = re.compile(r'\\w[\\w\\d_$]*').match\n for v in vars.keys():\n m = name_match(v)\n if m:\n n = v[m.start():m.end()]\n try:\n dep_matches[n]\n except KeyError:\n dep_matches[n] = re.compile(r'.*\\b%s\\b'%(v),re.I).match\n for n in svars:\n if n[0] in attrrules.keys():\n vars[n]=setattrspec(vars[n],attrrules[n[0]])\n if not vars[n].has_key('typespec'):\n if not(vars[n].has_key('attrspec') and 'external' in vars[n]['attrspec']):\n if implicitrules:\n ln0 = string.lower(n[0])\n for k in implicitrules[ln0].keys():\n if k=='typespec' and implicitrules[ln0][k]=='undefined':\n continue\n if not vars[n].has_key(k):\n vars[n][k]=implicitrules[ln0][k]\n elif k=='attrspec':\n for l in implicitrules[ln0][k]:\n vars[n]=setattrspec(vars[n],l)\n elif n in block['args']:\n outmess('analyzevars: typespec of variable %s is not defined in routine %s.\\n'%(`n`,block['name']))\n\n if vars[n].has_key('charselector'):\n if vars[n]['charselector'].has_key('len'):\n l = vars[n]['charselector']['len']\n try:\n l = str(eval(l,{},params))\n except:\n pass\n vars[n]['charselector']['len'] = l\n\n if vars[n].has_key('kindselector'):\n if vars[n]['kindselector'].has_key('kind'):\n l = vars[n]['kindselector']['kind']\n try:\n l = str(eval(l,{},params))\n except:\n pass\n vars[n]['kindselector']['kind'] = l\n\n savelindims = {}\n if vars[n].has_key('attrspec'):\n attr=vars[n]['attrspec']\n attr.reverse()\n vars[n]['attrspec']=[]\n dim,intent,depend,check,note=None,None,None,None,None\n for a in attr:\n if a[:9]=='dimension': dim=(string.strip(a[9:]))[1:-1]\n elif a[:6]=='intent': intent=(string.strip(a[6:]))[1:-1]\n elif a[:6]=='depend': depend=(string.strip(a[6:]))[1:-1]\n elif a[:5]=='check': check=(string.strip(a[5:]))[1:-1]\n elif a[:4]=='note': note=(string.strip(a[4:]))[1:-1]\n else: vars[n]=setattrspec(vars[n],a)\n if intent:\n if not vars[n].has_key('intent'): vars[n]['intent']=[]\n for c in map(string.strip,string.split(markoutercomma(intent),'@,@')):\n if not c in vars[n]['intent']:\n vars[n]['intent'].append(c)\n intent=None\n if note:\n note=string.replace(note,'\\\\n\\\\n','\\n\\n')\n note=string.replace(note,'\\\\n ','\\n')\n if not vars[n].has_key('note'): vars[n]['note']=[note]\n else: vars[n]['note'].append(note)\n note=None\n if depend is not None:\n if not vars[n].has_key('depend'): vars[n]['depend']=[]\n for c in rmbadname(map(string.strip,string.split(markoutercomma(depend),'@,@'))):\n if c not in vars[n]['depend']:\n vars[n]['depend'].append(c)\n depend=None\n if check is not None:\n if not vars[n].has_key('check'): vars[n]['check']=[]\n for c in map(string.strip,string.split(markoutercomma(check),'@,@')):\n if not c in vars[n]['check']:\n vars[n]['check'].append(c)\n check=None\n if dim and not vars[n].has_key('dimension'):\n vars[n]['dimension']=[]\n for d in rmbadname(map(string.strip,string.split(markoutercomma(dim),'@,@'))):\n star = '*'\n if d==':': star=':'\n if params.has_key(d):\n d = str(params[d])\n for p in params.keys():\n m = re.match(r'(?P.*?)\\b'+p+r'\\b(?P.*)',d,re.I)\n if m:\n #outmess('analyzevars:replacing parameter %s in %s (dimension of %s) with %s\\n'%(`p`,`d`,`n`,`params[p]`))\n d = m.group('before')+str(params[p])+m.group('after')\n if d==star:\n dl = [star]\n else:\n dl=string.split(markoutercomma(d,':'),'@:@')\n if len(dl)==2 and '*' in dl: # e.g. dimension(5:*)\n dl = ['*']\n d = '*'\n if len(dl)==1 and not dl[0]==star: dl = ['1',dl[0]]\n if len(dl)==2:\n d,v,di = getarrlen(dl,block['vars'].keys())\n if d[:4] == '1 * ': d = d[4:]\n if di and di[-4:] == '/(1)': di = di[:-4]\n if v: savelindims[d] = v,di\n vars[n]['dimension'].append(d)\n if vars[n].has_key('dimension'):\n if isintent_c(vars[n]):\n shape_macro = 'shape'\n else:\n shape_macro = 'shape'#'fshape'\n if isstringarray(vars[n]):\n if vars[n].has_key('charselector'):\n d = vars[n]['charselector']\n if d.has_key('*'):\n d = d['*']\n errmess('analyzevars: character array \"character*%s %s(%s)\" is considered as \"character %s(%s)\"; \"intent(c)\" is forced.\\n'\\\n %(d,n,\n ','.join(vars[n]['dimension']),\n n,','.join(vars[n]['dimension']+[d])))\n vars[n]['dimension'].append(d)\n del vars[n]['charselector']\n if not vars[n].has_key('intent'):\n vars[n]['intent'] = []\n if 'c' not in vars[n]['intent']:\n vars[n]['intent'].append('c')\n else:\n errmess(\"analyzevars: charselector=%r unhandled.\" % (d))\n if not vars[n].has_key('check') and block.has_key('args') and n in block['args']:\n flag=not vars[n].has_key('depend')\n if flag: vars[n]['depend']=[]\n vars[n]['check']=[]\n if vars[n].has_key('dimension'):\n #/----< no check\n #vars[n]['check'].append('rank(%s)==%s'%(n,len(vars[n]['dimension'])))\n i=-1; ni=len(vars[n]['dimension'])\n for d in vars[n]['dimension']:\n ddeps=[] # dependecies of 'd'\n ad=''\n pd=''\n #origd = d\n if not vars.has_key(d):\n if savelindims.has_key(d):\n pd,ad='(',savelindims[d][1]\n d = savelindims[d][0]\n else:\n for r in block['args']:\n #for r in block['vars'].keys():\n if not vars.has_key(r): continue\n if re.match(r'.*?\\b'+r+r'\\b',d,re.I):\n ddeps.append(r)\n if vars.has_key(d):\n if vars[d].has_key('attrspec'):\n for aa in vars[d]['attrspec']:\n if aa[:6]=='depend':\n ddeps=ddeps+string.split((string.strip(aa[6:]))[1:-1],',')\n if vars[d].has_key('depend'):\n ddeps=ddeps+vars[d]['depend']\n i=i+1\n if vars.has_key(d) and (not vars[d].has_key('depend')) \\\n and (not vars[d].has_key('=')) and (d not in vars[n]['depend']) \\\n and l_or(isintent_in,isintent_inout,isintent_inplace)(vars[n]):\n vars[d]['depend']=[n]\n if ni>1:\n vars[d]['=']='%s%s(%s,%s)%s'% (pd,shape_macro,n,i,ad)\n else:\n vars[d]['=']='%slen(%s)%s'% (pd,n,ad)\n # /---< no check\n if 1 and not vars[d].has_key('check'):\n if ni>1:\n vars[d]['check']=['%s%s(%s,%i)%s==%s'\\\n %(pd,shape_macro,n,i,ad,d)]\n else:\n vars[d]['check']=['%slen(%s)%s>=%s'%(pd,n,ad,d)]\n if not vars[d].has_key('attrspec'): vars[d]['attrspec']=['optional']\n if ('optional' not in vars[d]['attrspec']) and\\\n ('required' not in vars[d]['attrspec']):\n vars[d]['attrspec'].append('optional')\n elif d not in ['*',':']:\n #/----< no check \n #if ni>1: vars[n]['check'].append('shape(%s,%i)==%s'%(n,i,d))\n #else: vars[n]['check'].append('len(%s)>=%s'%(n,d))\n if flag: \n if vars.has_key(d):\n if n not in ddeps:\n vars[n]['depend'].append(d)\n else:\n vars[n]['depend'] = vars[n]['depend'] + ddeps\n elif isstring(vars[n]):\n length='1'\n if vars[n].has_key('charselector'):\n if vars[n]['charselector'].has_key('*'):\n length = _eval_length(vars[n]['charselector']['*'],\n params)\n vars[n]['charselector']['*']=length\n elif vars[n]['charselector'].has_key('len'):\n length = _eval_length(vars[n]['charselector']['len'],\n params)\n del vars[n]['charselector']['len']\n vars[n]['charselector']['*']=length\n\n if not vars[n]['check']: del vars[n]['check']\n if flag and not vars[n]['depend']: del vars[n]['depend']\n if vars[n].has_key('='):\n if not vars[n].has_key('attrspec'): vars[n]['attrspec']=[]\n if ('optional' not in vars[n]['attrspec']) and \\\n ('required' not in vars[n]['attrspec']):\n vars[n]['attrspec'].append('optional')\n if not vars[n].has_key('depend'):\n vars[n]['depend']=[]\n for v,m in dep_matches.items():\n if m(vars[n]['=']): vars[n]['depend'].append(v)\n if not vars[n]['depend']: del vars[n]['depend']\n if isscalar(vars[n]):\n vars[n]['='] = _eval_scalar(vars[n]['='],params)\n\n for n in vars.keys():\n if n==block['name']: # n is block name\n if vars[n].has_key('note'):\n block['note']=vars[n]['note']\n if block['block']=='function':\n if block.has_key('result') and vars.has_key(block['result']):\n vars[n]=appenddecl(vars[n],vars[block['result']])\n if block.has_key('prefix'):\n pr=block['prefix']; ispure=0; isrec=1\n pr1=string.replace(pr,'pure','')\n ispure=(not pr==pr1)\n pr=string.replace(pr1,'recursive','')\n isrec=(not pr==pr1)\n m=typespattern[0].match(pr)\n if m:\n typespec,selector,attr,edecl=cracktypespec0(m.group('this'),m.group('after'))\n kindselect,charselect,typename=cracktypespec(typespec,selector)\n vars[n]['typespec']=typespec\n if kindselect:\n if kindselect.has_key('kind'):\n try:\n kindselect['kind'] = eval(kindselect['kind'],{},params)\n except:\n pass\n vars[n]['kindselector']=kindselect\n if charselect: vars[n]['charselector']=charselect\n if typename: vars[n]['typename']=typename\n if ispure: vars[n]=setattrspec(vars[n],'pure')\n if isrec: vars[n]=setattrspec(vars[n],'recursive')\n else:\n outmess('analyzevars: prefix (%s) were not used\\n'%`block['prefix']`)\n if not block['block'] in ['module','pythonmodule','python module','block data']:\n if block.has_key('commonvars'):\n neededvars=copy.copy(block['args']+block['commonvars'])\n else:\n neededvars=copy.copy(block['args'])\n for n in vars.keys():\n if l_or(isintent_callback,isintent_aux)(vars[n]):\n neededvars.append(n)\n if block.has_key('entry'):\n neededvars.extend(block['entry'].keys())\n for k in block['entry'].keys():\n for n in block['entry'][k]:\n if n not in neededvars:\n neededvars.append(n)\n if block['block']=='function':\n if block.has_key('result'):\n neededvars.append(block['result'])\n else:\n neededvars.append(block['name'])\n if block['block'] in ['subroutine','function']:\n name = block['name']\n if vars.has_key(name) and vars[name].has_key('intent'):\n block['intent'] = vars[name]['intent']\n if block['block'] == 'type':\n neededvars.extend(vars.keys())\n for n in vars.keys():\n if n not in neededvars:\n del vars[n]\n return vars\nanalyzeargs_re_1 = re.compile(r'\\A[a-z]+[\\w$]*\\Z',re.I)\ndef analyzeargs(block):\n setmesstext(block)\n implicitrules,attrrules=buildimplicitrules(block)\n if not block.has_key('args'): block['args']=[]\n args=[]\n re_1 = analyzeargs_re_1\n for a in block['args']:\n if not re_1.match(a): # `a` is an expression\n at=determineexprtype(a,block['vars'],implicitrules)\n na='e_'\n for c in a:\n if c not in string.lowercase+string.digits: c='_'\n na=na+c\n if na[-1]=='_': na=na+'e'\n else: na=na+'_e'\n a=na\n while block['vars'].has_key(a) or a in block['args']: a=a+'r'\n block['vars'][a]=at \n args.append(a)\n if not block['vars'].has_key(a):\n block['vars'][a]={}\n if block.has_key('externals') and a in block['externals']+block['interfaced']:\n block['vars'][a]=setattrspec(block['vars'][a],'external')\n block['args']=args\n\n if block.has_key('entry'):\n for k,args1 in block['entry'].items():\n for a in args1:\n if not block['vars'].has_key(a):\n block['vars'][a]={}\n\n for b in block['body']:\n if b['name'] in args:\n if not block.has_key('externals'): block['externals']=[]\n if b['name'] not in block['externals']:\n block['externals'].append(b['name'])\n if block.has_key('result') and not block['vars'].has_key(block['result']):\n block['vars'][block['result']]={}\n return block\ndetermineexprtype_re_1 = re.compile(r'\\A\\(.+?[,].+?\\)\\Z',re.I)\ndetermineexprtype_re_2 = re.compile(r'\\A[+-]?\\d+(_(P[\\w]+)|)\\Z',re.I)\ndetermineexprtype_re_3 = re.compile(r'\\A[+-]?[\\d.]+[\\d+-de.]*(_(P[\\w]+)|)\\Z',re.I)\ndetermineexprtype_re_4 = re.compile(r'\\A\\(.*\\)\\Z',re.I)\ndetermineexprtype_re_5 = re.compile(r'\\A(?P\\w+)\\s*\\(.*?\\)\\s*\\Z',re.I)\ndef _ensure_exprdict(r):\n if type(r) is type(0):\n return {'typespec':'integer'}\n if type(r) is type(0.0):\n return {'typespec':'real'}\n if type(r) is type(0j):\n return {'typespec':'complex'}\n assert type(r) is type({}),`r`\n return r\n\ndef determineexprtype(expr,vars,rules={}):\n if vars.has_key(expr):\n return _ensure_exprdict(vars[expr])\n expr=string.strip(expr)\n if determineexprtype_re_1.match(expr):\n return {'typespec':'complex'}\n m=determineexprtype_re_2.match(expr)\n if m:\n if m.groupdict().has_key('name') and m.group('name'):\n outmess('determineexprtype: selected kind types not supported (%s)\\n'%`expr`)\n return {'typespec':'integer'}\n m = determineexprtype_re_3.match(expr)\n if m:\n if m.groupdict().has_key('name') and m.group('name'):\n outmess('determineexprtype: selected kind types not supported (%s)\\n'%`expr`)\n return {'typespec':'real'}\n for op in ['+','-','*','/']:\n for e in map(string.strip,string.split(markoutercomma(expr,comma=op),'@'+op+'@')):\n if vars.has_key(e):\n return _ensure_exprdict(vars[e])\n t={}\n if determineexprtype_re_4.match(expr): # in parenthesis\n t=determineexprtype(expr[1:-1],vars,rules)\n else:\n m = determineexprtype_re_5.match(expr)\n if m:\n rn=m.group('name')\n t=determineexprtype(m.group('name'),vars,rules)\n if t and t.has_key('attrspec'): del t['attrspec']\n if not t:\n if rules.has_key(rn[0]):\n return _ensure_exprdict(rules[rn[0]])\n if expr[0] in '\\'\"':\n return {'typespec':'character','charselector':{'*':'*'}}\n if not t:\n outmess('determineexprtype: could not determine expressions (%s) type.\\n'%(`expr`))\n return t\n######\ndef crack2fortrangen(block,tab='\\n'):\n setmesstext(block)\n ret=''\n if type(block) is type([]):\n for g in block:\n ret=ret+crack2fortrangen(g,tab)\n return ret\n prefix=''\n name=''\n args=''\n blocktype=block['block']\n if blocktype=='program': return ''\n al=[]\n if block.has_key('name'): name=block['name']\n if block.has_key('args'):\n vars = block['vars']\n al = [a for a in block['args'] if not isintent_callback(vars[a])]\n if block['block']=='function' or al:\n args='(%s)'%string.join(al,',')\n f2pyenhancements = ''\n if block.has_key('f2pyenhancements'):\n for k in block['f2pyenhancements'].keys():\n f2pyenhancements = '%s%s%s %s'%(f2pyenhancements,tab+tabchar,k,block['f2pyenhancements'][k])\n intent_lst = block.get('intent',[])[:]\n if blocktype=='function' and 'callback' in intent_lst:\n intent_lst.remove('callback')\n if intent_lst:\n f2pyenhancements = '%s%sintent(%s) %s'%\\\n (f2pyenhancements,tab+tabchar,\n string.join(intent_lst,','),name)\n use=''\n if block.has_key('use'):\n use=use2fortran(block['use'],tab+tabchar)\n common=''\n if block.has_key('common'):\n common=common2fortran(block['common'],tab+tabchar)\n if name=='unknown_interface': name=''\n result=''\n if block.has_key('result'):\n result=' result (%s)'%block['result']\n if block['result'] not in al:\n al.append(block['result'])\n #if block.has_key('prefix'): prefix=block['prefix']+' '\n body=crack2fortrangen(block['body'],tab+tabchar)\n vars=vars2fortran(block,block['vars'],al,tab+tabchar)\n mess=''\n if block.has_key('from'):\n mess='! in %s'%block['from']\n if block.has_key('entry'):\n entry_stmts = ''\n for k,i in block['entry'].items():\n entry_stmts = '%s%sentry %s(%s)' \\\n % (entry_stmts,tab+tabchar,k,string.join(i,','))\n body = body + entry_stmts\n if blocktype=='block data' and name=='_BLOCK_DATA_':\n name = ''\n ret='%s%s%s %s%s%s %s%s%s%s%s%s%send %s %s'%(tab,prefix,blocktype,name,args,result,mess,f2pyenhancements,use,vars,common,body,tab,blocktype,name)\n return ret\ndef common2fortran(common,tab=''):\n ret=''\n for k in common.keys():\n if k=='_BLNK_':\n ret='%s%scommon %s'%(ret,tab,string.join(common[k],','))\n else:\n ret='%s%scommon /%s/ %s'%(ret,tab,k,string.join(common[k],','))\n return ret\ndef use2fortran(use,tab=''):\n ret=''\n for m in use.keys():\n ret='%s%suse %s,'%(ret,tab,m)\n if use[m]=={}:\n if ret and ret[-1]==',': ret=ret[:-1]\n continue\n if use[m].has_key('only') and use[m]['only']:\n ret='%s,only:'%(ret)\n if use[m].has_key('map') and use[m]['map']:\n c=' '\n for k in use[m]['map'].keys():\n if k==use[m]['map'][k]:\n ret='%s%s%s'%(ret,c,k); c=','\n else:\n ret='%s%s%s=>%s'%(ret,c,k,use[m]['map'][k]); c=','\n if ret and ret[-1]==',': ret=ret[:-1]\n return ret\ndef true_intent_list(var):\n lst = var['intent']\n ret = []\n for intent in lst:\n try:\n exec('c = isintent_%s(var)' % intent)\n except NameError:\n c = 0\n if c:\n ret.append(intent)\n return ret\ndef vars2fortran(block,vars,args,tab=''):\n \"\"\"\n TODO:\n public sub\n ...\n \"\"\"\n setmesstext(block)\n ret=''\n nout=[]\n for a in args:\n if block['vars'].has_key(a): nout.append(a)\n if block.has_key('commonvars'):\n for a in block['commonvars']:\n if vars.has_key(a):\n if a not in nout: nout.append(a)\n else: errmess('vars2fortran: Confused?!: \"%s\" is not defined in vars.\\n'%a)\n if block.has_key('varnames'):\n nout.extend(block['varnames'])\n for a in vars.keys():\n if a not in nout: nout.append(a)\n for a in nout:\n if vars[a].has_key('depend'):\n for d in vars[a]['depend']:\n if vars.has_key(d) and vars[d].has_key('depend') and a in vars[d]['depend']:\n errmess('vars2fortran: Warning: cross-dependence between variables \"%s\" and \"%s\"\\n'%(a,d))\n if block.has_key('externals') and a in block['externals']:\n if isintent_callback(vars[a]):\n ret='%s%sintent(callback) %s'%(ret,tab,a)\n ret='%s%sexternal %s'%(ret,tab,a)\n if isoptional(vars[a]):\n ret='%s%soptional %s'%(ret,tab,a)\n if vars.has_key(a) and not vars[a].has_key('typespec'):\n continue\n cont=1\n for b in block['body']:\n if a==b['name'] and b['block']=='function': cont=0;break\n if cont: continue\n if not vars.has_key(a):\n show(vars)\n outmess('vars2fortran: No definition for argument \"%s\".\\n'%a)\n continue\n if a==block['name'] and not block['block']=='function':\n continue\n if not vars[a].has_key('typespec'):\n if vars[a].has_key('attrspec') and 'external' in vars[a]['attrspec']:\n if a in args:\n ret='%s%sexternal %s'%(ret,tab,a)\n continue\n show(vars[a])\n outmess('vars2fortran: No typespec for argument \"%s\".\\n'%a)\n continue\n vardef=vars[a]['typespec']\n if vardef=='type' and vars[a].has_key('typename'):\n vardef='%s(%s)'%(vardef,vars[a]['typename'])\n selector={}\n if vars[a].has_key('kindselector'): selector=vars[a]['kindselector']\n elif vars[a].has_key('charselector'): selector=vars[a]['charselector']\n if selector.has_key('*'):\n if selector['*'] in ['*',':']:\n vardef='%s*(%s)'%(vardef,selector['*'])\n else:\n vardef='%s*%s'%(vardef,selector['*'])\n else:\n if selector.has_key('len'):\n vardef='%s(len=%s'%(vardef,selector['len'])\n if selector.has_key('kind'):\n vardef='%s,kind=%s)'%(vardef,selector['kind'])\n else:\n vardef='%s)'%(vardef)\n elif selector.has_key('kind'):\n vardef='%s(kind=%s)'%(vardef,selector['kind'])\n c=' '\n if vars[a].has_key('attrspec'):\n attr=[]\n for l in vars[a]['attrspec']:\n if l not in ['external']:\n attr.append(l)\n if attr:\n vardef='%s %s'%(vardef,string.join(attr,','))\n c=','\n if vars[a].has_key('dimension'):\n# if not isintent_c(vars[a]):\n# vars[a]['dimension'].reverse()\n vardef='%s%sdimension(%s)'%(vardef,c,string.join(vars[a]['dimension'],','))\n c=','\n if vars[a].has_key('intent'):\n lst = true_intent_list(vars[a])\n if lst:\n vardef='%s%sintent(%s)'%(vardef,c,string.join(lst,','))\n c=','\n if vars[a].has_key('check'):\n vardef='%s%scheck(%s)'%(vardef,c,string.join(vars[a]['check'],','))\n c=','\n if vars[a].has_key('depend'):\n vardef='%s%sdepend(%s)'%(vardef,c,string.join(vars[a]['depend'],','))\n c=','\n if vars[a].has_key('='):\n v = vars[a]['=']\n if vars[a]['typespec'] in ['complex','double complex']:\n try:\n v = eval(v)\n v = '(%s,%s)' % (v.real,v.imag)\n except:\n pass\n vardef='%s :: %s=%s'%(vardef,a,v)\n else:\n vardef='%s :: %s'%(vardef,a)\n ret='%s%s%s'%(ret,tab,vardef)\n return ret\n######\n\ndef crackfortran(files):\n global usermodules\n outmess('Reading fortran codes...\\n',0)\n readfortrancode(files,crackline)\n outmess('Post-processing...\\n',0)\n usermodules=[]\n postlist=postcrack(grouplist[0])\n outmess('Post-processing (stage 2)...\\n',0)\n postlist=postcrack2(postlist)\n return usermodules+postlist\ndef crack2fortran(block):\n global f2py_version\n pyf=crack2fortrangen(block)+'\\n'\n header=\"\"\"! -*- f90 -*-\n! Note: the context of this file is case sensitive.\n\"\"\"\n footer=\"\"\"\n! This file was auto-generated with f2py (version:%s).\n! See http://cens.ioc.ee/projects/f2py2e/\n\"\"\"%(f2py_version)\n return header+pyf+footer\n\nif __name__ == \"__main__\":\n files=[]\n funcs=[]\n f=1;f2=0;f3=0\n showblocklist=0\n for l in sys.argv[1:]:\n if l=='': pass\n elif l[0]==':':\n f=0\n elif l=='-quiet':\n quiet=1\n verbose=0\n elif l=='-verbose':\n verbose=2\n quiet=0\n elif l=='-fix':\n if strictf77:\n outmess('Use option -f90 before -fix if Fortran 90 code is in fix form.\\n',0)\n skipemptyends=1\n sourcecodeform='fix'\n elif l=='-skipemptyends':\n skipemptyends=1\n elif l=='--ignore-contains':\n ignorecontains=1\n elif l=='-f77':\n strictf77=1\n sourcecodeform='fix'\n elif l=='-f90':\n strictf77=0\n sourcecodeform='free'\n skipemptyends=1\n elif l=='-h':\n f2=1\n elif l=='-show':\n showblocklist=1\n elif l=='-m':\n f3=1\n elif l[0]=='-':\n errmess('Unknown option %s\\n'%`l`)\n elif f2:\n f2=0\n pyffilename=l\n elif f3:\n f3=0\n f77modulename=l\n elif f:\n try:\n open(l).close()\n files.append(l)\n except IOError,detail:\n errmess('IOError: %s\\n'%str(detail))\n else:\n funcs.append(l)\n if not strictf77 and f77modulename and not skipemptyends:\n outmess(\"\"\"\\\n Warning: You have specifyied module name for non Fortran 77 code\n that should not need one (expect if you are scanning F90 code\n for non module blocks but then you should use flag -skipemptyends\n and also be sure that the files do not contain programs without program statement).\n\"\"\",0)\n\n postlist=crackfortran(files,funcs)\n if pyffilename:\n outmess('Writing fortran code to file %s\\n'%`pyffilename`,0)\n pyf=crack2fortran(postlist)\n f=open(pyffilename,'w')\n f.write(pyf)\n f.close()\n if showblocklist:\n show(postlist)\n", + "methods": [ + { + "name": "outmess", + "long_name": "outmess( line , flag = 1 )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 4, + "token_count": 39, + "parameters": [ + "line", + "flag" + ], + "start_line": 186, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rmbadname1", + "long_name": "rmbadname1( name )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 2, + "token_count": 33, + "parameters": [ + "name" + ], + "start_line": 209, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "undo_rmbadname1", + "long_name": "undo_rmbadname1( name )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "name" + ], + "start_line": 216, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "getextension", + "long_name": "getextension( name )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 4, + "token_count": 53, + "parameters": [ + "name" + ], + "start_line": 224, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "crackfortran.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 236, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "readfortrancode", + "long_name": "readfortrancode( ffile , dowithline = show , istop = 1 )", + "filename": "crackfortran.py", + "nloc": 164, + "complexity": 57, + "token_count": 1156, + "parameters": [ + "ffile", + "dowithline", + "istop" + ], + "start_line": 261, + "end_line": 435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 175, + "top_nesting_level": 0 + }, + { + "name": "_simplifyargs", + "long_name": "_simplifyargs( argsline )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 56, + "parameters": [ + "argsline" + ], + "start_line": 483, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "crackline", + "long_name": "crackline( line , reset = 0 )", + "filename": "crackfortran.py", + "nloc": 121, + "complexity": 41, + "token_count": 874, + "parameters": [ + "line", + "reset" + ], + "start_line": 492, + "end_line": 619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 128, + "top_nesting_level": 0 + }, + { + "name": "markouterparen", + "long_name": "markouterparen( line )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 6, + "token_count": 68, + "parameters": [ + "line" + ], + "start_line": 621, + "end_line": 631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "markoutercomma", + "long_name": "markoutercomma( line , comma = ',' )", + "filename": "crackfortran.py", + "nloc": 20, + "complexity": 13, + "token_count": 132, + "parameters": [ + "line", + "comma" + ], + "start_line": 632, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "unmarkouterparen", + "long_name": "unmarkouterparen( line )", + "filename": "crackfortran.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "line" + ], + "start_line": 652, + "end_line": 654, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "appenddecl", + "long_name": "appenddecl( decl , decl2 , force = 1 )", + "filename": "crackfortran.py", + "nloc": 23, + "complexity": 17, + "token_count": 189, + "parameters": [ + "decl", + "decl2", + "force" + ], + "start_line": 655, + "end_line": 677, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_is_intent_callback", + "long_name": "_is_intent_callback( vdecl )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 3, + "token_count": 30, + "parameters": [ + "vdecl" + ], + "start_line": 686, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_resolvenameargspattern", + "long_name": "_resolvenameargspattern( line )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 77, + "parameters": [ + "line" + ], + "start_line": 692, + "end_line": 698, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "analyzeline", + "long_name": "analyzeline( m , case , line )", + "filename": "crackfortran.py", + "nloc": 413, + "complexity": 161, + "token_count": 3998, + "parameters": [ + "m", + "case", + "line" + ], + "start_line": 700, + "end_line": 1130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 431, + "top_nesting_level": 0 + }, + { + "name": "appendmultiline", + "long_name": "appendmultiline( group , context_name , ml )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 3, + "token_count": 57, + "parameters": [ + "group", + "context_name", + "ml" + ], + "start_line": 1132, + "end_line": 1139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cracktypespec0", + "long_name": "cracktypespec0( typespec , ll )", + "filename": "crackfortran.py", + "nloc": 20, + "complexity": 7, + "token_count": 185, + "parameters": [ + "typespec", + "ll" + ], + "start_line": 1141, + "end_line": 1160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "removespaces", + "long_name": "removespaces( expr )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 6, + "token_count": 97, + "parameters": [ + "expr" + ], + "start_line": 1167, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "markinnerspaces", + "long_name": "markinnerspaces( line )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 10, + "token_count": 129, + "parameters": [ + "line" + ], + "start_line": 1177, + "end_line": 1192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "updatevars", + "long_name": "updatevars( typespec , selector , attrspec , entitydecl )", + "filename": "crackfortran.py", + "nloc": 120, + "complexity": 61, + "token_count": 1215, + "parameters": [ + "typespec", + "selector", + "attrspec", + "entitydecl" + ], + "start_line": 1193, + "end_line": 1313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 121, + "top_nesting_level": 0 + }, + { + "name": "cracktypespec", + "long_name": "cracktypespec( typespec , selector )", + "filename": "crackfortran.py", + "nloc": 45, + "complexity": 17, + "token_count": 346, + "parameters": [ + "typespec", + "selector" + ], + "start_line": 1315, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "setattrspec", + "long_name": "setattrspec( decl , attr , force = 0 )", + "filename": "crackfortran.py", + "nloc": 19, + "complexity": 14, + "token_count": 167, + "parameters": [ + "decl", + "attr", + "force" + ], + "start_line": 1361, + "end_line": 1379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setkindselector", + "long_name": "setkindselector( decl , sel , force = 0 )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 7, + "token_count": 79, + "parameters": [ + "decl", + "sel", + "force" + ], + "start_line": 1380, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "setcharselector", + "long_name": "setcharselector( decl , sel , force = 0 )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 7, + "token_count": 79, + "parameters": [ + "decl", + "sel", + "force" + ], + "start_line": 1390, + "end_line": 1399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "getblockname", + "long_name": "getblockname( block , unknown = 'unknown' )", + "filename": "crackfortran.py", + "nloc": 3, + "complexity": 2, + "token_count": 24, + "parameters": [ + "block", + "unknown" + ], + "start_line": 1400, + "end_line": 1402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "setmesstext", + "long_name": "setmesstext( block )", + "filename": "crackfortran.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "block" + ], + "start_line": 1404, + "end_line": 1407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "get_usedict", + "long_name": "get_usedict( block )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "block" + ], + "start_line": 1409, + "end_line": 1415, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "get_useparameters", + "long_name": "get_useparameters( block , param_map = None )", + "filename": "crackfortran.py", + "nloc": 23, + "complexity": 9, + "token_count": 132, + "parameters": [ + "block", + "param_map" + ], + "start_line": 1417, + "end_line": 1440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "postcrack2", + "long_name": "postcrack2( block , tab = '' , param_map = None )", + "filename": "crackfortran.py", + "nloc": 30, + "complexity": 12, + "token_count": 215, + "parameters": [ + "block", + "tab", + "param_map" + ], + "start_line": 1442, + "end_line": 1474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "postcrack", + "long_name": "postcrack( block , args = None , tab = '' )", + "filename": "crackfortran.py", + "nloc": 76, + "complexity": 35, + "token_count": 639, + "parameters": [ + "block", + "args", + "tab" + ], + "start_line": 1476, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "sortvarnames", + "long_name": "sortvarnames( vars )", + "filename": "crackfortran.py", + "nloc": 31, + "complexity": 9, + "token_count": 172, + "parameters": [ + "vars" + ], + "start_line": 1566, + "end_line": 1598, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "analyzecommon", + "long_name": "analyzecommon( block )", + "filename": "crackfortran.py", + "nloc": 32, + "complexity": 11, + "token_count": 306, + "parameters": [ + "block" + ], + "start_line": 1600, + "end_line": 1631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "analyzebody", + "long_name": "analyzebody( block , args , tab = '' )", + "filename": "crackfortran.py", + "nloc": 27, + "complexity": 13, + "token_count": 193, + "parameters": [ + "block", + "args", + "tab" + ], + "start_line": 1632, + "end_line": 1658, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "buildimplicitrules", + "long_name": "buildimplicitrules( block )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 6, + "token_count": 119, + "parameters": [ + "block" + ], + "start_line": 1659, + "end_line": 1674, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "myeval", + "long_name": "myeval( e , g = None , l = None )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 2, + "token_count": 53, + "parameters": [ + "e", + "g", + "l" + ], + "start_line": 1676, + "end_line": 1680, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "getlincoef", + "long_name": "getlincoef( e , xset )", + "filename": "crackfortran.py", + "nloc": 34, + "complexity": 11, + "token_count": 287, + "parameters": [ + "e", + "xset" + ], + "start_line": 1683, + "end_line": 1716, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "getarrlen", + "long_name": "getarrlen( dl , args , star = '*' )", + "filename": "crackfortran.py", + "nloc": 95, + "complexity": 55, + "token_count": 1295, + "parameters": [ + "dl", + "args", + "star" + ], + "start_line": 1719, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 100, + "top_nesting_level": 0 + }, + { + "name": "_get_depend_dict", + "long_name": "_get_depend_dict( name , vars , deps )", + "filename": "crackfortran.py", + "nloc": 17, + "complexity": 11, + "token_count": 153, + "parameters": [ + "name", + "vars", + "deps" + ], + "start_line": 1822, + "end_line": 1839, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_calc_depend_dict", + "long_name": "_calc_depend_dict( vars )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "vars" + ], + "start_line": 1841, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "get_sorted_names", + "long_name": "get_sorted_names( vars )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 10, + "token_count": 111, + "parameters": [ + "vars" + ], + "start_line": 1848, + "end_line": 1865, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_kind_func", + "long_name": "_kind_func( string )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 4, + "token_count": 48, + "parameters": [ + "string" + ], + "start_line": 1867, + "end_line": 1875, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_selected_int_kind_func", + "long_name": "_selected_int_kind_func( r )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 6, + "token_count": 58, + "parameters": [ + "r" + ], + "start_line": 1877, + "end_line": 1885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "get_parameters", + "long_name": "get_parameters( vars , global_params = { } )", + "filename": "crackfortran.py", + "nloc": 52, + "complexity": 21, + "token_count": 482, + "parameters": [ + "vars", + "global_params" + ], + "start_line": 1887, + "end_line": 1940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_eval_length", + "long_name": "_eval_length( length , params )", + "filename": "crackfortran.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "length", + "params" + ], + "start_line": 1942, + "end_line": 1945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_eval_scalar", + "long_name": "_eval_scalar( value , params )", + "filename": "crackfortran.py", + "nloc": 12, + "complexity": 4, + "token_count": 75, + "parameters": [ + "value", + "params" + ], + "start_line": 1949, + "end_line": 1960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "analyzevars", + "long_name": "analyzevars( block )", + "filename": "crackfortran.py", + "nloc": 291, + "complexity": 158, + "token_count": 3132, + "parameters": [ + "block" + ], + "start_line": 1962, + "end_line": 2268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 307, + "top_nesting_level": 0 + }, + { + "name": "analyzeargs", + "long_name": "analyzeargs( block )", + "filename": "crackfortran.py", + "nloc": 37, + "complexity": 22, + "token_count": 370, + "parameters": [ + "block" + ], + "start_line": 2270, + "end_line": 2308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_ensure_exprdict", + "long_name": "_ensure_exprdict( r )", + "filename": "crackfortran.py", + "nloc": 9, + "complexity": 4, + "token_count": 75, + "parameters": [ + "r" + ], + "start_line": 2314, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "determineexprtype", + "long_name": "determineexprtype( expr , vars , rules = { } )", + "filename": "crackfortran.py", + "nloc": 37, + "complexity": 20, + "token_count": 340, + "parameters": [ + "expr", + "vars", + "rules" + ], + "start_line": 2324, + "end_line": 2360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "crack2fortrangen", + "long_name": "crack2fortrangen( block , tab = '\\n' )", + "filename": "crackfortran.py", + "nloc": 57, + "complexity": 25, + "token_count": 485, + "parameters": [ + "block", + "tab" + ], + "start_line": 2362, + "end_line": 2419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "common2fortran", + "long_name": "common2fortran( common , tab = '' )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 3, + "token_count": 74, + "parameters": [ + "common", + "tab" + ], + "start_line": 2420, + "end_line": 2427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "use2fortran", + "long_name": "use2fortran( use , tab = '' )", + "filename": "crackfortran.py", + "nloc": 18, + "complexity": 13, + "token_count": 202, + "parameters": [ + "use", + "tab" + ], + "start_line": 2428, + "end_line": 2445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "true_intent_list", + "long_name": "true_intent_list( var )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 4, + "token_count": 45, + "parameters": [ + "var" + ], + "start_line": 2446, + "end_line": 2456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "vars2fortran", + "long_name": "vars2fortran( block , vars , args , tab = '' )", + "filename": "crackfortran.py", + "nloc": 102, + "complexity": 54, + "token_count": 933, + "parameters": [ + "block", + "vars", + "args", + "tab" + ], + "start_line": 2457, + "end_line": 2565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "crackfortran", + "long_name": "crackfortran( files )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 1, + "token_count": 54, + "parameters": [ + "files" + ], + "start_line": 2568, + "end_line": 2577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "crack2fortran", + "long_name": "crack2fortran( block )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 1, + "token_count": 31, + "parameters": [ + "block" + ], + "start_line": 2578, + "end_line": 2588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "outmess", + "long_name": "outmess( line , flag = 1 )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 4, + "token_count": 39, + "parameters": [ + "line", + "flag" + ], + "start_line": 186, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "rmbadname1", + "long_name": "rmbadname1( name )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 2, + "token_count": 33, + "parameters": [ + "name" + ], + "start_line": 209, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "undo_rmbadname1", + "long_name": "undo_rmbadname1( name )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "name" + ], + "start_line": 216, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "getextension", + "long_name": "getextension( name )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 4, + "token_count": 53, + "parameters": [ + "name" + ], + "start_line": 224, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "is_free_format", + "long_name": "is_free_format( file )", + "filename": "crackfortran.py", + "nloc": 19, + "complexity": 9, + "token_count": 114, + "parameters": [ + "file" + ], + "start_line": 236, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "readfortrancode", + "long_name": "readfortrancode( ffile , dowithline = show , istop = 1 )", + "filename": "crackfortran.py", + "nloc": 164, + "complexity": 57, + "token_count": 1156, + "parameters": [ + "ffile", + "dowithline", + "istop" + ], + "start_line": 261, + "end_line": 435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 175, + "top_nesting_level": 0 + }, + { + "name": "_simplifyargs", + "long_name": "_simplifyargs( argsline )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 56, + "parameters": [ + "argsline" + ], + "start_line": 483, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "crackline", + "long_name": "crackline( line , reset = 0 )", + "filename": "crackfortran.py", + "nloc": 121, + "complexity": 41, + "token_count": 874, + "parameters": [ + "line", + "reset" + ], + "start_line": 492, + "end_line": 619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 128, + "top_nesting_level": 0 + }, + { + "name": "markouterparen", + "long_name": "markouterparen( line )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 6, + "token_count": 68, + "parameters": [ + "line" + ], + "start_line": 621, + "end_line": 631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "markoutercomma", + "long_name": "markoutercomma( line , comma = ',' )", + "filename": "crackfortran.py", + "nloc": 20, + "complexity": 13, + "token_count": 132, + "parameters": [ + "line", + "comma" + ], + "start_line": 632, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "unmarkouterparen", + "long_name": "unmarkouterparen( line )", + "filename": "crackfortran.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "line" + ], + "start_line": 652, + "end_line": 654, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "appenddecl", + "long_name": "appenddecl( decl , decl2 , force = 1 )", + "filename": "crackfortran.py", + "nloc": 23, + "complexity": 17, + "token_count": 189, + "parameters": [ + "decl", + "decl2", + "force" + ], + "start_line": 655, + "end_line": 677, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_is_intent_callback", + "long_name": "_is_intent_callback( vdecl )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 3, + "token_count": 30, + "parameters": [ + "vdecl" + ], + "start_line": 686, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_resolvenameargspattern", + "long_name": "_resolvenameargspattern( line )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 77, + "parameters": [ + "line" + ], + "start_line": 692, + "end_line": 698, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "analyzeline", + "long_name": "analyzeline( m , case , line )", + "filename": "crackfortran.py", + "nloc": 413, + "complexity": 161, + "token_count": 3998, + "parameters": [ + "m", + "case", + "line" + ], + "start_line": 700, + "end_line": 1130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 431, + "top_nesting_level": 0 + }, + { + "name": "appendmultiline", + "long_name": "appendmultiline( group , context_name , ml )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 3, + "token_count": 57, + "parameters": [ + "group", + "context_name", + "ml" + ], + "start_line": 1132, + "end_line": 1139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cracktypespec0", + "long_name": "cracktypespec0( typespec , ll )", + "filename": "crackfortran.py", + "nloc": 20, + "complexity": 7, + "token_count": 185, + "parameters": [ + "typespec", + "ll" + ], + "start_line": 1141, + "end_line": 1160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "removespaces", + "long_name": "removespaces( expr )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 6, + "token_count": 97, + "parameters": [ + "expr" + ], + "start_line": 1167, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "markinnerspaces", + "long_name": "markinnerspaces( line )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 10, + "token_count": 129, + "parameters": [ + "line" + ], + "start_line": 1177, + "end_line": 1192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "updatevars", + "long_name": "updatevars( typespec , selector , attrspec , entitydecl )", + "filename": "crackfortran.py", + "nloc": 120, + "complexity": 61, + "token_count": 1215, + "parameters": [ + "typespec", + "selector", + "attrspec", + "entitydecl" + ], + "start_line": 1193, + "end_line": 1313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 121, + "top_nesting_level": 0 + }, + { + "name": "cracktypespec", + "long_name": "cracktypespec( typespec , selector )", + "filename": "crackfortran.py", + "nloc": 45, + "complexity": 17, + "token_count": 346, + "parameters": [ + "typespec", + "selector" + ], + "start_line": 1315, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "setattrspec", + "long_name": "setattrspec( decl , attr , force = 0 )", + "filename": "crackfortran.py", + "nloc": 19, + "complexity": 14, + "token_count": 167, + "parameters": [ + "decl", + "attr", + "force" + ], + "start_line": 1361, + "end_line": 1379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setkindselector", + "long_name": "setkindselector( decl , sel , force = 0 )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 7, + "token_count": 79, + "parameters": [ + "decl", + "sel", + "force" + ], + "start_line": 1380, + "end_line": 1389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "setcharselector", + "long_name": "setcharselector( decl , sel , force = 0 )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 7, + "token_count": 79, + "parameters": [ + "decl", + "sel", + "force" + ], + "start_line": 1390, + "end_line": 1399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "getblockname", + "long_name": "getblockname( block , unknown = 'unknown' )", + "filename": "crackfortran.py", + "nloc": 3, + "complexity": 2, + "token_count": 24, + "parameters": [ + "block", + "unknown" + ], + "start_line": 1400, + "end_line": 1402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "setmesstext", + "long_name": "setmesstext( block )", + "filename": "crackfortran.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "block" + ], + "start_line": 1404, + "end_line": 1407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "get_usedict", + "long_name": "get_usedict( block )", + "filename": "crackfortran.py", + "nloc": 7, + "complexity": 3, + "token_count": 45, + "parameters": [ + "block" + ], + "start_line": 1409, + "end_line": 1415, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "get_useparameters", + "long_name": "get_useparameters( block , param_map = None )", + "filename": "crackfortran.py", + "nloc": 23, + "complexity": 9, + "token_count": 132, + "parameters": [ + "block", + "param_map" + ], + "start_line": 1417, + "end_line": 1440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "postcrack2", + "long_name": "postcrack2( block , tab = '' , param_map = None )", + "filename": "crackfortran.py", + "nloc": 30, + "complexity": 12, + "token_count": 215, + "parameters": [ + "block", + "tab", + "param_map" + ], + "start_line": 1442, + "end_line": 1474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "postcrack", + "long_name": "postcrack( block , args = None , tab = '' )", + "filename": "crackfortran.py", + "nloc": 76, + "complexity": 35, + "token_count": 639, + "parameters": [ + "block", + "args", + "tab" + ], + "start_line": 1476, + "end_line": 1564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "sortvarnames", + "long_name": "sortvarnames( vars )", + "filename": "crackfortran.py", + "nloc": 31, + "complexity": 9, + "token_count": 172, + "parameters": [ + "vars" + ], + "start_line": 1566, + "end_line": 1598, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "analyzecommon", + "long_name": "analyzecommon( block )", + "filename": "crackfortran.py", + "nloc": 32, + "complexity": 11, + "token_count": 306, + "parameters": [ + "block" + ], + "start_line": 1600, + "end_line": 1631, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "analyzebody", + "long_name": "analyzebody( block , args , tab = '' )", + "filename": "crackfortran.py", + "nloc": 27, + "complexity": 13, + "token_count": 193, + "parameters": [ + "block", + "args", + "tab" + ], + "start_line": 1632, + "end_line": 1658, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "buildimplicitrules", + "long_name": "buildimplicitrules( block )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 6, + "token_count": 119, + "parameters": [ + "block" + ], + "start_line": 1659, + "end_line": 1674, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "myeval", + "long_name": "myeval( e , g = None , l = None )", + "filename": "crackfortran.py", + "nloc": 5, + "complexity": 2, + "token_count": 53, + "parameters": [ + "e", + "g", + "l" + ], + "start_line": 1676, + "end_line": 1680, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "getlincoef", + "long_name": "getlincoef( e , xset )", + "filename": "crackfortran.py", + "nloc": 34, + "complexity": 11, + "token_count": 287, + "parameters": [ + "e", + "xset" + ], + "start_line": 1683, + "end_line": 1716, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "getarrlen", + "long_name": "getarrlen( dl , args , star = '*' )", + "filename": "crackfortran.py", + "nloc": 95, + "complexity": 55, + "token_count": 1295, + "parameters": [ + "dl", + "args", + "star" + ], + "start_line": 1719, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 100, + "top_nesting_level": 0 + }, + { + "name": "_get_depend_dict", + "long_name": "_get_depend_dict( name , vars , deps )", + "filename": "crackfortran.py", + "nloc": 17, + "complexity": 11, + "token_count": 153, + "parameters": [ + "name", + "vars", + "deps" + ], + "start_line": 1822, + "end_line": 1839, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_calc_depend_dict", + "long_name": "_calc_depend_dict( vars )", + "filename": "crackfortran.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "vars" + ], + "start_line": 1841, + "end_line": 1846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "get_sorted_names", + "long_name": "get_sorted_names( vars )", + "filename": "crackfortran.py", + "nloc": 16, + "complexity": 10, + "token_count": 111, + "parameters": [ + "vars" + ], + "start_line": 1848, + "end_line": 1865, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_kind_func", + "long_name": "_kind_func( string )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 4, + "token_count": 48, + "parameters": [ + "string" + ], + "start_line": 1867, + "end_line": 1875, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_selected_int_kind_func", + "long_name": "_selected_int_kind_func( r )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 6, + "token_count": 58, + "parameters": [ + "r" + ], + "start_line": 1877, + "end_line": 1885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "get_parameters", + "long_name": "get_parameters( vars , global_params = { } )", + "filename": "crackfortran.py", + "nloc": 52, + "complexity": 21, + "token_count": 482, + "parameters": [ + "vars", + "global_params" + ], + "start_line": 1887, + "end_line": 1940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "_eval_length", + "long_name": "_eval_length( length , params )", + "filename": "crackfortran.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "length", + "params" + ], + "start_line": 1942, + "end_line": 1945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_eval_scalar", + "long_name": "_eval_scalar( value , params )", + "filename": "crackfortran.py", + "nloc": 12, + "complexity": 4, + "token_count": 75, + "parameters": [ + "value", + "params" + ], + "start_line": 1949, + "end_line": 1960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "analyzevars", + "long_name": "analyzevars( block )", + "filename": "crackfortran.py", + "nloc": 291, + "complexity": 158, + "token_count": 3132, + "parameters": [ + "block" + ], + "start_line": 1962, + "end_line": 2268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 307, + "top_nesting_level": 0 + }, + { + "name": "analyzeargs", + "long_name": "analyzeargs( block )", + "filename": "crackfortran.py", + "nloc": 37, + "complexity": 22, + "token_count": 370, + "parameters": [ + "block" + ], + "start_line": 2270, + "end_line": 2308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_ensure_exprdict", + "long_name": "_ensure_exprdict( r )", + "filename": "crackfortran.py", + "nloc": 9, + "complexity": 4, + "token_count": 75, + "parameters": [ + "r" + ], + "start_line": 2314, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "determineexprtype", + "long_name": "determineexprtype( expr , vars , rules = { } )", + "filename": "crackfortran.py", + "nloc": 37, + "complexity": 20, + "token_count": 340, + "parameters": [ + "expr", + "vars", + "rules" + ], + "start_line": 2324, + "end_line": 2360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "crack2fortrangen", + "long_name": "crack2fortrangen( block , tab = '\\n' )", + "filename": "crackfortran.py", + "nloc": 57, + "complexity": 25, + "token_count": 485, + "parameters": [ + "block", + "tab" + ], + "start_line": 2362, + "end_line": 2419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "common2fortran", + "long_name": "common2fortran( common , tab = '' )", + "filename": "crackfortran.py", + "nloc": 8, + "complexity": 3, + "token_count": 74, + "parameters": [ + "common", + "tab" + ], + "start_line": 2420, + "end_line": 2427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "use2fortran", + "long_name": "use2fortran( use , tab = '' )", + "filename": "crackfortran.py", + "nloc": 18, + "complexity": 13, + "token_count": 202, + "parameters": [ + "use", + "tab" + ], + "start_line": 2428, + "end_line": 2445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "true_intent_list", + "long_name": "true_intent_list( var )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 4, + "token_count": 45, + "parameters": [ + "var" + ], + "start_line": 2446, + "end_line": 2456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "vars2fortran", + "long_name": "vars2fortran( block , vars , args , tab = '' )", + "filename": "crackfortran.py", + "nloc": 102, + "complexity": 54, + "token_count": 933, + "parameters": [ + "block", + "vars", + "args", + "tab" + ], + "start_line": 2457, + "end_line": 2565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "crackfortran", + "long_name": "crackfortran( files )", + "filename": "crackfortran.py", + "nloc": 10, + "complexity": 1, + "token_count": 54, + "parameters": [ + "files" + ], + "start_line": 2568, + "end_line": 2577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "crack2fortran", + "long_name": "crack2fortran( block )", + "filename": "crackfortran.py", + "nloc": 11, + "complexity": 1, + "token_count": 31, + "parameters": [ + "block" + ], + "start_line": 2578, + "end_line": 2588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 2493, + "complexity": 993, + "token_count": 21225, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/doc/collectinput.py", + "new_path": "numpy/f2py/doc/collectinput.py", + "filename": "collectinput.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,7 +7,7 @@\n Copyright 1999 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\ncollectinput - Collects all files that are included to a main Latex document\n with \\input or \\include commands. These commands must be\n in separate lines.\n\nCopyright 1999 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\nPearu Peterson\n\nUsage:\n collectinput \n collectinput # =inputless_\n collectinput # in and out are stdin and stdout\n\"\"\"\n\n__version__ = \"0.0\"\n\nstdoutflag=0\nimport sys,os,string,fileinput,re,commands\n\ntry: fn=sys.argv[2]\nexcept:\n try: fn='inputless_'+sys.argv[1]\n except: stdoutflag=1\ntry: fi=sys.argv[1]\nexcept: fi=()\nif not stdoutflag:\n sys.stdout=open(fn,'w')\n\nnonverb=r'[\\w\\s\\\\&=\\^\\*\\.\\{\\(\\)\\[\\?\\+\\$/]*(?!\\\\verb.)'\ninput=re.compile(nonverb+r'\\\\(input|include)\\*?\\s*\\{?.*}?')\ncomment=re.compile(r'[^%]*%')\n\nfor l in fileinput.input(fi):\n l=l[:-1]\n l1=''\n if comment.match(l):\n m=comment.match(l)\n l1=l[m.end()-1:]\n l=l[:m.end()-1]\n m=input.match(l)\n if m:\n l=string.strip(l)\n if l[-1]=='}': l=l[:-1]\n i=m.end()-2\n sys.stderr.write('>>>>>>')\n while i>-1 and (l[i] not in [' ','{']): i=i-1\n if i>-1:\n fn=l[i+1:]\n try: f=open(fn,'r'); flag=1; f.close()\n except:\n try: f=open(fn+'.tex','r'); flag=1;fn=fn+'.tex'; f.close()\n except: flag=0\n if flag==0:\n sys.stderr.write('Could not open a file: '+fn+'\\n')\n print l+l1\n continue\n elif flag==1:\n sys.stderr.write(fn+'\\n')\n print '%%%%% Begin of '+fn\n print commands.getoutput(sys.argv[0]+' < '+fn)\n print '%%%%% End of '+fn\n else:\n sys.stderr.write('Could not extract a file name from: '+l)\n print l+l1\n else:\n print l+l1\nsys.stdout.close()\n\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncollectinput - Collects all files that are included to a main Latex document\n with \\input or \\include commands. These commands must be\n in separate lines.\n\nCopyright 1999 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\nPearu Peterson\n\nUsage:\n collectinput \n collectinput # =inputless_\n collectinput # in and out are stdin and stdout\n\"\"\"\n\n__version__ = \"0.0\"\n\nstdoutflag=0\nimport sys,os,string,fileinput,re,commands\n\ntry: fn=sys.argv[2]\nexcept:\n try: fn='inputless_'+sys.argv[1]\n except: stdoutflag=1\ntry: fi=sys.argv[1]\nexcept: fi=()\nif not stdoutflag:\n sys.stdout=open(fn,'w')\n\nnonverb=r'[\\w\\s\\\\&=\\^\\*\\.\\{\\(\\)\\[\\?\\+\\$/]*(?!\\\\verb.)'\ninput=re.compile(nonverb+r'\\\\(input|include)\\*?\\s*\\{?.*}?')\ncomment=re.compile(r'[^%]*%')\n\nfor l in fileinput.input(fi):\n l=l[:-1]\n l1=''\n if comment.match(l):\n m=comment.match(l)\n l1=l[m.end()-1:]\n l=l[:m.end()-1]\n m=input.match(l)\n if m:\n l=string.strip(l)\n if l[-1]=='}': l=l[:-1]\n i=m.end()-2\n sys.stderr.write('>>>>>>')\n while i>-1 and (l[i] not in [' ','{']): i=i-1\n if i>-1:\n fn=l[i+1:]\n try: f=open(fn,'r'); flag=1; f.close()\n except:\n try: f=open(fn+'.tex','r'); flag=1;fn=fn+'.tex'; f.close()\n except: flag=0\n if flag==0:\n sys.stderr.write('Could not open a file: '+fn+'\\n')\n print l+l1\n continue\n elif flag==1:\n sys.stderr.write(fn+'\\n')\n print '%%%%% Begin of '+fn\n print commands.getoutput(sys.argv[0]+' < '+fn)\n print '%%%%% End of '+fn\n else:\n sys.stderr.write('Could not extract a file name from: '+l)\n print l+l1\n else:\n print l+l1\nsys.stdout.close()\n\n\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 68, + "complexity": 0, + "token_count": 403, + "diff_parsed": { + "added": [ + "terms of the NumPy License" + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/doc/index.html", + "new_path": "numpy/f2py/doc/index.html", + "filename": "index.html", + "extension": "html", + "change_type": "MODIFY", + "diff": "@@ -43,8 +43,7 @@

Introduction

\n tool as F2PY ­ Fortran to Python Interface Generator.\n It is completely written in Python\n language and can be called from the command line as f2py.\n-F2PY is released under the terms of GNU LGPL. \n+F2PY (in NumPy) is released under the terms of the NumPy License.\n \n \n

f2py, Second Edition

\n@@ -226,7 +225,7 @@

Related sites

\n Pearu Peterson\n <pearu(at)ioc.ee>
\n \n-Last modified: Mon Dec 3 19:40:26 EET 2001\n+Last modified: Fri Jan 20 14:55:12 MST 2006\n \n \n \n", + "added_lines": 2, + "deleted_lines": 3, + "source_code": "\n\n\n\n\n\nF2PY - Fortran to Python Interface Generator\n\n\n\n\n\n

F2PY ­ Fortran to Python Interface Generator

\nby Pearu Peterson\n\n

What's new?

\n\nSee NEWS.txt for the latest changes in f2py.\n
\n
July ??, 2002\n
Implemented prototype calculator, complete tests for scalar F77\n functions, --help-compiler option. Fixed number of bugs and\n removed obsolete features.\n
April 4, 2002\n
Fixed a nasty bug of copying one-dimensional non-contiguous arrays.\n (Thanks to Travis O. for pointing this out).\n
March 26, 2002\n
Bug fixes, turned off F2PY_REPORT_ATEXIT by default.\n
March 13, 2002\n
MAC support, fixed incomplete dependency calculator, minor bug fixes.\n
March 3, 2002\n
Fixed memory leak and copying of multi-dimensional complex arrays.\n
Old news.\n
\n\n

Introduction

\n\nWriting Python C/API wrappers for Fortran routines can be a very\ntedious task, especially if a Fortran routine takes more than 20\narguments but only few of them are relevant for the problems that they\nsolve. So, I have developed a tool that generates the C/API modules\ncontaining wrapper functions of Fortran routines. I call this\ntool as F2PY ­ Fortran to Python Interface Generator.\nIt is completely written in Python\nlanguage and can be called from the command line as f2py.\nF2PY (in NumPy) is released under the terms of the NumPy License.\n\n\n

f2py, Second Edition

\n\nThe development of f2py started in summer of 1999.\nFor now (January, 2000) it has reached to stage of being a\ncomplete tool: it scans real Fortran code, creates signature file\nthat the user can modify, constructs C/API module that can be\ncomplied and imported to Python, and it creates LaTeX documentation\nfor wrapper functions. Below is a bit longer list of\nf2py features:\n
    \n
  1. f2py scans real Fortran codes and produces the signature files.\n The syntax of the signature files is borrowed from the Fortran 90/95\n language specification with some extensions.\n
  2. f2py generates a GNU Makefile that can be used\n for building shared modules (see below for a list of supported\n platforms/compilers). Starting from the third release,\n f2py generates setup_modulename.py for\n building extension modules using distutils tools.\n
  3. f2py uses the signature files to produce the wrappers for\n Fortran 77 routines and their COMMON blocks.\n
  4. For external arguments f2py constructs a very flexible\n call-back mechanism so that Python functions can be called from\n Fortran.\n
  5. You can pass in almost arbitrary Python objects to wrapper\n functions. If needed, f2py takes care of type-casting and\n non-contiguous arrays.\n
  6. You can modify the signature files so that f2py will generate\n wrapper functions with desired signatures. depend()\n attribute is introduced to control the initialization order of the\n variables. f2py introduces intent(hide)\n attribute to remove\n the particular argument from the argument list of the wrapper\n function and intent(c) that is useful for wrapping C\nlibraries. In addition, optional and\nrequired\n attributes are introduced and employed.\n
  7. f2py supports almost all standard Fortran 77/90/95 constructs\n and understands all basic Fortran types, including\n (multi-dimensional, complex) arrays and character strings with\n adjustable and assumed sizes/lengths.\n
  8. f2py generates a LaTeX document containing the\n documentations of the wrapped functions (argument types, dimensions,\n etc). The user can easily add some human readable text to the\n documentation by inserting note(<LaTeX text>) attribute to\n the definition of routine signatures.\n
  9. With f2py one can access also Fortran 90/95\n module subroutines from Python.\n
\n\nFor more information, see the User's\nGuide of the tool. Windows users should also take a look at\nf2py HOWTO for Win32 (its latest version\ncan be found here).\n\n

Requirements

\n
    \n
  1. You'll need Python\n (1.5.2 or later, 2.2 is recommended) to run f2py\n (because it uses exchanged module re).\n To build generated extension modules with distutils setup script,\n you'll need Python 2.x.\n
  2. You'll need Numerical\n Python\n (version 13 or later, 20.3 is recommended) to compile\n C/API modules (because they use function\n PyArray_FromDimsAndDataAndDescr)\n
\n\n

Download

\n\n
\n
User's Guide:\n
usersguide.html,\n usersguide.pdf,\n usersguide.ps.gz,\n usersguide.dvi.\n
Snapshots of the fifth public release:\n
2.x/F2PY-2-latest.tar.gz\n
Snapshots of earlier releases:\n
rel-5.x, rel-4.x,\n rel-3.x,\n rel-2.x,rel-1.x,\n rel-0.x\n
\n\n

Installation

\n\nUnpack the source file, change to directory f2py-?-???\nand run python setup.py install. That's it!\n\n

Platform/Compiler Related Notes

\n\nf2py has been successfully tested on\n\nf2py will probably run on other UN*X systems as\nwell. Additions to the list of platforms/compilers where\nf2py has been successfully used are most welcome.\n

\nNote:\nUsing Compaq Fortran\ncompiler on Alpha Linux is succesful unless when\nwrapping Fortran callback functions returning\nCOMPLEX. This applies also for IRIX64.\n

\nNote:\nFortran 90/95 module support is currently tested with Absoft F90, VAST/f90, Intel F90 compilers on Linux (MD7.0,Debian woody).\n\n\n

Mailing list

\n\nThere is a mailing list f2py-users \navailable for the users of the f2py \nprogram and it is open for discussion, questions, and answers. You can subscribe\nthe list here.\n\n

CVS Repository

\n\nf2py is being developed under CVS and those who are\ninterested in the really latest version of f2py (possibly\nunstable) can get it from the repository as follows:\n
    \n
  1. First you need to login (the password is guest):\n
    \n> cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login\n
    \n
  2. and then do the checkout:\n
    \n> cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout f2py2e\n
    \n
  3. In the directory f2py2e you can get the updates by hitting\n
    \n> cvs -z6 update -P -d\n
    \n
\nYou can browse f2py CVS repository here.\n\n

Related sites

\n\n
    \n
  1. Numerical Python.\n
  2. Pyfort -- The Python-Fortran connection tool.\n
  3. Scientific Python.\n
  4. SciPy -- Scientific tools for Python (includes Multipack).\n
  5. The Fortran Company.\n
  6. Fortran Standards.\n\n
  7. American National Standard Programming Language FORTRAN ANSI(R) X3.9-1978\n
  8. Mathtools.net -- A technical computing portal for all scientific and engineering needs.\n\n
\n\n\n
\n
\n\"Valid\nPearu Peterson\n<pearu(at)ioc.ee>
\n\nLast modified: Fri Jan 20 14:55:12 MST 2006\n\n
\n\n\n\n\n

\n

\nThis Python\nring site owned by Pearu Peterson.\n
\n[ \n Previous 5 Sites \n|\n Previous \n|\n Next \n|\n Next 5 Sites \n|\n Random Site \n|\n List Sites \n]\n
\n

\n\n\n\n\n\n\n\n\n\n\n", + "source_code_before": "\n\n\n\n\n\nF2PY - Fortran to Python Interface Generator\n\n\n\n\n\n

F2PY ­ Fortran to Python Interface Generator

\nby Pearu Peterson\n\n

What's new?

\n\nSee NEWS.txt for the latest changes in f2py.\n
\n
July ??, 2002\n
Implemented prototype calculator, complete tests for scalar F77\n functions, --help-compiler option. Fixed number of bugs and\n removed obsolete features.\n
April 4, 2002\n
Fixed a nasty bug of copying one-dimensional non-contiguous arrays.\n (Thanks to Travis O. for pointing this out).\n
March 26, 2002\n
Bug fixes, turned off F2PY_REPORT_ATEXIT by default.\n
March 13, 2002\n
MAC support, fixed incomplete dependency calculator, minor bug fixes.\n
March 3, 2002\n
Fixed memory leak and copying of multi-dimensional complex arrays.\n
Old news.\n
\n\n

Introduction

\n\nWriting Python C/API wrappers for Fortran routines can be a very\ntedious task, especially if a Fortran routine takes more than 20\narguments but only few of them are relevant for the problems that they\nsolve. So, I have developed a tool that generates the C/API modules\ncontaining wrapper functions of Fortran routines. I call this\ntool as F2PY ­ Fortran to Python Interface Generator.\nIt is completely written in Python\nlanguage and can be called from the command line as f2py.\nF2PY is released under the terms of GNU LGPL. \n\n\n

f2py, Second Edition

\n\nThe development of f2py started in summer of 1999.\nFor now (January, 2000) it has reached to stage of being a\ncomplete tool: it scans real Fortran code, creates signature file\nthat the user can modify, constructs C/API module that can be\ncomplied and imported to Python, and it creates LaTeX documentation\nfor wrapper functions. Below is a bit longer list of\nf2py features:\n
    \n
  1. f2py scans real Fortran codes and produces the signature files.\n The syntax of the signature files is borrowed from the Fortran 90/95\n language specification with some extensions.\n
  2. f2py generates a GNU Makefile that can be used\n for building shared modules (see below for a list of supported\n platforms/compilers). Starting from the third release,\n f2py generates setup_modulename.py for\n building extension modules using distutils tools.\n
  3. f2py uses the signature files to produce the wrappers for\n Fortran 77 routines and their COMMON blocks.\n
  4. For external arguments f2py constructs a very flexible\n call-back mechanism so that Python functions can be called from\n Fortran.\n
  5. You can pass in almost arbitrary Python objects to wrapper\n functions. If needed, f2py takes care of type-casting and\n non-contiguous arrays.\n
  6. You can modify the signature files so that f2py will generate\n wrapper functions with desired signatures. depend()\n attribute is introduced to control the initialization order of the\n variables. f2py introduces intent(hide)\n attribute to remove\n the particular argument from the argument list of the wrapper\n function and intent(c) that is useful for wrapping C\nlibraries. In addition, optional and\nrequired\n attributes are introduced and employed.\n
  7. f2py supports almost all standard Fortran 77/90/95 constructs\n and understands all basic Fortran types, including\n (multi-dimensional, complex) arrays and character strings with\n adjustable and assumed sizes/lengths.\n
  8. f2py generates a LaTeX document containing the\n documentations of the wrapped functions (argument types, dimensions,\n etc). The user can easily add some human readable text to the\n documentation by inserting note(<LaTeX text>) attribute to\n the definition of routine signatures.\n
  9. With f2py one can access also Fortran 90/95\n module subroutines from Python.\n
\n\nFor more information, see the User's\nGuide of the tool. Windows users should also take a look at\nf2py HOWTO for Win32 (its latest version\ncan be found here).\n\n

Requirements

\n
    \n
  1. You'll need Python\n (1.5.2 or later, 2.2 is recommended) to run f2py\n (because it uses exchanged module re).\n To build generated extension modules with distutils setup script,\n you'll need Python 2.x.\n
  2. You'll need Numerical\n Python\n (version 13 or later, 20.3 is recommended) to compile\n C/API modules (because they use function\n PyArray_FromDimsAndDataAndDescr)\n
\n\n

Download

\n\n
\n
User's Guide:\n
usersguide.html,\n usersguide.pdf,\n usersguide.ps.gz,\n usersguide.dvi.\n
Snapshots of the fifth public release:\n
2.x/F2PY-2-latest.tar.gz\n
Snapshots of earlier releases:\n
rel-5.x, rel-4.x,\n rel-3.x,\n rel-2.x,rel-1.x,\n rel-0.x\n
\n\n

Installation

\n\nUnpack the source file, change to directory f2py-?-???\nand run python setup.py install. That's it!\n\n

Platform/Compiler Related Notes

\n\nf2py has been successfully tested on\n\nf2py will probably run on other UN*X systems as\nwell. Additions to the list of platforms/compilers where\nf2py has been successfully used are most welcome.\n

\nNote:\nUsing Compaq Fortran\ncompiler on Alpha Linux is succesful unless when\nwrapping Fortran callback functions returning\nCOMPLEX. This applies also for IRIX64.\n

\nNote:\nFortran 90/95 module support is currently tested with Absoft F90, VAST/f90, Intel F90 compilers on Linux (MD7.0,Debian woody).\n\n\n

Mailing list

\n\nThere is a mailing list f2py-users \navailable for the users of the f2py \nprogram and it is open for discussion, questions, and answers. You can subscribe\nthe list here.\n\n

CVS Repository

\n\nf2py is being developed under CVS and those who are\ninterested in the really latest version of f2py (possibly\nunstable) can get it from the repository as follows:\n
    \n
  1. First you need to login (the password is guest):\n
    \n> cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login\n
    \n
  2. and then do the checkout:\n
    \n> cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout f2py2e\n
    \n
  3. In the directory f2py2e you can get the updates by hitting\n
    \n> cvs -z6 update -P -d\n
    \n
\nYou can browse f2py CVS repository here.\n\n

Related sites

\n\n
    \n
  1. Numerical Python.\n
  2. Pyfort -- The Python-Fortran connection tool.\n
  3. Scientific Python.\n
  4. SciPy -- Scientific tools for Python (includes Multipack).\n
  5. The Fortran Company.\n
  6. Fortran Standards.\n\n
  7. American National Standard Programming Language FORTRAN ANSI(R) X3.9-1978\n
  8. Mathtools.net -- A technical computing portal for all scientific and engineering needs.\n\n
\n\n\n
\n
\n\"Valid\nPearu Peterson\n<pearu(at)ioc.ee>
\n\nLast modified: Mon Dec 3 19:40:26 EET 2001\n\n
\n\n\n\n\n

\n

\nThis Python\nring site owned by Pearu Peterson.\n
\n[ \n Previous 5 Sites \n|\n Previous \n|\n Next \n|\n Next 5 Sites \n|\n Random Site \n|\n List Sites \n]\n
\n

\n\n\n\n\n\n\n\n\n\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "F2PY (in NumPy) is released under the terms of the NumPy License.", + "Last modified: Fri Jan 20 14:55:12 MST 2006" + ], + "deleted": [ + "F2PY is released under the terms of GNU LGPL.", + "Last modified: Mon Dec 3 19:40:26 EET 2001" + ] + } + }, + { + "old_path": "numpy/f2py/docs/README.txt", + "new_path": "numpy/f2py/docs/README.txt", + "filename": "README.txt", + "extension": "txt", + "change_type": "MODIFY", + "diff": "@@ -5,7 +5,7 @@\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n :Author: Pearu Peterson \n-:License: LGPL_.\n+:License: NumPy License\n :Web-site: http://cens.ioc.ee/projects/f2py2e/\n :Discussions to: `f2py-users mailing list`_\n :Documentation: `User's Guide`__, FAQ__\n@@ -443,7 +443,6 @@ __ http://jrfonseca.dyndns.org/debian/\n .. _Numarray: http://www.stsci.edu/resources/software_hardware/numarray\n .. _docutils: http://docutils.sourceforge.net/\n .. _distutils: http://www.python.org/sigs/distutils-sig/\n-.. _LGPL: http://www.fsf.org/copyleft/lesser.html\n .. _Numerical Python: http://www.numpy.org/\n .. _Pyfort: http://pyfortran.sourceforge.net/\n .. _Scientific Python: \n", + "added_lines": 1, + "deleted_lines": 2, + "source_code": ".. -*- rest -*-\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n F2PY: Fortran to Python interface generator\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Author: Pearu Peterson \n:License: NumPy License\n:Web-site: http://cens.ioc.ee/projects/f2py2e/\n:Discussions to: `f2py-users mailing list`_\n:Documentation: `User's Guide`__, FAQ__\n:Platforms: All\n:Date: $Date: 2005/01/30 18:54:53 $\n\n.. _f2py-users mailing list: http://cens.ioc.ee/mailman/listinfo/f2py-users/\n__ usersguide/index.html\n__ FAQ.html\n\n-------------------------------\n\n.. topic:: NEWS!!!\n\n January 5, 2006\n \n WARNING -- these notes are out of date! The package structure for NumPy and\n SciPy has changed considerably. Much of this information is now incorrect.\n \n January 30, 2005\n\n Latest F2PY release (version 2.45.241_1926).\n New features: wrapping unsigned integers, support for ``.pyf.src`` template files,\n callback arguments can now be CObjects, fortran objects, built-in functions.\n Introduced ``intent(aux)`` attribute. Wrapped objects have ``_cpointer``\n attribute holding C pointer to wrapped functions or variables.\n Many bug fixes and improvements, updated documentation.\n `Differences with the previous release (version 2.43.239_1831)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.163&r2=1.137&f=h\n\n October 4, 2004\n F2PY bug fix release (version 2.43.239_1831).\n Better support for 64-bit platforms.\n Introduced ``--help-link`` and ``--link-`` options.\n Bug fixes.\n `Differences with the previous release (version 2.43.239_1806)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.137&r2=1.131&f=h\n\n September 25, 2004\n Latest F2PY release (version 2.43.239_1806). \n Support for ``ENTRY`` statement. New attributes:\n ``intent(inplace)``, ``intent(callback)``. Supports Numarray 1.1.\n Introduced ``-*- fix -*-`` header content. Improved ``PARAMETER`` support.\n Documentation updates. `Differences with the previous release\n (version 2.39.235-1693)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.131&r2=1.98&f=h\n\n `History of NEWS`__\n\n __ OLDNEWS.html\n\n-------------------------------\n\n.. Contents::\n\n==============\n Introduction\n==============\n\nThe purpose of the F2PY --*Fortran to Python interface generator*--\nproject is to provide connection between Python_ and Fortran\nlanguages. F2PY is a Python extension tool for creating Python C/API\nmodules from (handwritten or F2PY generated) signature files (or\ndirectly from Fortran sources). The generated extension modules\nfacilitate:\n\n* Calling Fortran 77/90/95, Fortran 90/95 module, and C functions from\n Python.\n\n* Accessing Fortran 77 ``COMMON`` blocks and Fortran 90/95 module\n data (including allocatable arrays) from Python.\n\n* Calling Python functions from Fortran or C (call-backs).\n\n* Automatically handling the difference in the data storage order of\n multi-dimensional Fortran and Numerical Python (i.e. C) arrays.\n\nIn addition, F2PY can build the generated extension modules to shared\nlibraries with one command. F2PY uses the ``numpy_distutils`` module\nfrom SciPy_ that supports number of major Fortran compilers.\n\n..\n (see `COMPILERS.txt`_ for more information).\n\nF2PY generated extension modules depend on NumPy_ package that\nprovides fast multi-dimensional array language facility to Python.\n\n\n---------------\n Main features\n---------------\n\nHere follows a more detailed list of F2PY features:\n\n* F2PY scans real Fortran codes to produce the so-called signature\n files (.pyf files). The signature files contain all the information\n (function names, arguments and their types, etc.) that is needed to\n construct Python bindings to Fortran (or C) functions.\n\n The syntax of signature files is borrowed from the\n Fortran 90/95 language specification and has some F2PY specific\n extensions. The signature files can be modified to dictate how\n Fortran (or C) programs are called from Python:\n\n + F2PY solves dependencies between arguments (this is relevant for\n the order of initializing variables in extension modules).\n\n + Arguments can be specified to be optional or hidden that\n simplifies calling Fortran programs from Python considerably.\n\n + In principle, one can design any Python signature for a given\n Fortran function, e.g. change the order arguments, introduce\n auxiliary arguments, hide the arguments, process the arguments\n before passing to Fortran, return arguments as output of F2PY\n generated functions, etc.\n\n* F2PY automatically generates __doc__ strings (and optionally LaTeX\n documentation) for extension modules.\n\n* F2PY generated functions accept arbitrary (but sensible) Python\n objects as arguments. The F2PY interface automatically takes care of\n type-casting and handling of non-contiguous arrays.\n\n* The following Fortran constructs are recognized by F2PY:\n\n + All basic Fortran types::\n\n integer[ | *1 | *2 | *4 | *8 ], logical[ | *1 | *2 | *4 | *8 ]\n integer*([ -1 | -2 | -4 | -8 ])\n character[ | *(*) | *1 | *2 | *3 | ... ]\n real[ | *4 | *8 | *16 ], double precision\n complex[ | *8 | *16 | *32 ]\n\n Negative ``integer`` kinds are used to wrap unsigned integers.\n\n + Multi-dimensional arrays of all basic types with the following\n dimension specifications::\n\n | : | * | :\n\n + Attributes and statements::\n \n intent([ in | inout | out | hide | in,out | inout,out | c |\n copy | cache | callback | inplace | aux ])\n dimension()\n common, parameter\n allocatable\n optional, required, external\n depend([])\n check([])\n note()\n usercode, callstatement, callprotoargument, threadsafe, fortranname\n pymethoddef\n entry\n\n* Because there are only little (and easily handleable) differences\n between calling C and Fortran functions from F2PY generated\n extension modules, then F2PY is also well suited for wrapping C\n libraries to Python.\n\n* Practice has shown that F2PY generated interfaces (to C or Fortran\n functions) are less error prone and even more efficient than\n handwritten extension modules. The F2PY generated interfaces are\n easy to maintain and any future optimization of F2PY generated\n interfaces transparently apply to extension modules by just\n regenerating them with the latest version of F2PY.\n\n* `F2PY Users Guide and Reference Manual`_\n\n\n===============\n Prerequisites\n===============\n\nF2PY requires the following software installed:\n\n* Python_ (versions 1.5.2 or later; 2.1 and up are recommended).\n You must have python-dev package installed.\n* NumPy_ (versions 13 or later; 20.x, 21.x, 22.x, 23.x are recommended)\n* Numarray_ (version 0.9 and up), optional, partial support.\n* Scipy_distutils (version 0.2.2 and up are recommended) from SciPy_\n project. Get it from Scipy CVS or download it below.\n\nPython 1.x users also need distutils_.\n\nOf course, to build extension modules, you'll need also working C\nand/or Fortran compilers installed.\n\n==========\n Download\n==========\n\nYou can download the sources for the latest F2PY and numpy_distutils\nreleases as:\n\n* `2.x`__/`F2PY-2-latest.tar.gz`__\n* `2.x`__/`numpy_distutils-latest.tar.gz`__\n\nWindows users might be interested in Win32 installer for F2PY and\nScipy_distutils (these installers are built using Python 2.3):\n\n* `2.x`__/`F2PY-2-latest.win32.exe`__\n* `2.x`__/`numpy_distutils-latest.win32.exe`__\n\nOlder releases are also available in the directories\n`rel-0.x`__, `rel-1.x`__, `rel-2.x`__, `rel-3.x`__, `rel-4.x`__, `rel-5.x`__,\nif you need them.\n\n.. __: 2.x/\n.. __: 2.x/F2PY-2-latest.tar.gz\n.. __: 2.x/\n.. __: 2.x/numpy_distutils-latest.tar.gz\n.. __: 2.x/\n.. __: 2.x/F2PY-2-latest.win32.exe\n.. __: 2.x/\n.. __: 2.x/numpy_distutils-latest.win32.exe\n.. __: rel-0.x\n.. __: rel-1.x\n.. __: rel-2.x\n.. __: rel-3.x\n.. __: rel-4.x\n.. __: rel-5.x\n\nDevelopment version of F2PY from CVS is available as `f2py2e.tar.gz`__.\n\n__ http://cens.ioc.ee/cgi-bin/viewcvs.cgi/python/f2py2e/f2py2e.tar.gz?tarball=1\n\nDebian Sid users can simply install ``python-f2py`` package.\n\n==============\n Installation\n==============\n\nUnpack the source file, change to directrory ``F2PY-?-???/`` and run\n(you may need to become a root)::\n\n python setup.py install\n\nThe F2PY installation installs a Python package ``f2py2e`` to your\nPython ``site-packages`` directory and a script ``f2py`` to your\nPython executable path. \n\nSee also Installation__ section in `F2PY FAQ`_.\n\n.. __: FAQ.html#installation\n\nSimilarly, to install ``numpy_distutils``, unpack its tar-ball and run::\n\n python setup.py install\n\n=======\n Usage\n=======\n\nTo check if F2PY is installed correctly, run\n::\n\n f2py\n\nwithout any arguments. This should print out the usage information of\nthe ``f2py`` program.\n\nNext, try out the following three steps:\n\n1) Create a Fortran file `hello.f`__ that contains::\n\n C File hello.f\n subroutine foo (a)\n integer a\n print*, \"Hello from Fortran!\"\n print*, \"a=\",a\n end\n\n__ hello.f\n\n2) Run\n\n ::\n \n f2py -c -m hello hello.f\n\n This will build an extension module ``hello.so`` (or ``hello.sl``,\n or ``hello.pyd``, etc. depending on your platform) into the current\n directory.\n\n3) Now in Python try::\n\n >>> import hello\n >>> print hello.__doc__\n >>> print hello.foo.__doc__\n >>> hello.foo(4) \n Hello from Fortran!\n a= 4\n >>> \n\nIf the above works, then you can try out more thorough \n`F2PY unit tests`__ and read the `F2PY Users Guide and Reference Manual`_.\n\n__ FAQ.html#q-how-to-test-if-f2py-is-working-correctly\n\n===============\n Documentation\n===============\n\nThe documentation of the F2PY project is collected in ``f2py2e/docs/``\ndirectory. It contains the following documents:\n\n`README.txt`_ (in CVS__)\n The first thing to read about F2PY -- this document.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/README.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`usersguide/index.txt`_, `usersguide/f2py_usersguide.pdf`_\n F2PY Users Guide and Reference Manual. Contains lots of examples.\n\n`FAQ.txt`_ (in CVS__)\n F2PY Frequently Asked Questions.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/FAQ.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`TESTING.txt`_ (in CVS__)\n About F2PY testing site. What tests are available and how to run them.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/TESTING.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`HISTORY.txt`_ (in CVS__)\n A list of latest changes in F2PY. This is the most up-to-date\n document on F2PY.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`THANKS.txt`_\n Acknowledgments.\n\n..\n `COMPILERS.txt`_\n Compiler and platform specific notes.\n\n===============\n Mailing list\n===============\n\nA mailing list f2py-users@cens.ioc.ee is open for F2PY releated\ndiscussion/questions/etc.\n\n* `Subscribe..`__ \n* `Archives..`__\n\n__ http://cens.ioc.ee/mailman/listinfo/f2py-users\n__ http://cens.ioc.ee/pipermail/f2py-users\n\n\n=====\n CVS\n=====\n\nF2PY is being developed under CVS_. The CVS version of F2PY can be\nobtained as follows:\n\n1) First you need to login (the password is ``guest``)::\n\n cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login\n\n2) and then do the checkout::\n\n cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout f2py2e\n\n3) You can update your local F2PY tree ``f2py2e/`` by executing::\n\n cvs -z6 update -P -d\n\nYou can browse the `F2PY CVS`_ repository.\n\n===============\n Contributions\n===============\n\n* `A short introduction to F2PY`__ by Pierre Schnizer.\n\n* `F2PY notes`__ by Fernando Perez.\n\n* `Debian packages of F2PY`__ by Jos Fonseca. [OBSOLETE, Debian Sid\n ships python-f2py package]\n\n__ http://fubphpc.tu-graz.ac.at/~pierre/f2py_tutorial.tar.gz\n__ http://cens.ioc.ee/pipermail/f2py-users/2003-April/000472.html\n__ http://jrfonseca.dyndns.org/debian/\n\n\n===============\n Related sites\n===============\n\n* `Numerical Python`_ -- adds a fast array facility to the Python language.\n* Pyfort_ -- A Python-Fortran connection tool.\n* SciPy_ -- An open source library of scientific tools for Python.\n* `Scientific Python`_ -- A collection of Python modules that are\n useful for scientific computing.\n* `The Fortran Company`_ -- A place to find products, services, and general\n information related to the Fortran programming language.\n* `American National Standard Programming Language FORTRAN ANSI(R) X3.9-1978`__\n* `J3`_ -- The US Fortran standards committee.\n* SWIG_ -- A software development tool that connects programs written\n in C and C++ with a variety of high-level programming languages. \n* `Mathtools.net`_ -- A technical computing portal for all scientific\n and engineering needs. \n\n.. __: http://www.fortran.com/fortran/F77_std/rjcnf.html\n\n.. References\n ==========\n\n\n.. _F2PY Users Guide and Reference Manual: usersguide/index.html\n.. _usersguide/index.txt: usersguide/index.html\n.. _usersguide/f2py_usersguide.pdf: usersguide/f2py_usersguide.pdf\n.. _README.txt: README.html\n.. _COMPILERS.txt: COMPILERS.html\n.. _F2PY FAQ:\n.. _FAQ.txt: FAQ.html\n.. _HISTORY.txt: HISTORY.html\n.. _HISTORY.txt from CVS: http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n.. _THANKS.txt: THANKS.html\n.. _TESTING.txt: TESTING.html\n.. _F2PY CVS2: http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/\n.. _F2PY CVS: http://cens.ioc.ee/cgi-bin/viewcvs.cgi/python/f2py2e/\n\n.. _CVS: http://www.cvshome.org/\n.. _Python: http://www.python.org/\n.. _SciPy: http://www.numpy.org/\n.. _NumPy: http://www.numpy.org/\n.. _Numarray: http://www.stsci.edu/resources/software_hardware/numarray\n.. _docutils: http://docutils.sourceforge.net/\n.. _distutils: http://www.python.org/sigs/distutils-sig/\n.. _Numerical Python: http://www.numpy.org/\n.. _Pyfort: http://pyfortran.sourceforge.net/\n.. _Scientific Python: \n http://starship.python.net/crew/hinsen/scientific.html\n.. _The Fortran Company: http://www.fortran.com/fortran/\n.. _J3: http://www.j3-fortran.org/\n.. _Mathtools.net: http://www.mathtools.net/\n.. _SWIG: http://www.swig.org/\n\n..\n Local Variables:\n mode: indented-text\n indent-tabs-mode: nil\n sentence-end-double-space: t\n fill-column: 70\n End:\n", + "source_code_before": ".. -*- rest -*-\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n F2PY: Fortran to Python interface generator\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Author: Pearu Peterson \n:License: LGPL_.\n:Web-site: http://cens.ioc.ee/projects/f2py2e/\n:Discussions to: `f2py-users mailing list`_\n:Documentation: `User's Guide`__, FAQ__\n:Platforms: All\n:Date: $Date: 2005/01/30 18:54:53 $\n\n.. _f2py-users mailing list: http://cens.ioc.ee/mailman/listinfo/f2py-users/\n__ usersguide/index.html\n__ FAQ.html\n\n-------------------------------\n\n.. topic:: NEWS!!!\n\n January 5, 2006\n \n WARNING -- these notes are out of date! The package structure for NumPy and\n SciPy has changed considerably. Much of this information is now incorrect.\n \n January 30, 2005\n\n Latest F2PY release (version 2.45.241_1926).\n New features: wrapping unsigned integers, support for ``.pyf.src`` template files,\n callback arguments can now be CObjects, fortran objects, built-in functions.\n Introduced ``intent(aux)`` attribute. Wrapped objects have ``_cpointer``\n attribute holding C pointer to wrapped functions or variables.\n Many bug fixes and improvements, updated documentation.\n `Differences with the previous release (version 2.43.239_1831)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.163&r2=1.137&f=h\n\n October 4, 2004\n F2PY bug fix release (version 2.43.239_1831).\n Better support for 64-bit platforms.\n Introduced ``--help-link`` and ``--link-`` options.\n Bug fixes.\n `Differences with the previous release (version 2.43.239_1806)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.137&r2=1.131&f=h\n\n September 25, 2004\n Latest F2PY release (version 2.43.239_1806). \n Support for ``ENTRY`` statement. New attributes:\n ``intent(inplace)``, ``intent(callback)``. Supports Numarray 1.1.\n Introduced ``-*- fix -*-`` header content. Improved ``PARAMETER`` support.\n Documentation updates. `Differences with the previous release\n (version 2.39.235-1693)`__.\n\n __ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt.diff?r1=1.131&r2=1.98&f=h\n\n `History of NEWS`__\n\n __ OLDNEWS.html\n\n-------------------------------\n\n.. Contents::\n\n==============\n Introduction\n==============\n\nThe purpose of the F2PY --*Fortran to Python interface generator*--\nproject is to provide connection between Python_ and Fortran\nlanguages. F2PY is a Python extension tool for creating Python C/API\nmodules from (handwritten or F2PY generated) signature files (or\ndirectly from Fortran sources). The generated extension modules\nfacilitate:\n\n* Calling Fortran 77/90/95, Fortran 90/95 module, and C functions from\n Python.\n\n* Accessing Fortran 77 ``COMMON`` blocks and Fortran 90/95 module\n data (including allocatable arrays) from Python.\n\n* Calling Python functions from Fortran or C (call-backs).\n\n* Automatically handling the difference in the data storage order of\n multi-dimensional Fortran and Numerical Python (i.e. C) arrays.\n\nIn addition, F2PY can build the generated extension modules to shared\nlibraries with one command. F2PY uses the ``numpy_distutils`` module\nfrom SciPy_ that supports number of major Fortran compilers.\n\n..\n (see `COMPILERS.txt`_ for more information).\n\nF2PY generated extension modules depend on NumPy_ package that\nprovides fast multi-dimensional array language facility to Python.\n\n\n---------------\n Main features\n---------------\n\nHere follows a more detailed list of F2PY features:\n\n* F2PY scans real Fortran codes to produce the so-called signature\n files (.pyf files). The signature files contain all the information\n (function names, arguments and their types, etc.) that is needed to\n construct Python bindings to Fortran (or C) functions.\n\n The syntax of signature files is borrowed from the\n Fortran 90/95 language specification and has some F2PY specific\n extensions. The signature files can be modified to dictate how\n Fortran (or C) programs are called from Python:\n\n + F2PY solves dependencies between arguments (this is relevant for\n the order of initializing variables in extension modules).\n\n + Arguments can be specified to be optional or hidden that\n simplifies calling Fortran programs from Python considerably.\n\n + In principle, one can design any Python signature for a given\n Fortran function, e.g. change the order arguments, introduce\n auxiliary arguments, hide the arguments, process the arguments\n before passing to Fortran, return arguments as output of F2PY\n generated functions, etc.\n\n* F2PY automatically generates __doc__ strings (and optionally LaTeX\n documentation) for extension modules.\n\n* F2PY generated functions accept arbitrary (but sensible) Python\n objects as arguments. The F2PY interface automatically takes care of\n type-casting and handling of non-contiguous arrays.\n\n* The following Fortran constructs are recognized by F2PY:\n\n + All basic Fortran types::\n\n integer[ | *1 | *2 | *4 | *8 ], logical[ | *1 | *2 | *4 | *8 ]\n integer*([ -1 | -2 | -4 | -8 ])\n character[ | *(*) | *1 | *2 | *3 | ... ]\n real[ | *4 | *8 | *16 ], double precision\n complex[ | *8 | *16 | *32 ]\n\n Negative ``integer`` kinds are used to wrap unsigned integers.\n\n + Multi-dimensional arrays of all basic types with the following\n dimension specifications::\n\n | : | * | :\n\n + Attributes and statements::\n \n intent([ in | inout | out | hide | in,out | inout,out | c |\n copy | cache | callback | inplace | aux ])\n dimension()\n common, parameter\n allocatable\n optional, required, external\n depend([])\n check([])\n note()\n usercode, callstatement, callprotoargument, threadsafe, fortranname\n pymethoddef\n entry\n\n* Because there are only little (and easily handleable) differences\n between calling C and Fortran functions from F2PY generated\n extension modules, then F2PY is also well suited for wrapping C\n libraries to Python.\n\n* Practice has shown that F2PY generated interfaces (to C or Fortran\n functions) are less error prone and even more efficient than\n handwritten extension modules. The F2PY generated interfaces are\n easy to maintain and any future optimization of F2PY generated\n interfaces transparently apply to extension modules by just\n regenerating them with the latest version of F2PY.\n\n* `F2PY Users Guide and Reference Manual`_\n\n\n===============\n Prerequisites\n===============\n\nF2PY requires the following software installed:\n\n* Python_ (versions 1.5.2 or later; 2.1 and up are recommended).\n You must have python-dev package installed.\n* NumPy_ (versions 13 or later; 20.x, 21.x, 22.x, 23.x are recommended)\n* Numarray_ (version 0.9 and up), optional, partial support.\n* Scipy_distutils (version 0.2.2 and up are recommended) from SciPy_\n project. Get it from Scipy CVS or download it below.\n\nPython 1.x users also need distutils_.\n\nOf course, to build extension modules, you'll need also working C\nand/or Fortran compilers installed.\n\n==========\n Download\n==========\n\nYou can download the sources for the latest F2PY and numpy_distutils\nreleases as:\n\n* `2.x`__/`F2PY-2-latest.tar.gz`__\n* `2.x`__/`numpy_distutils-latest.tar.gz`__\n\nWindows users might be interested in Win32 installer for F2PY and\nScipy_distutils (these installers are built using Python 2.3):\n\n* `2.x`__/`F2PY-2-latest.win32.exe`__\n* `2.x`__/`numpy_distutils-latest.win32.exe`__\n\nOlder releases are also available in the directories\n`rel-0.x`__, `rel-1.x`__, `rel-2.x`__, `rel-3.x`__, `rel-4.x`__, `rel-5.x`__,\nif you need them.\n\n.. __: 2.x/\n.. __: 2.x/F2PY-2-latest.tar.gz\n.. __: 2.x/\n.. __: 2.x/numpy_distutils-latest.tar.gz\n.. __: 2.x/\n.. __: 2.x/F2PY-2-latest.win32.exe\n.. __: 2.x/\n.. __: 2.x/numpy_distutils-latest.win32.exe\n.. __: rel-0.x\n.. __: rel-1.x\n.. __: rel-2.x\n.. __: rel-3.x\n.. __: rel-4.x\n.. __: rel-5.x\n\nDevelopment version of F2PY from CVS is available as `f2py2e.tar.gz`__.\n\n__ http://cens.ioc.ee/cgi-bin/viewcvs.cgi/python/f2py2e/f2py2e.tar.gz?tarball=1\n\nDebian Sid users can simply install ``python-f2py`` package.\n\n==============\n Installation\n==============\n\nUnpack the source file, change to directrory ``F2PY-?-???/`` and run\n(you may need to become a root)::\n\n python setup.py install\n\nThe F2PY installation installs a Python package ``f2py2e`` to your\nPython ``site-packages`` directory and a script ``f2py`` to your\nPython executable path. \n\nSee also Installation__ section in `F2PY FAQ`_.\n\n.. __: FAQ.html#installation\n\nSimilarly, to install ``numpy_distutils``, unpack its tar-ball and run::\n\n python setup.py install\n\n=======\n Usage\n=======\n\nTo check if F2PY is installed correctly, run\n::\n\n f2py\n\nwithout any arguments. This should print out the usage information of\nthe ``f2py`` program.\n\nNext, try out the following three steps:\n\n1) Create a Fortran file `hello.f`__ that contains::\n\n C File hello.f\n subroutine foo (a)\n integer a\n print*, \"Hello from Fortran!\"\n print*, \"a=\",a\n end\n\n__ hello.f\n\n2) Run\n\n ::\n \n f2py -c -m hello hello.f\n\n This will build an extension module ``hello.so`` (or ``hello.sl``,\n or ``hello.pyd``, etc. depending on your platform) into the current\n directory.\n\n3) Now in Python try::\n\n >>> import hello\n >>> print hello.__doc__\n >>> print hello.foo.__doc__\n >>> hello.foo(4) \n Hello from Fortran!\n a= 4\n >>> \n\nIf the above works, then you can try out more thorough \n`F2PY unit tests`__ and read the `F2PY Users Guide and Reference Manual`_.\n\n__ FAQ.html#q-how-to-test-if-f2py-is-working-correctly\n\n===============\n Documentation\n===============\n\nThe documentation of the F2PY project is collected in ``f2py2e/docs/``\ndirectory. It contains the following documents:\n\n`README.txt`_ (in CVS__)\n The first thing to read about F2PY -- this document.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/README.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`usersguide/index.txt`_, `usersguide/f2py_usersguide.pdf`_\n F2PY Users Guide and Reference Manual. Contains lots of examples.\n\n`FAQ.txt`_ (in CVS__)\n F2PY Frequently Asked Questions.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/FAQ.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`TESTING.txt`_ (in CVS__)\n About F2PY testing site. What tests are available and how to run them.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/TESTING.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`HISTORY.txt`_ (in CVS__)\n A list of latest changes in F2PY. This is the most up-to-date\n document on F2PY.\n\n__ http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n\n`THANKS.txt`_\n Acknowledgments.\n\n..\n `COMPILERS.txt`_\n Compiler and platform specific notes.\n\n===============\n Mailing list\n===============\n\nA mailing list f2py-users@cens.ioc.ee is open for F2PY releated\ndiscussion/questions/etc.\n\n* `Subscribe..`__ \n* `Archives..`__\n\n__ http://cens.ioc.ee/mailman/listinfo/f2py-users\n__ http://cens.ioc.ee/pipermail/f2py-users\n\n\n=====\n CVS\n=====\n\nF2PY is being developed under CVS_. The CVS version of F2PY can be\nobtained as follows:\n\n1) First you need to login (the password is ``guest``)::\n\n cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login\n\n2) and then do the checkout::\n\n cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout f2py2e\n\n3) You can update your local F2PY tree ``f2py2e/`` by executing::\n\n cvs -z6 update -P -d\n\nYou can browse the `F2PY CVS`_ repository.\n\n===============\n Contributions\n===============\n\n* `A short introduction to F2PY`__ by Pierre Schnizer.\n\n* `F2PY notes`__ by Fernando Perez.\n\n* `Debian packages of F2PY`__ by Jos Fonseca. [OBSOLETE, Debian Sid\n ships python-f2py package]\n\n__ http://fubphpc.tu-graz.ac.at/~pierre/f2py_tutorial.tar.gz\n__ http://cens.ioc.ee/pipermail/f2py-users/2003-April/000472.html\n__ http://jrfonseca.dyndns.org/debian/\n\n\n===============\n Related sites\n===============\n\n* `Numerical Python`_ -- adds a fast array facility to the Python language.\n* Pyfort_ -- A Python-Fortran connection tool.\n* SciPy_ -- An open source library of scientific tools for Python.\n* `Scientific Python`_ -- A collection of Python modules that are\n useful for scientific computing.\n* `The Fortran Company`_ -- A place to find products, services, and general\n information related to the Fortran programming language.\n* `American National Standard Programming Language FORTRAN ANSI(R) X3.9-1978`__\n* `J3`_ -- The US Fortran standards committee.\n* SWIG_ -- A software development tool that connects programs written\n in C and C++ with a variety of high-level programming languages. \n* `Mathtools.net`_ -- A technical computing portal for all scientific\n and engineering needs. \n\n.. __: http://www.fortran.com/fortran/F77_std/rjcnf.html\n\n.. References\n ==========\n\n\n.. _F2PY Users Guide and Reference Manual: usersguide/index.html\n.. _usersguide/index.txt: usersguide/index.html\n.. _usersguide/f2py_usersguide.pdf: usersguide/f2py_usersguide.pdf\n.. _README.txt: README.html\n.. _COMPILERS.txt: COMPILERS.html\n.. _F2PY FAQ:\n.. _FAQ.txt: FAQ.html\n.. _HISTORY.txt: HISTORY.html\n.. _HISTORY.txt from CVS: http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/docs/HISTORY.txt?rev=HEAD&content-type=text/x-cvsweb-markup\n.. _THANKS.txt: THANKS.html\n.. _TESTING.txt: TESTING.html\n.. _F2PY CVS2: http://cens.ioc.ee/cgi-bin/cvsweb/python/f2py2e/\n.. _F2PY CVS: http://cens.ioc.ee/cgi-bin/viewcvs.cgi/python/f2py2e/\n\n.. _CVS: http://www.cvshome.org/\n.. _Python: http://www.python.org/\n.. _SciPy: http://www.numpy.org/\n.. _NumPy: http://www.numpy.org/\n.. _Numarray: http://www.stsci.edu/resources/software_hardware/numarray\n.. _docutils: http://docutils.sourceforge.net/\n.. _distutils: http://www.python.org/sigs/distutils-sig/\n.. _LGPL: http://www.fsf.org/copyleft/lesser.html\n.. _Numerical Python: http://www.numpy.org/\n.. _Pyfort: http://pyfortran.sourceforge.net/\n.. _Scientific Python: \n http://starship.python.net/crew/hinsen/scientific.html\n.. _The Fortran Company: http://www.fortran.com/fortran/\n.. _J3: http://www.j3-fortran.org/\n.. _Mathtools.net: http://www.mathtools.net/\n.. _SWIG: http://www.swig.org/\n\n..\n Local Variables:\n mode: indented-text\n indent-tabs-mode: nil\n sentence-end-double-space: t\n fill-column: 70\n End:\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + ":License: NumPy License" + ], + "deleted": [ + ":License: LGPL_.", + ".. _LGPL: http://www.fsf.org/copyleft/lesser.html" + ] + } + }, + { + "old_path": "numpy/f2py/docs/THANKS.txt", + "new_path": "numpy/f2py/docs/THANKS.txt", + "filename": "THANKS.txt", + "extension": "txt", + "change_type": "MODIFY", + "diff": "@@ -3,7 +3,7 @@\n Acknowledgments\n =================\n \n-F2PY__ is a LGPL'd Python package and command line tool developed and\n+F2PY__ is an open source Python package and command line tool developed and\n maintained by Pearu Peterson (me__). \n \n .. __: http://cens.ioc.ee/projects/f2py2e/\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\n=================\n Acknowledgments\n=================\n\nF2PY__ is an open source Python package and command line tool developed and\nmaintained by Pearu Peterson (me__). \n\n.. __: http://cens.ioc.ee/projects/f2py2e/\n.. __: http://cens.ioc.ee/~pearu/\n\nMany people have contributed to the F2PY project in terms of interest,\nencouragement, suggestions, criticism, bug reports, code\ncontributions, and keeping me busy with developing F2PY. For all that\nI thank\n\n James Amundson, John Barnard, David Beazley, Frank Bertoldi, Roman\n Bertle, James Boyle, Moritz Braun, Rolv Erlend Bredesen, John\n Chaffer, Fred Clare, Adam Collard, Ben Cornett, Jose L Gomez Dans,\n Jaime D. Perea Duarte, Paul F Dubois, Thilo Ernst, Bonilla Fabian,\n Martin Gelfand, Eduardo A. Gonzalez, Siegfried Gonzi, Bernhard\n Gschaider, Charles Doutriaux, Jeff Hagelberg, Janko Hauser, Thomas\n Hauser, Heiko Henkelmann, William Henney, Yueqiang Huang, Asim\n Hussain, Berthold Hllmann, Vladimir Janku, Henk Jansen, Curtis\n Jensen, Eric Jones, Tiffany Kamm, Andrey Khavryuchenko, Greg\n Kochanski, Jochen Kpper, Simon Lacoste-Julien, Tim Lahey, Hans\n Petter Langtangen, Jeff Layton, Matthew Lewis, Patrick LeGresley,\n Joaquim R R A Martins, Paul Magwene Lionel Maziere, Craig McNeile,\n Todd Miller, David C. Morrill, Dirk Muders, Kevin Mueller, Andrew\n Mullhaupt, Vijayendra Munikoti, Travis Oliphant, Kevin O'Mara, Arno\n Paehler, Fernando Perez, Didrik Pinte, Todd Alan Pitts, Prabhu\n Ramachandran, Brad Reisfeld, Steve M. Robbins, Theresa Robinson,\n Pedro Rodrigues, Les Schaffer, Christoph Scheurer, Herb Schilling,\n Pierre Schnizer, Kevin Smith, Paulo Teotonio Sobrinho, Jos Rui\n Faustino de Sousa, Andrew Swan, Dustin Tang, Charlie Taylor, Paul le\n Texier, Michael Tiller, Semen Trygubenko, Ravi C Venkatesan, Peter\n Verveer, Nils Wagner, R. Clint Whaley, Erik Wilsher, Martin\n Wiechert, Gilles Zerah, SungPil Yoon.\n\n(This list may not be complete. Please forgive me if I have left you\nout and let me know, I'll add your name.)\n\nSpecial thanks are due to ...\n\nEric Jones - he and Travis O. are responsible for starting the\nnumpy_distutils project that allowed to move most of the platform and\ncompiler specific codes out from F2PY. This simplified maintaining the\nF2PY project considerably.\n\nJoaquim R R A Martins - he made possible for me to test F2PY on IRIX64\nplatform. He also presented our paper about F2PY in the 9th Python\nConference that I planned to attend but had to cancel in very last\nminutes.\n\nTravis Oliphant - his knowledge and experience on Numerical Python\nC/API has been invaluable in early development of the F2PY program.\nHis major contributions are call-back mechanism and copying N-D arrays\nof arbitrary types.\n\nTodd Miller - he is responsible for Numarray support in F2PY.\n\nThanks!\n\tPearu\n", + "source_code_before": "\n=================\n Acknowledgments\n=================\n\nF2PY__ is a LGPL'd Python package and command line tool developed and\nmaintained by Pearu Peterson (me__). \n\n.. __: http://cens.ioc.ee/projects/f2py2e/\n.. __: http://cens.ioc.ee/~pearu/\n\nMany people have contributed to the F2PY project in terms of interest,\nencouragement, suggestions, criticism, bug reports, code\ncontributions, and keeping me busy with developing F2PY. For all that\nI thank\n\n James Amundson, John Barnard, David Beazley, Frank Bertoldi, Roman\n Bertle, James Boyle, Moritz Braun, Rolv Erlend Bredesen, John\n Chaffer, Fred Clare, Adam Collard, Ben Cornett, Jose L Gomez Dans,\n Jaime D. Perea Duarte, Paul F Dubois, Thilo Ernst, Bonilla Fabian,\n Martin Gelfand, Eduardo A. Gonzalez, Siegfried Gonzi, Bernhard\n Gschaider, Charles Doutriaux, Jeff Hagelberg, Janko Hauser, Thomas\n Hauser, Heiko Henkelmann, William Henney, Yueqiang Huang, Asim\n Hussain, Berthold Hllmann, Vladimir Janku, Henk Jansen, Curtis\n Jensen, Eric Jones, Tiffany Kamm, Andrey Khavryuchenko, Greg\n Kochanski, Jochen Kpper, Simon Lacoste-Julien, Tim Lahey, Hans\n Petter Langtangen, Jeff Layton, Matthew Lewis, Patrick LeGresley,\n Joaquim R R A Martins, Paul Magwene Lionel Maziere, Craig McNeile,\n Todd Miller, David C. Morrill, Dirk Muders, Kevin Mueller, Andrew\n Mullhaupt, Vijayendra Munikoti, Travis Oliphant, Kevin O'Mara, Arno\n Paehler, Fernando Perez, Didrik Pinte, Todd Alan Pitts, Prabhu\n Ramachandran, Brad Reisfeld, Steve M. Robbins, Theresa Robinson,\n Pedro Rodrigues, Les Schaffer, Christoph Scheurer, Herb Schilling,\n Pierre Schnizer, Kevin Smith, Paulo Teotonio Sobrinho, Jos Rui\n Faustino de Sousa, Andrew Swan, Dustin Tang, Charlie Taylor, Paul le\n Texier, Michael Tiller, Semen Trygubenko, Ravi C Venkatesan, Peter\n Verveer, Nils Wagner, R. Clint Whaley, Erik Wilsher, Martin\n Wiechert, Gilles Zerah, SungPil Yoon.\n\n(This list may not be complete. Please forgive me if I have left you\nout and let me know, I'll add your name.)\n\nSpecial thanks are due to ...\n\nEric Jones - he and Travis O. are responsible for starting the\nnumpy_distutils project that allowed to move most of the platform and\ncompiler specific codes out from F2PY. This simplified maintaining the\nF2PY project considerably.\n\nJoaquim R R A Martins - he made possible for me to test F2PY on IRIX64\nplatform. He also presented our paper about F2PY in the 9th Python\nConference that I planned to attend but had to cancel in very last\nminutes.\n\nTravis Oliphant - his knowledge and experience on Numerical Python\nC/API has been invaluable in early development of the F2PY program.\nHis major contributions are call-back mechanism and copying N-D arrays\nof arbitrary types.\n\nTodd Miller - he is responsible for Numarray support in F2PY.\n\nThanks!\n\tPearu\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "F2PY__ is an open source Python package and command line tool developed and" + ], + "deleted": [ + "F2PY__ is a LGPL'd Python package and command line tool developed and" + ] + } + }, + { + "old_path": "numpy/f2py/f2py.1", + "new_path": "numpy/f2py/f2py.1", + "filename": "f2py.1", + "extension": "1", + "change_type": "MODIFY", + "diff": "@@ -204,6 +204,6 @@ Scipy website: http://www.numpy.org\n .SH COPYRIGHT\n Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Pearu Peterson\n .SH LICENSE\n-LGPL (see http://www.fsf.org)\n+NumPy License\n .SH VERSION\n 2.45.241\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": ".TH \"F2PY\" 1\n.SH NAME\nf2py \\- Fortran to Python interface generator\n.SH SYNOPSIS\n(1) To construct extension module sources:\n\n.B f2py\n[] [[[only:]||[skip:]] ] [: ...]\n\n(2) To compile fortran files and build extension modules:\n\n.B f2py\n-c [, , ] \n\n(3) To generate signature files:\n\n.B f2py\n-h ...< same options as in (1) >\n.SH DESCRIPTION\nThis program generates a Python C/API file (module.c)\nthat contains wrappers for given Fortran or C functions so that they\ncan be called from Python.\nWith the -c option the corresponding\nextension modules are built.\n.SH OPTIONS\n.TP\n.B \\-h \nWrite signatures of the fortran routines to file and\nexit. You can then edit and use it instead of . If ==stdout then the signatures are printed to\nstdout.\n.TP\n.B \nNames of fortran routines for which Python C/API functions will be\ngenerated. Default is all that are found in .\n.TP\n.B skip:\nIgnore fortran functions that follow until `:'.\n.TP\n.B only:\nUse only fortran functions that follow until `:'.\n.TP\n.B :\nGet back to mode.\n.TP\n.B \\-m \nName of the module; f2py generates a Python/C API file\nmodule.c or extension module . Default is\n\\'untitled\\'.\n.TP\n.B \\-\\-[no\\-]lower\nDo [not] lower the cases in . By default, --lower is\nassumed with -h key, and --no-lower without -h key.\n.TP\n.B \\-\\-build\\-dir \nAll f2py generated files are created in . Default is tempfile.mktemp().\n.TP\n.B \\-\\-overwrite\\-signature\nOverwrite existing signature file.\n.TP\n.B \\-\\-[no\\-]latex\\-doc\nCreate (or not) module.tex. Default is --no-latex-doc.\n.TP\n.B \\-\\-short\\-latex\nCreate 'incomplete' LaTeX document (without commands \\\\documentclass,\n\\\\tableofcontents, and \\\\begin{document}, \\\\end{document}).\n.TP\n.B \\-\\-[no\\-]rest\\-doc\nCreate (or not) module.rst. Default is --no-rest-doc.\n.TP\n.B \\-\\-debug\\-capi\nCreate C/API code that reports the state of the wrappers during\nruntime. Useful for debugging.\n.TP\n.B \\-include\\'\\'\nAdd CPP #include statement to the C/API code. should be\nin the format of either `\"filename.ext\"' or `'. As a\nresult will be included just before wrapper functions\npart in the C/API code. The option is depreciated, use `usercode`\nstatement in signature files instead.\n.TP\n.B \\-\\-[no\\-]wrap\\-functions\nCreate Fortran subroutine wrappers to Fortran 77\nfunctions. --wrap-functions is default because it ensures maximum\nportability/compiler independence.\n.TP\n.B \\-\\-help\\-link [..]\nList system resources found by system_info.py. [..] may contain\na list of resources names. See also --link- switch below.\n.TP\n.B \\-\\-quiet\nRun quietly.\n.TP\n.B \\-\\-verbose\nRun with extra verbosity.\n.TP\n.B \\-v\nPrint f2py version ID and exit.\n.TP\n.B \\-\\-include_paths path1:path2:...\nSearch include files (that f2py will scan) from the given directories.\n.SH \"CONFIG_FC OPTIONS\"\nThe following options are effective only when -c switch is used.\n.TP\n.B \\-\\-help-compiler\nList available Fortran compilers [DEPRECIATED].\n.TP\n.B \\-\\-fcompiler=\nSpecify Fortran compiler type by vendor.\n.TP\n.B \\-\\-compiler=\nSpecify C compiler type (as defined by distutils)\n.TP\n.B \\-\\-fcompiler-exec=\nSpecify the path to F77 compiler [DEPRECIATED].\n.TP\n.B \\-\\-f90compiler\\-exec=\nSpecify the path to F90 compiler [DEPRECIATED].\n.TP\n.B \\-\\-help\\-fcompiler\nList available Fortran compilers and exit.\n.TP\n.B \\-\\-f77exec=\nSpecify the path to F77 compiler.\n.TP\n.B \\-\\-f90exec=\nSpecify the path to F90 compiler.\n.TP\n.B \\-\\-f77flags=\"...\"\nSpecify F77 compiler flags.\n.TP\n.B \\-\\-f90flags=\"...\"\nSpecify F90 compiler flags.\n.TP\n.B \\-\\-opt=\"...\"\nSpecify optimization flags.\n.TP\n.B \\-\\-arch=\"...\"\nSpecify architecture specific optimization flags.\n.TP\n.B \\-\\-noopt\nCompile without optimization.\n.TP\n.B \\-\\-noarch\nCompile without arch-dependent optimization.\n.TP\n.B \\-\\-debug\nCompile with debugging information.\n.SH \"EXTRA OPTIONS\"\nThe following options are effective only when -c switch is used.\n.TP\n.B \\-\\-link- \nLink extension module with as defined by\nnumpy_distutils/system_info.py. E.g. to link with optimized LAPACK\nlibraries (vecLib on MacOSX, ATLAS elsewhere), use\n--link-lapack_opt. See also --help-link switch.\n\n.TP\n.B -L/path/to/lib/ -l\n.TP\n.B -D -U -I/path/to/include/ \n.TP\n.B .o .so .a\n\n.TP\n.B -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN -DUNDERSCORE_G77\nMacros that might be required with non-gcc Fortran compilers. \n\n.TP\n.B -DF2PY_REPORT_ATEXIT\nTo print out a performance report of F2PY interface when python\nexits. Available for Linux.\n\n.TP\n.B -DF2PY_REPORT_ON_ARRAY_COPY=\nTo send a message to stderr whenever F2PY interface makes a copy of an\narray. Integer sets the threshold for array sizes when a message\nshould be shown.\n\n.SH REQUIREMENTS\nPython 1.5.2 or higher (2.x is supported).\n\nNumerical Python 13 or higher (20.x,21.x,22.x,23.x are supported).\n\nOptional Numarray 0.9 or higher partially supported.\n\nnumpy_distutils from Scipy (can be downloaded from F2PY homepage)\n.SH \"SEE ALSO\"\npython(1)\n.SH BUGS\nFor instructions on reporting bugs, see \n\n http://cens.ioc.ee/projects/f2py2e/FAQ.html\n.SH AUTHOR\nPearu Peterson \n.SH \"INTERNET RESOURCES\"\nMain website: http://cens.ioc.ee/projects/f2py2e/\n\nUser's Guide: http://cens.ioc.ee/projects/f2py2e/usersguide/\n\nMailing list: http://cens.ioc.ee/mailman/listinfo/f2py-users/\n\nScipy website: http://www.numpy.org\n.SH COPYRIGHT\nCopyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Pearu Peterson\n.SH LICENSE\nNumPy License\n.SH VERSION\n2.45.241\n", + "source_code_before": ".TH \"F2PY\" 1\n.SH NAME\nf2py \\- Fortran to Python interface generator\n.SH SYNOPSIS\n(1) To construct extension module sources:\n\n.B f2py\n[] [[[only:]||[skip:]] ] [: ...]\n\n(2) To compile fortran files and build extension modules:\n\n.B f2py\n-c [, , ] \n\n(3) To generate signature files:\n\n.B f2py\n-h ...< same options as in (1) >\n.SH DESCRIPTION\nThis program generates a Python C/API file (module.c)\nthat contains wrappers for given Fortran or C functions so that they\ncan be called from Python.\nWith the -c option the corresponding\nextension modules are built.\n.SH OPTIONS\n.TP\n.B \\-h \nWrite signatures of the fortran routines to file and\nexit. You can then edit and use it instead of . If ==stdout then the signatures are printed to\nstdout.\n.TP\n.B \nNames of fortran routines for which Python C/API functions will be\ngenerated. Default is all that are found in .\n.TP\n.B skip:\nIgnore fortran functions that follow until `:'.\n.TP\n.B only:\nUse only fortran functions that follow until `:'.\n.TP\n.B :\nGet back to mode.\n.TP\n.B \\-m \nName of the module; f2py generates a Python/C API file\nmodule.c or extension module . Default is\n\\'untitled\\'.\n.TP\n.B \\-\\-[no\\-]lower\nDo [not] lower the cases in . By default, --lower is\nassumed with -h key, and --no-lower without -h key.\n.TP\n.B \\-\\-build\\-dir \nAll f2py generated files are created in . Default is tempfile.mktemp().\n.TP\n.B \\-\\-overwrite\\-signature\nOverwrite existing signature file.\n.TP\n.B \\-\\-[no\\-]latex\\-doc\nCreate (or not) module.tex. Default is --no-latex-doc.\n.TP\n.B \\-\\-short\\-latex\nCreate 'incomplete' LaTeX document (without commands \\\\documentclass,\n\\\\tableofcontents, and \\\\begin{document}, \\\\end{document}).\n.TP\n.B \\-\\-[no\\-]rest\\-doc\nCreate (or not) module.rst. Default is --no-rest-doc.\n.TP\n.B \\-\\-debug\\-capi\nCreate C/API code that reports the state of the wrappers during\nruntime. Useful for debugging.\n.TP\n.B \\-include\\'\\'\nAdd CPP #include statement to the C/API code. should be\nin the format of either `\"filename.ext\"' or `'. As a\nresult will be included just before wrapper functions\npart in the C/API code. The option is depreciated, use `usercode`\nstatement in signature files instead.\n.TP\n.B \\-\\-[no\\-]wrap\\-functions\nCreate Fortran subroutine wrappers to Fortran 77\nfunctions. --wrap-functions is default because it ensures maximum\nportability/compiler independence.\n.TP\n.B \\-\\-help\\-link [..]\nList system resources found by system_info.py. [..] may contain\na list of resources names. See also --link- switch below.\n.TP\n.B \\-\\-quiet\nRun quietly.\n.TP\n.B \\-\\-verbose\nRun with extra verbosity.\n.TP\n.B \\-v\nPrint f2py version ID and exit.\n.TP\n.B \\-\\-include_paths path1:path2:...\nSearch include files (that f2py will scan) from the given directories.\n.SH \"CONFIG_FC OPTIONS\"\nThe following options are effective only when -c switch is used.\n.TP\n.B \\-\\-help-compiler\nList available Fortran compilers [DEPRECIATED].\n.TP\n.B \\-\\-fcompiler=\nSpecify Fortran compiler type by vendor.\n.TP\n.B \\-\\-compiler=\nSpecify C compiler type (as defined by distutils)\n.TP\n.B \\-\\-fcompiler-exec=\nSpecify the path to F77 compiler [DEPRECIATED].\n.TP\n.B \\-\\-f90compiler\\-exec=\nSpecify the path to F90 compiler [DEPRECIATED].\n.TP\n.B \\-\\-help\\-fcompiler\nList available Fortran compilers and exit.\n.TP\n.B \\-\\-f77exec=\nSpecify the path to F77 compiler.\n.TP\n.B \\-\\-f90exec=\nSpecify the path to F90 compiler.\n.TP\n.B \\-\\-f77flags=\"...\"\nSpecify F77 compiler flags.\n.TP\n.B \\-\\-f90flags=\"...\"\nSpecify F90 compiler flags.\n.TP\n.B \\-\\-opt=\"...\"\nSpecify optimization flags.\n.TP\n.B \\-\\-arch=\"...\"\nSpecify architecture specific optimization flags.\n.TP\n.B \\-\\-noopt\nCompile without optimization.\n.TP\n.B \\-\\-noarch\nCompile without arch-dependent optimization.\n.TP\n.B \\-\\-debug\nCompile with debugging information.\n.SH \"EXTRA OPTIONS\"\nThe following options are effective only when -c switch is used.\n.TP\n.B \\-\\-link- \nLink extension module with as defined by\nnumpy_distutils/system_info.py. E.g. to link with optimized LAPACK\nlibraries (vecLib on MacOSX, ATLAS elsewhere), use\n--link-lapack_opt. See also --help-link switch.\n\n.TP\n.B -L/path/to/lib/ -l\n.TP\n.B -D -U -I/path/to/include/ \n.TP\n.B .o .so .a\n\n.TP\n.B -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN -DUNDERSCORE_G77\nMacros that might be required with non-gcc Fortran compilers. \n\n.TP\n.B -DF2PY_REPORT_ATEXIT\nTo print out a performance report of F2PY interface when python\nexits. Available for Linux.\n\n.TP\n.B -DF2PY_REPORT_ON_ARRAY_COPY=\nTo send a message to stderr whenever F2PY interface makes a copy of an\narray. Integer sets the threshold for array sizes when a message\nshould be shown.\n\n.SH REQUIREMENTS\nPython 1.5.2 or higher (2.x is supported).\n\nNumerical Python 13 or higher (20.x,21.x,22.x,23.x are supported).\n\nOptional Numarray 0.9 or higher partially supported.\n\nnumpy_distutils from Scipy (can be downloaded from F2PY homepage)\n.SH \"SEE ALSO\"\npython(1)\n.SH BUGS\nFor instructions on reporting bugs, see \n\n http://cens.ioc.ee/projects/f2py2e/FAQ.html\n.SH AUTHOR\nPearu Peterson \n.SH \"INTERNET RESOURCES\"\nMain website: http://cens.ioc.ee/projects/f2py2e/\n\nUser's Guide: http://cens.ioc.ee/projects/f2py2e/usersguide/\n\nMailing list: http://cens.ioc.ee/mailman/listinfo/f2py-users/\n\nScipy website: http://www.numpy.org\n.SH COPYRIGHT\nCopyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Pearu Peterson\n.SH LICENSE\nLGPL (see http://www.fsf.org)\n.SH VERSION\n2.45.241\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "NumPy License" + ], + "deleted": [ + "LGPL (see http://www.fsf.org)" + ] + } + }, + { + "old_path": "numpy/f2py/f2py2e.py", + "new_path": "numpy/f2py/f2py2e.py", + "filename": "f2py2e.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,7 +7,7 @@\n Copyright 1999--2005 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/05/06 08:31:19 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nf2py2e - Fortran to Python C/API generator. 2nd Edition.\n See __usage__ below.\n\nCopyright 1999--2005 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 08:31:19 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.90 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport sys,os,string,pprint,shutil,types,re\nerrmess=sys.stderr.write\n#outmess=sys.stdout.write\nshow=pprint.pprint\n\nimport crackfortran\nimport rules\nimport cb_rules\nimport common_rules\nimport auxfuncs\nimport cfuncs\nimport capi_maps\nimport func2subr\nimport f90mod_rules\n\noutmess = auxfuncs.outmess\n\ntry:\n from numpy import __version__ as numpy_version\nexcept ImportError:\n numpy_version = 'N/A'\n\n__usage__ = \"\"\"\\\nUsage:\n\n1) To construct extension module sources:\n\n f2py [] [[[only:]||[skip:]] \\\\\n ] \\\\\n [: ...]\n\n2) To compile fortran files and build extension modules:\n\n f2py -c [, , ] \n\n3) To generate signature files:\n\n f2py -h ...< same options as in (1) >\n\nDescription: This program generates a Python C/API file (module.c)\n that contains wrappers for given fortran functions so that they\n can be called from Python. With the -c option the corresponding\n extension modules are built.\n\nOptions:\n\n -h Write signatures of the fortran routines to file \n and exit. You can then edit and use it instead\n of . If ==stdout then the\n signatures are printed to stdout.\n Names of fortran routines for which Python C/API\n functions will be generated. Default is all that are found\n in .\n Paths to fortran/signature files that will be scanned for\n in order to determine their signatures.\n skip: Ignore fortran functions that follow until `:'.\n only: Use only fortran functions that follow until `:'.\n : Get back to mode.\n\n -m Name of the module; f2py generates a Python/C API\n file module.c or extension module .\n Default is 'untitled'.\n\n --[no-]lower Do [not] lower the cases in . By default,\n --lower is assumed with -h key, and --no-lower without -h key.\n\n --build-dir All f2py generated files are created in .\n Default is tempfile.mktemp().\n\n --overwrite-signature Overwrite existing signature file.\n\n --[no-]latex-doc Create (or not) module.tex.\n Default is --no-latex-doc.\n --short-latex Create 'incomplete' LaTeX document (without commands\n \\\\documentclass, \\\\tableofcontents, and \\\\begin{document},\n \\\\end{document}).\n\n --[no-]rest-doc Create (or not) module.rst.\n Default is --no-rest-doc.\n\n --debug-capi Create C/API code that reports the state of the wrappers\n during runtime. Useful for debugging.\n\n --[no-]wrap-functions Create Fortran subroutine wrappers to Fortran 77\n functions. --wrap-functions is default because it ensures\n maximum portability/compiler independence.\n\n --include_paths ::... Search include files from the given\n directories.\n\n --help-link [..] List system resources found by system_info.py. See also\n --link- switch below. [..] is optional list\n of resources names. E.g. try 'f2py --help-link lapack_opt'.\n\n --quiet Run quietly.\n --verbose Run with extra verbosity.\n -v Print f2py version ID and exit.\n\n\nnumpy.distutils options (only effective with -c):\n\n --fcompiler= Specify Fortran compiler type by vendor\n --compiler= Specify C compiler type (as defined by distutils)\n\n --help-fcompiler List available Fortran compilers and exit\n --f77exec= Specify the path to F77 compiler\n --f90exec= Specify the path to F90 compiler\n --f77flags= Specify F77 compiler flags\n --f90flags= Specify F90 compiler flags\n --opt= Specify optimization flags\n --arch= Specify architecture specific optimization flags\n --noopt Compile without optimization\n --noarch Compile without arch-dependent optimization\n --debug Compile with debugging information\n\nExtra options (only effective with -c):\n\n --link- Link extension module with as defined\n by numpy.distutils/system_info.py. E.g. to link\n with optimized LAPACK libraries (vecLib on MacOSX,\n ATLAS elsewhere), use --link-lapack_opt.\n See also --help-link switch.\n\n -L/path/to/lib/ -l\n -D -U\n -I/path/to/include/\n .o .so .a\n\n Using the following macros may be required with non-gcc Fortran\n compilers:\n -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN\n -DUNDERSCORE_G77\n\n When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY\n interface is printed out at exit (platforms: Linux).\n\n When using -DF2PY_REPORT_ON_ARRAY_COPY=, a message is\n sent to stderr whenever F2PY interface makes a copy of an\n array. Integer sets the threshold for array sizes when\n a message should be shown.\n\nVersion: %s\nnumpy Version: %s\nRequires: Python 2.3 or higher.\nLicense: LGPL (see http://www.fsf.org)\nCopyright 1999 - 2005 Pearu Peterson all rights reserved.\nhttp://cens.ioc.ee/projects/f2py2e/\"\"\"%(f2py_version, numpy_version)\n\n\ndef scaninputline(inputline):\n files,funcs,skipfuncs,onlyfuncs,debug=[],[],[],[],[]\n f,f2,f3,f4,f5,f6,f7=1,0,0,0,0,0,0\n verbose = 1\n dolc=-1\n dolatexdoc = 0\n dorestdoc = 0\n wrapfuncs = 1\n buildpath = '.'\n include_paths = []\n signsfile,modulename=None,None\n options = {'buildpath':buildpath}\n for l in inputline:\n if l=='': pass\n elif l=='only:': f=0\n elif l=='skip:': f=-1\n elif l==':': f=1;f4=0\n elif l[:8]=='--debug-': debug.append(l[8:])\n elif l=='--lower': dolc=1\n elif l=='--build-dir': f6=1\n elif l=='--no-lower': dolc=0\n elif l=='--quiet': verbose = 0\n elif l=='--verbose': verbose += 1\n elif l=='--latex-doc': dolatexdoc=1\n elif l=='--no-latex-doc': dolatexdoc=0\n elif l=='--rest-doc': dorestdoc=1\n elif l=='--no-rest-doc': dorestdoc=0\n elif l=='--wrap-functions': wrapfuncs=1\n elif l=='--no-wrap-functions': wrapfuncs=0\n elif l=='--short-latex': options['shortlatex']=1\n elif l=='--overwrite-signature': options['h-overwrite']=1\n elif l=='-h': f2=1\n elif l=='-m': f3=1\n elif l[:2]=='-v':\n print f2py_version\n sys.exit()\n elif l=='--show-compilers':\n f5=1\n elif l[:8]=='-include':\n cfuncs.outneeds['userincludes'].append(l[9:-1])\n cfuncs.userincludes[l[9:-1]]='#include '+l[8:]\n elif l[:15]=='--include_paths':\n f7=1\n elif l[0]=='-':\n errmess('Unknown option %s\\n'%`l`)\n sys.exit()\n elif f2: f2=0;signsfile=l\n elif f3: f3=0;modulename=l\n elif f6: f6=0;buildpath=l\n elif f7: f7=0;include_paths.extend(l.split(os.pathsep))\n elif f==1:\n try:\n open(l).close()\n files.append(l)\n except IOError,detail:\n errmess('IOError: %s. Skipping file \"%s\".\\n'%(str(detail),l))\n elif f==-1: skipfuncs.append(l)\n elif f==0: onlyfuncs.append(l)\n if not f5 and not files and not modulename:\n print __usage__\n sys.exit()\n if not os.path.isdir(buildpath):\n if not verbose:\n outmess('Creating build directory %s'%(buildpath))\n os.mkdir(buildpath)\n if signsfile:\n signsfile = os.path.join(buildpath,signsfile)\n if signsfile and os.path.isfile(signsfile) and not options.has_key('h-overwrite'):\n errmess('Signature file \"%s\" exists!!! Use --overwrite-signature to overwrite.\\n'%(signsfile))\n sys.exit()\n\n options['debug']=debug\n options['verbose']=verbose\n if dolc==-1 and not signsfile: options['do-lower']=0\n else: options['do-lower']=dolc\n if modulename: options['module']=modulename\n if signsfile: options['signsfile']=signsfile\n if onlyfuncs: options['onlyfuncs']=onlyfuncs\n if skipfuncs: options['skipfuncs']=skipfuncs\n options['dolatexdoc'] = dolatexdoc\n options['dorestdoc'] = dorestdoc\n options['wrapfuncs'] = wrapfuncs\n options['buildpath']=buildpath\n options['include_paths']=include_paths\n return files,options\n\ndef callcrackfortran(files,options):\n rules.options=options\n funcs=[]\n crackfortran.debug=options['debug']\n crackfortran.verbose=options['verbose']\n if options.has_key('module'):\n crackfortran.f77modulename=options['module']\n if options.has_key('skipfuncs'):\n crackfortran.skipfuncs=options['skipfuncs']\n if options.has_key('onlyfuncs'):\n crackfortran.onlyfuncs=options['onlyfuncs']\n crackfortran.include_paths[:]=options['include_paths']\n crackfortran.dolowercase=options['do-lower']\n postlist=crackfortran.crackfortran(files)\n if options.has_key('signsfile'):\n outmess('Saving signatures to file \"%s\"\\n'%(options['signsfile']))\n pyf=crackfortran.crack2fortran(postlist)\n if options['signsfile'][-6:]=='stdout':\n sys.stdout.write(pyf)\n else:\n f=open(options['signsfile'],'w')\n f.write(pyf)\n f.close()\n return postlist\n\ndef buildmodules(list):\n cfuncs.buildcfuncs()\n outmess('Building modules...\\n')\n modules,mnames,isusedby=[],[],{}\n for i in range(len(list)):\n if string.find(list[i]['name'],'__user__')>=0:\n cb_rules.buildcallbacks(list[i])\n else:\n if list[i].has_key('use'):\n for u in list[i]['use'].keys():\n if not isusedby.has_key(u): isusedby[u]=[]\n isusedby[u].append(list[i]['name'])\n modules.append(list[i])\n mnames.append(list[i]['name'])\n ret = {}\n for i in range(len(mnames)):\n if isusedby.has_key(mnames[i]):\n outmess('\\tSkipping module \"%s\" which is used by %s.\\n'%(mnames[i],string.join(map(lambda s:'\"%s\"'%s,isusedby[mnames[i]]),',')))\n else:\n um=[]\n if modules[i].has_key('use'):\n for u in modules[i]['use'].keys():\n if isusedby.has_key(u) and u in mnames:\n um.append(modules[mnames.index(u)])\n else:\n outmess('\\tModule \"%s\" uses nonexisting \"%s\" which will be ignored.\\n'%(mnames[i],u))\n ret[mnames[i]] = {}\n dict_append(ret[mnames[i]],rules.buildmodule(modules[i],um))\n return ret\n\ndef dict_append(d_out,d_in):\n for (k,v) in d_in.items():\n if not d_out.has_key(k):\n d_out[k] = []\n if type(v) is types.ListType:\n d_out[k] = d_out[k] + v\n else:\n d_out[k].append(v)\n\ndef run_main(comline_list):\n \"\"\"Run f2py as if string.join(comline_list,' ') is used as a command line.\n In case of using -h flag, return None.\n \"\"\"\n reload(crackfortran)\n f2pydir=os.path.dirname(os.path.abspath(cfuncs.__file__))\n fobjhsrc = os.path.join(f2pydir,'src','fortranobject.h')\n fobjcsrc = os.path.join(f2pydir,'src','fortranobject.c')\n files,options=scaninputline(comline_list)\n auxfuncs.options=options \n postlist=callcrackfortran(files,options)\n isusedby={}\n for i in range(len(postlist)):\n if postlist[i].has_key('use'):\n for u in postlist[i]['use'].keys():\n if not isusedby.has_key(u): isusedby[u]=[]\n isusedby[u].append(postlist[i]['name'])\n for i in range(len(postlist)):\n if postlist[i]['block']=='python module' and string.find(postlist[i]['name'],'__user__')<0:\n if isusedby.has_key(postlist[i]['name']):\n #if not quiet:\n outmess('Skipping Makefile build for module \"%s\" which is used by %s\\n'%(postlist[i]['name'],string.join(map(lambda s:'\"%s\"'%s,isusedby[postlist[i]['name']]),',')))\n if options.has_key('signsfile'):\n if options['verbose']>1:\n outmess('Stopping. Edit the signature file and then run f2py on the signature file: ')\n outmess('%s %s\\n'%(os.path.basename(sys.argv[0]),options['signsfile']))\n return\n for i in range(len(postlist)):\n if postlist[i]['block']!='python module':\n if not options.has_key('python module'):\n errmess('Tip: If your original code is Fortran 77 then you must use -m option.\\n')\n raise TypeError,'All blocks must be module blocks but got %s'%(`postlist[i]['block']`)\n auxfuncs.debugoptions=options['debug']\n f90mod_rules.options=options\n auxfuncs.wrapfuncs=options['wrapfuncs']\n\n ret=buildmodules(postlist)\n\n for mn in ret.keys():\n dict_append(ret[mn],{'csrc':fobjcsrc,'h':fobjhsrc})\n return ret\n\ndef filter_files(prefix,suffix,files,remove_prefix=None):\n \"\"\"\n Filter files by prefix and suffix.\n \"\"\"\n filtered,rest = [],[]\n match = re.compile(prefix+r'.*'+suffix+r'\\Z').match\n if remove_prefix:\n ind = len(prefix)\n else:\n ind = 0\n for file in map(string.strip,files):\n if match(file): filtered.append(file[ind:])\n else: rest.append(file)\n return filtered,rest\n\ndef get_prefix(module):\n p = os.path.dirname(os.path.dirname(module.__file__))\n return p\n\ndef run_compile():\n \"\"\"\n Do it all in one call!\n \"\"\"\n import tempfile,os,shutil\n\n i = sys.argv.index('-c')\n del sys.argv[i]\n\n remove_build_dir = 0\n try: i = sys.argv.index('--build-dir')\n except ValueError: i=None\n if i is not None:\n build_dir = sys.argv[i+1]\n del sys.argv[i+1]\n del sys.argv[i]\n else:\n remove_build_dir = 1\n build_dir = os.path.join(tempfile.mktemp())\n\n sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)\n if sysinfo_flags:\n sysinfo_flags = [f[7:] for f in sysinfo_flags]\n\n f2py_flags = filter(re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=f2py_flags:a not in flags,sys.argv)\n f2py_flags2 = []\n fl = 0\n for a in sys.argv[1:]:\n if a in ['only:','skip:']:\n fl = 1\n elif a==':':\n fl = 0\n if fl or a==':':\n f2py_flags2.append(a)\n if f2py_flags2 and f2py_flags2[-1]!=':':\n f2py_flags2.append(':')\n f2py_flags.extend(f2py_flags2)\n\n sys.argv = filter(lambda a,flags=f2py_flags2:a not in flags,sys.argv)\n \n flib_flags = filter(re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=flib_flags:a not in flags,sys.argv)\n fc_flags = filter(re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=fc_flags:a not in flags,sys.argv)\n\n if 1:\n del_list = []\n for s in flib_flags:\n v = '--fcompiler='\n if s[:len(v)]==v:\n from numpy.distutils import fcompiler\n allowed_keys = fcompiler.fcompiler_class.keys()\n nv = ov = s[len(v):].lower()\n if ov not in allowed_keys:\n vmap = {} # XXX\n try:\n nv = vmap[ov]\n except KeyError:\n if ov not in vmap.values():\n print 'Unknown vendor: \"%s\"' % (s[len(v):])\n nv = ov\n i = flib_flags.index(s)\n flib_flags[i] = '--fcompiler=' + nv\n continue\n for s in del_list:\n i = flib_flags.index(s)\n del flib_flags[i]\n assert len(flib_flags)<=2,`flib_flags`\n setup_flags = filter(re.compile(r'[-][-](verbose)').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=setup_flags:a not in flags,sys.argv)\n if '--quiet' in f2py_flags:\n setup_flags.append('--quiet')\n\n modulename = 'untitled'\n sources = sys.argv[1:]\n if '-m' in sys.argv:\n i = sys.argv.index('-m')\n modulename = sys.argv[i+1]\n del sys.argv[i+1],sys.argv[i]\n sources = sys.argv[1:]\n else:\n from numpy.distutils.command.build_src import get_f2py_modulename\n pyf_files,sources = filter_files('','[.]pyf([.]src|)',sources)\n sources = pyf_files + sources\n for f in pyf_files:\n modulename = get_f2py_modulename(f)\n if modulename:\n break\n\n extra_objects, sources = filter_files('','[.](o|a|so)',sources)\n include_dirs, sources = filter_files('-I','',sources,remove_prefix=1)\n library_dirs, sources = filter_files('-L','',sources,remove_prefix=1)\n libraries, sources = filter_files('-l','',sources,remove_prefix=1)\n undef_macros, sources = filter_files('-U','',sources,remove_prefix=1)\n define_macros, sources = filter_files('-D','',sources,remove_prefix=1)\n using_numarray = 0\n using_numeric = 0\n for i in range(len(define_macros)):\n name_value = string.split(define_macros[i],'=',1)\n if len(name_value)==1:\n name_value.append(None)\n if len(name_value)==2:\n define_macros[i] = tuple(name_value)\n else:\n print 'Invalid use of -D:',name_value\n\n from numpy.distutils.system_info import get_info\n\n num_include_dir = None\n num_info = {}\n #import numpy\n #n = 'numpy'\n #p = get_prefix(numpy)\n #from numpy.distutils.misc_util import get_numpy_include_dirs\n #num_info = {'include_dirs': get_numpy_include_dirs()}\n\n if num_info:\n include_dirs.extend(num_info.get('include_dirs',[]))\n\n from numpy.distutils.core import setup,Extension\n ext_args = {'name':modulename,'sources':sources,\n 'include_dirs': include_dirs,\n 'library_dirs': library_dirs,\n 'libraries': libraries,\n 'define_macros': define_macros,\n 'undef_macros': undef_macros,\n 'extra_objects': extra_objects,\n 'f2py_options': f2py_flags,\n }\n\n if sysinfo_flags:\n from numpy.distutils.misc_util import dict_append\n for n in sysinfo_flags:\n i = get_info(n)\n if not i:\n outmess('No %s resources found in system'\\\n ' (try `f2py --help-link`)\\n' % (`n`))\n dict_append(ext_args,**i)\n\n ext = Extension(**ext_args)\n sys.argv = [sys.argv[0]] + setup_flags\n sys.argv.extend(['build',\n '--build-temp',build_dir,\n '--build-base',build_dir,\n '--build-platlib','.'])\n if fc_flags:\n sys.argv.extend(['config_fc']+fc_flags)\n if flib_flags:\n sys.argv.extend(['build_ext']+flib_flags)\n\n setup(ext_modules = [ext])\n\n if remove_build_dir and os.path.exists(build_dir):\n outmess('Removing build directory %s\\n'%(build_dir))\n shutil.rmtree(build_dir)\n\ndef main():\n if '--help-link' in sys.argv[1:]:\n sys.argv.remove('--help-link')\n from numpy.distutils.system_info import show_all\n show_all()\n return\n if '-c' in sys.argv[1:]:\n run_compile()\n else:\n run_main(sys.argv[1:])\n\n#if __name__ == \"__main__\":\n# main()\n\n\n# EOF\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nf2py2e - Fortran to Python C/API generator. 2nd Edition.\n See __usage__ below.\n\nCopyright 1999--2005 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/05/06 08:31:19 $\nPearu Peterson\n\"\"\"\n__version__ = \"$Revision: 1.90 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport sys,os,string,pprint,shutil,types,re\nerrmess=sys.stderr.write\n#outmess=sys.stdout.write\nshow=pprint.pprint\n\nimport crackfortran\nimport rules\nimport cb_rules\nimport common_rules\nimport auxfuncs\nimport cfuncs\nimport capi_maps\nimport func2subr\nimport f90mod_rules\n\noutmess = auxfuncs.outmess\n\ntry:\n from numpy import __version__ as numpy_version\nexcept ImportError:\n numpy_version = 'N/A'\n\n__usage__ = \"\"\"\\\nUsage:\n\n1) To construct extension module sources:\n\n f2py [] [[[only:]||[skip:]] \\\\\n ] \\\\\n [: ...]\n\n2) To compile fortran files and build extension modules:\n\n f2py -c [, , ] \n\n3) To generate signature files:\n\n f2py -h ...< same options as in (1) >\n\nDescription: This program generates a Python C/API file (module.c)\n that contains wrappers for given fortran functions so that they\n can be called from Python. With the -c option the corresponding\n extension modules are built.\n\nOptions:\n\n -h Write signatures of the fortran routines to file \n and exit. You can then edit and use it instead\n of . If ==stdout then the\n signatures are printed to stdout.\n Names of fortran routines for which Python C/API\n functions will be generated. Default is all that are found\n in .\n Paths to fortran/signature files that will be scanned for\n in order to determine their signatures.\n skip: Ignore fortran functions that follow until `:'.\n only: Use only fortran functions that follow until `:'.\n : Get back to mode.\n\n -m Name of the module; f2py generates a Python/C API\n file module.c or extension module .\n Default is 'untitled'.\n\n --[no-]lower Do [not] lower the cases in . By default,\n --lower is assumed with -h key, and --no-lower without -h key.\n\n --build-dir All f2py generated files are created in .\n Default is tempfile.mktemp().\n\n --overwrite-signature Overwrite existing signature file.\n\n --[no-]latex-doc Create (or not) module.tex.\n Default is --no-latex-doc.\n --short-latex Create 'incomplete' LaTeX document (without commands\n \\\\documentclass, \\\\tableofcontents, and \\\\begin{document},\n \\\\end{document}).\n\n --[no-]rest-doc Create (or not) module.rst.\n Default is --no-rest-doc.\n\n --debug-capi Create C/API code that reports the state of the wrappers\n during runtime. Useful for debugging.\n\n --[no-]wrap-functions Create Fortran subroutine wrappers to Fortran 77\n functions. --wrap-functions is default because it ensures\n maximum portability/compiler independence.\n\n --include_paths ::... Search include files from the given\n directories.\n\n --help-link [..] List system resources found by system_info.py. See also\n --link- switch below. [..] is optional list\n of resources names. E.g. try 'f2py --help-link lapack_opt'.\n\n --quiet Run quietly.\n --verbose Run with extra verbosity.\n -v Print f2py version ID and exit.\n\n\nnumpy.distutils options (only effective with -c):\n\n --fcompiler= Specify Fortran compiler type by vendor\n --compiler= Specify C compiler type (as defined by distutils)\n\n --help-fcompiler List available Fortran compilers and exit\n --f77exec= Specify the path to F77 compiler\n --f90exec= Specify the path to F90 compiler\n --f77flags= Specify F77 compiler flags\n --f90flags= Specify F90 compiler flags\n --opt= Specify optimization flags\n --arch= Specify architecture specific optimization flags\n --noopt Compile without optimization\n --noarch Compile without arch-dependent optimization\n --debug Compile with debugging information\n\nExtra options (only effective with -c):\n\n --link- Link extension module with as defined\n by numpy.distutils/system_info.py. E.g. to link\n with optimized LAPACK libraries (vecLib on MacOSX,\n ATLAS elsewhere), use --link-lapack_opt.\n See also --help-link switch.\n\n -L/path/to/lib/ -l\n -D -U\n -I/path/to/include/\n .o .so .a\n\n Using the following macros may be required with non-gcc Fortran\n compilers:\n -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN\n -DUNDERSCORE_G77\n\n When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY\n interface is printed out at exit (platforms: Linux).\n\n When using -DF2PY_REPORT_ON_ARRAY_COPY=, a message is\n sent to stderr whenever F2PY interface makes a copy of an\n array. Integer sets the threshold for array sizes when\n a message should be shown.\n\nVersion: %s\nnumpy Version: %s\nRequires: Python 2.3 or higher.\nLicense: LGPL (see http://www.fsf.org)\nCopyright 1999 - 2005 Pearu Peterson all rights reserved.\nhttp://cens.ioc.ee/projects/f2py2e/\"\"\"%(f2py_version, numpy_version)\n\n\ndef scaninputline(inputline):\n files,funcs,skipfuncs,onlyfuncs,debug=[],[],[],[],[]\n f,f2,f3,f4,f5,f6,f7=1,0,0,0,0,0,0\n verbose = 1\n dolc=-1\n dolatexdoc = 0\n dorestdoc = 0\n wrapfuncs = 1\n buildpath = '.'\n include_paths = []\n signsfile,modulename=None,None\n options = {'buildpath':buildpath}\n for l in inputline:\n if l=='': pass\n elif l=='only:': f=0\n elif l=='skip:': f=-1\n elif l==':': f=1;f4=0\n elif l[:8]=='--debug-': debug.append(l[8:])\n elif l=='--lower': dolc=1\n elif l=='--build-dir': f6=1\n elif l=='--no-lower': dolc=0\n elif l=='--quiet': verbose = 0\n elif l=='--verbose': verbose += 1\n elif l=='--latex-doc': dolatexdoc=1\n elif l=='--no-latex-doc': dolatexdoc=0\n elif l=='--rest-doc': dorestdoc=1\n elif l=='--no-rest-doc': dorestdoc=0\n elif l=='--wrap-functions': wrapfuncs=1\n elif l=='--no-wrap-functions': wrapfuncs=0\n elif l=='--short-latex': options['shortlatex']=1\n elif l=='--overwrite-signature': options['h-overwrite']=1\n elif l=='-h': f2=1\n elif l=='-m': f3=1\n elif l[:2]=='-v':\n print f2py_version\n sys.exit()\n elif l=='--show-compilers':\n f5=1\n elif l[:8]=='-include':\n cfuncs.outneeds['userincludes'].append(l[9:-1])\n cfuncs.userincludes[l[9:-1]]='#include '+l[8:]\n elif l[:15]=='--include_paths':\n f7=1\n elif l[0]=='-':\n errmess('Unknown option %s\\n'%`l`)\n sys.exit()\n elif f2: f2=0;signsfile=l\n elif f3: f3=0;modulename=l\n elif f6: f6=0;buildpath=l\n elif f7: f7=0;include_paths.extend(l.split(os.pathsep))\n elif f==1:\n try:\n open(l).close()\n files.append(l)\n except IOError,detail:\n errmess('IOError: %s. Skipping file \"%s\".\\n'%(str(detail),l))\n elif f==-1: skipfuncs.append(l)\n elif f==0: onlyfuncs.append(l)\n if not f5 and not files and not modulename:\n print __usage__\n sys.exit()\n if not os.path.isdir(buildpath):\n if not verbose:\n outmess('Creating build directory %s'%(buildpath))\n os.mkdir(buildpath)\n if signsfile:\n signsfile = os.path.join(buildpath,signsfile)\n if signsfile and os.path.isfile(signsfile) and not options.has_key('h-overwrite'):\n errmess('Signature file \"%s\" exists!!! Use --overwrite-signature to overwrite.\\n'%(signsfile))\n sys.exit()\n\n options['debug']=debug\n options['verbose']=verbose\n if dolc==-1 and not signsfile: options['do-lower']=0\n else: options['do-lower']=dolc\n if modulename: options['module']=modulename\n if signsfile: options['signsfile']=signsfile\n if onlyfuncs: options['onlyfuncs']=onlyfuncs\n if skipfuncs: options['skipfuncs']=skipfuncs\n options['dolatexdoc'] = dolatexdoc\n options['dorestdoc'] = dorestdoc\n options['wrapfuncs'] = wrapfuncs\n options['buildpath']=buildpath\n options['include_paths']=include_paths\n return files,options\n\ndef callcrackfortran(files,options):\n rules.options=options\n funcs=[]\n crackfortran.debug=options['debug']\n crackfortran.verbose=options['verbose']\n if options.has_key('module'):\n crackfortran.f77modulename=options['module']\n if options.has_key('skipfuncs'):\n crackfortran.skipfuncs=options['skipfuncs']\n if options.has_key('onlyfuncs'):\n crackfortran.onlyfuncs=options['onlyfuncs']\n crackfortran.include_paths[:]=options['include_paths']\n crackfortran.dolowercase=options['do-lower']\n postlist=crackfortran.crackfortran(files)\n if options.has_key('signsfile'):\n outmess('Saving signatures to file \"%s\"\\n'%(options['signsfile']))\n pyf=crackfortran.crack2fortran(postlist)\n if options['signsfile'][-6:]=='stdout':\n sys.stdout.write(pyf)\n else:\n f=open(options['signsfile'],'w')\n f.write(pyf)\n f.close()\n return postlist\n\ndef buildmodules(list):\n cfuncs.buildcfuncs()\n outmess('Building modules...\\n')\n modules,mnames,isusedby=[],[],{}\n for i in range(len(list)):\n if string.find(list[i]['name'],'__user__')>=0:\n cb_rules.buildcallbacks(list[i])\n else:\n if list[i].has_key('use'):\n for u in list[i]['use'].keys():\n if not isusedby.has_key(u): isusedby[u]=[]\n isusedby[u].append(list[i]['name'])\n modules.append(list[i])\n mnames.append(list[i]['name'])\n ret = {}\n for i in range(len(mnames)):\n if isusedby.has_key(mnames[i]):\n outmess('\\tSkipping module \"%s\" which is used by %s.\\n'%(mnames[i],string.join(map(lambda s:'\"%s\"'%s,isusedby[mnames[i]]),',')))\n else:\n um=[]\n if modules[i].has_key('use'):\n for u in modules[i]['use'].keys():\n if isusedby.has_key(u) and u in mnames:\n um.append(modules[mnames.index(u)])\n else:\n outmess('\\tModule \"%s\" uses nonexisting \"%s\" which will be ignored.\\n'%(mnames[i],u))\n ret[mnames[i]] = {}\n dict_append(ret[mnames[i]],rules.buildmodule(modules[i],um))\n return ret\n\ndef dict_append(d_out,d_in):\n for (k,v) in d_in.items():\n if not d_out.has_key(k):\n d_out[k] = []\n if type(v) is types.ListType:\n d_out[k] = d_out[k] + v\n else:\n d_out[k].append(v)\n\ndef run_main(comline_list):\n \"\"\"Run f2py as if string.join(comline_list,' ') is used as a command line.\n In case of using -h flag, return None.\n \"\"\"\n reload(crackfortran)\n f2pydir=os.path.dirname(os.path.abspath(cfuncs.__file__))\n fobjhsrc = os.path.join(f2pydir,'src','fortranobject.h')\n fobjcsrc = os.path.join(f2pydir,'src','fortranobject.c')\n files,options=scaninputline(comline_list)\n auxfuncs.options=options \n postlist=callcrackfortran(files,options)\n isusedby={}\n for i in range(len(postlist)):\n if postlist[i].has_key('use'):\n for u in postlist[i]['use'].keys():\n if not isusedby.has_key(u): isusedby[u]=[]\n isusedby[u].append(postlist[i]['name'])\n for i in range(len(postlist)):\n if postlist[i]['block']=='python module' and string.find(postlist[i]['name'],'__user__')<0:\n if isusedby.has_key(postlist[i]['name']):\n #if not quiet:\n outmess('Skipping Makefile build for module \"%s\" which is used by %s\\n'%(postlist[i]['name'],string.join(map(lambda s:'\"%s\"'%s,isusedby[postlist[i]['name']]),',')))\n if options.has_key('signsfile'):\n if options['verbose']>1:\n outmess('Stopping. Edit the signature file and then run f2py on the signature file: ')\n outmess('%s %s\\n'%(os.path.basename(sys.argv[0]),options['signsfile']))\n return\n for i in range(len(postlist)):\n if postlist[i]['block']!='python module':\n if not options.has_key('python module'):\n errmess('Tip: If your original code is Fortran 77 then you must use -m option.\\n')\n raise TypeError,'All blocks must be module blocks but got %s'%(`postlist[i]['block']`)\n auxfuncs.debugoptions=options['debug']\n f90mod_rules.options=options\n auxfuncs.wrapfuncs=options['wrapfuncs']\n\n ret=buildmodules(postlist)\n\n for mn in ret.keys():\n dict_append(ret[mn],{'csrc':fobjcsrc,'h':fobjhsrc})\n return ret\n\ndef filter_files(prefix,suffix,files,remove_prefix=None):\n \"\"\"\n Filter files by prefix and suffix.\n \"\"\"\n filtered,rest = [],[]\n match = re.compile(prefix+r'.*'+suffix+r'\\Z').match\n if remove_prefix:\n ind = len(prefix)\n else:\n ind = 0\n for file in map(string.strip,files):\n if match(file): filtered.append(file[ind:])\n else: rest.append(file)\n return filtered,rest\n\ndef get_prefix(module):\n p = os.path.dirname(os.path.dirname(module.__file__))\n return p\n\ndef run_compile():\n \"\"\"\n Do it all in one call!\n \"\"\"\n import tempfile,os,shutil\n\n i = sys.argv.index('-c')\n del sys.argv[i]\n\n remove_build_dir = 0\n try: i = sys.argv.index('--build-dir')\n except ValueError: i=None\n if i is not None:\n build_dir = sys.argv[i+1]\n del sys.argv[i+1]\n del sys.argv[i]\n else:\n remove_build_dir = 1\n build_dir = os.path.join(tempfile.mktemp())\n\n sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)\n if sysinfo_flags:\n sysinfo_flags = [f[7:] for f in sysinfo_flags]\n\n f2py_flags = filter(re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=f2py_flags:a not in flags,sys.argv)\n f2py_flags2 = []\n fl = 0\n for a in sys.argv[1:]:\n if a in ['only:','skip:']:\n fl = 1\n elif a==':':\n fl = 0\n if fl or a==':':\n f2py_flags2.append(a)\n if f2py_flags2 and f2py_flags2[-1]!=':':\n f2py_flags2.append(':')\n f2py_flags.extend(f2py_flags2)\n\n sys.argv = filter(lambda a,flags=f2py_flags2:a not in flags,sys.argv)\n \n flib_flags = filter(re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=flib_flags:a not in flags,sys.argv)\n fc_flags = filter(re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=fc_flags:a not in flags,sys.argv)\n\n if 1:\n del_list = []\n for s in flib_flags:\n v = '--fcompiler='\n if s[:len(v)]==v:\n from numpy.distutils import fcompiler\n allowed_keys = fcompiler.fcompiler_class.keys()\n nv = ov = s[len(v):].lower()\n if ov not in allowed_keys:\n vmap = {} # XXX\n try:\n nv = vmap[ov]\n except KeyError:\n if ov not in vmap.values():\n print 'Unknown vendor: \"%s\"' % (s[len(v):])\n nv = ov\n i = flib_flags.index(s)\n flib_flags[i] = '--fcompiler=' + nv\n continue\n for s in del_list:\n i = flib_flags.index(s)\n del flib_flags[i]\n assert len(flib_flags)<=2,`flib_flags`\n setup_flags = filter(re.compile(r'[-][-](verbose)').match,sys.argv[1:])\n sys.argv = filter(lambda a,flags=setup_flags:a not in flags,sys.argv)\n if '--quiet' in f2py_flags:\n setup_flags.append('--quiet')\n\n modulename = 'untitled'\n sources = sys.argv[1:]\n if '-m' in sys.argv:\n i = sys.argv.index('-m')\n modulename = sys.argv[i+1]\n del sys.argv[i+1],sys.argv[i]\n sources = sys.argv[1:]\n else:\n from numpy.distutils.command.build_src import get_f2py_modulename\n pyf_files,sources = filter_files('','[.]pyf([.]src|)',sources)\n sources = pyf_files + sources\n for f in pyf_files:\n modulename = get_f2py_modulename(f)\n if modulename:\n break\n\n extra_objects, sources = filter_files('','[.](o|a|so)',sources)\n include_dirs, sources = filter_files('-I','',sources,remove_prefix=1)\n library_dirs, sources = filter_files('-L','',sources,remove_prefix=1)\n libraries, sources = filter_files('-l','',sources,remove_prefix=1)\n undef_macros, sources = filter_files('-U','',sources,remove_prefix=1)\n define_macros, sources = filter_files('-D','',sources,remove_prefix=1)\n using_numarray = 0\n using_numeric = 0\n for i in range(len(define_macros)):\n name_value = string.split(define_macros[i],'=',1)\n if len(name_value)==1:\n name_value.append(None)\n if len(name_value)==2:\n define_macros[i] = tuple(name_value)\n else:\n print 'Invalid use of -D:',name_value\n\n from numpy.distutils.system_info import get_info\n\n num_include_dir = None\n num_info = {}\n #import numpy\n #n = 'numpy'\n #p = get_prefix(numpy)\n #from numpy.distutils.misc_util import get_numpy_include_dirs\n #num_info = {'include_dirs': get_numpy_include_dirs()}\n\n if num_info:\n include_dirs.extend(num_info.get('include_dirs',[]))\n\n from numpy.distutils.core import setup,Extension\n ext_args = {'name':modulename,'sources':sources,\n 'include_dirs': include_dirs,\n 'library_dirs': library_dirs,\n 'libraries': libraries,\n 'define_macros': define_macros,\n 'undef_macros': undef_macros,\n 'extra_objects': extra_objects,\n 'f2py_options': f2py_flags,\n }\n\n if sysinfo_flags:\n from numpy.distutils.misc_util import dict_append\n for n in sysinfo_flags:\n i = get_info(n)\n if not i:\n outmess('No %s resources found in system'\\\n ' (try `f2py --help-link`)\\n' % (`n`))\n dict_append(ext_args,**i)\n\n ext = Extension(**ext_args)\n sys.argv = [sys.argv[0]] + setup_flags\n sys.argv.extend(['build',\n '--build-temp',build_dir,\n '--build-base',build_dir,\n '--build-platlib','.'])\n if fc_flags:\n sys.argv.extend(['config_fc']+fc_flags)\n if flib_flags:\n sys.argv.extend(['build_ext']+flib_flags)\n\n setup(ext_modules = [ext])\n\n if remove_build_dir and os.path.exists(build_dir):\n outmess('Removing build directory %s\\n'%(build_dir))\n shutil.rmtree(build_dir)\n\ndef main():\n if '--help-link' in sys.argv[1:]:\n sys.argv.remove('--help-link')\n from numpy.distutils.system_info import show_all\n show_all()\n return\n if '-c' in sys.argv[1:]:\n run_compile()\n else:\n run_main(sys.argv[1:])\n\n#if __name__ == \"__main__\":\n# main()\n\n\n# EOF\n\n", + "methods": [ + { + "name": "scaninputline", + "long_name": "scaninputline( inputline )", + "filename": "f2py2e.py", + "nloc": 84, + "complexity": 50, + "token_count": 692, + "parameters": [ + "inputline" + ], + "start_line": 170, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "callcrackfortran", + "long_name": "callcrackfortran( files , options )", + "filename": "f2py2e.py", + "nloc": 24, + "complexity": 6, + "token_count": 181, + "parameters": [ + "files", + "options" + ], + "start_line": 256, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "buildmodules", + "long_name": "buildmodules( list )", + "filename": "f2py2e.py", + "nloc": 29, + "complexity": 12, + "token_count": 315, + "parameters": [ + "list" + ], + "start_line": 281, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d_out , d_in )", + "filename": "f2py2e.py", + "nloc": 8, + "complexity": 4, + "token_count": 68, + "parameters": [ + "d_out", + "d_in" + ], + "start_line": 311, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "run_main", + "long_name": "run_main( comline_list )", + "filename": "f2py2e.py", + "nloc": 35, + "complexity": 15, + "token_count": 397, + "parameters": [ + "comline_list" + ], + "start_line": 320, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "filter_files", + "long_name": "filter_files( prefix , suffix , files , remove_prefix = None )", + "filename": "f2py2e.py", + "nloc": 11, + "complexity": 4, + "token_count": 95, + "parameters": [ + "prefix", + "suffix", + "files", + "remove_prefix" + ], + "start_line": 362, + "end_line": 375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "get_prefix", + "long_name": "get_prefix( module )", + "filename": "f2py2e.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "module" + ], + "start_line": 377, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "run_compile", + "long_name": "run_compile( )", + "filename": "f2py2e.py", + "nloc": 132, + "complexity": 34, + "token_count": 1097, + "parameters": [], + "start_line": 381, + "end_line": 537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 157, + "top_nesting_level": 0 + }, + { + "name": "main", + "long_name": "main( )", + "filename": "f2py2e.py", + "nloc": 10, + "complexity": 3, + "token_count": 61, + "parameters": [], + "start_line": 539, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "scaninputline", + "long_name": "scaninputline( inputline )", + "filename": "f2py2e.py", + "nloc": 84, + "complexity": 50, + "token_count": 692, + "parameters": [ + "inputline" + ], + "start_line": 170, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "callcrackfortran", + "long_name": "callcrackfortran( files , options )", + "filename": "f2py2e.py", + "nloc": 24, + "complexity": 6, + "token_count": 181, + "parameters": [ + "files", + "options" + ], + "start_line": 256, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "buildmodules", + "long_name": "buildmodules( list )", + "filename": "f2py2e.py", + "nloc": 29, + "complexity": 12, + "token_count": 315, + "parameters": [ + "list" + ], + "start_line": 281, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d_out , d_in )", + "filename": "f2py2e.py", + "nloc": 8, + "complexity": 4, + "token_count": 68, + "parameters": [ + "d_out", + "d_in" + ], + "start_line": 311, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "run_main", + "long_name": "run_main( comline_list )", + "filename": "f2py2e.py", + "nloc": 35, + "complexity": 15, + "token_count": 397, + "parameters": [ + "comline_list" + ], + "start_line": 320, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "filter_files", + "long_name": "filter_files( prefix , suffix , files , remove_prefix = None )", + "filename": "f2py2e.py", + "nloc": 11, + "complexity": 4, + "token_count": 95, + "parameters": [ + "prefix", + "suffix", + "files", + "remove_prefix" + ], + "start_line": 362, + "end_line": 375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "get_prefix", + "long_name": "get_prefix( module )", + "filename": "f2py2e.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "module" + ], + "start_line": 377, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "run_compile", + "long_name": "run_compile( )", + "filename": "f2py2e.py", + "nloc": 132, + "complexity": 34, + "token_count": 1097, + "parameters": [], + "start_line": 381, + "end_line": 537, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 157, + "top_nesting_level": 0 + }, + { + "name": "main", + "long_name": "main( )", + "filename": "f2py2e.py", + "nloc": 10, + "complexity": 3, + "token_count": 61, + "parameters": [], + "start_line": 539, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 495, + "complexity": 129, + "token_count": 3030, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/f90mod_rules.py", + "new_path": "numpy/f2py/f90mod_rules.py", + "filename": "f90mod_rules.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n Copyright 2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/02/03 19:30:23 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nBuild F90 module support for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/02/03 19:30:23 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.27 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\nimport rules\nimport func2subr\nfrom crackfortran import undo_rmbadname, undo_rmbadname1\n\noptions={}\n\ndef findf90modules(m):\n if ismodule(m): return [m]\n if not hasbody(m): return []\n ret = []\n for b in m['body']:\n if ismodule(b): ret.append(b)\n else: ret=ret+findf90modules(b)\n return ret\n\nfgetdims1 = \"\"\"\\\n external f2pysetdata\n logical ns\n integer s(*),r,i,j\n ns = .FALSE.\n if (allocated(d)) then\n do i=1,r\n if ((size(d,i).ne.s(i)).and.(s(i).ge.0)) then\n ns = .TRUE.\n end if\n end do\n if (ns) then \n deallocate(d) \n end if\n end if\n if ((.not.allocated(d)).and.(s(1).ge.1)) then\"\"\"\n\nfgetdims2=\"\"\"\\\n end if\n if (allocated(d)) then\n do i=1,r\n s(i) = size(d,i)\n end do\n end if\n flag = 1\n call f2pysetdata(d,allocated(d))\"\"\"\n\nfgetdims2_sa=\"\"\"\\\n end if\n if (allocated(d)) then\n do i=1,r\n s(i) = size(d,i)\n end do\n !s(r) must be equal to len(d(1))\n end if\n flag = 2\n call f2pysetdata(d,allocated(d))\"\"\"\n\n\ndef buildhooks(pymod):\n global fgetdims1,fgetdims2\n ret = {'f90modhooks':[],'initf90modhooks':[],'body':[],\n 'need':['F_FUNC','arrayobject.h'],\n 'separatorsfor':{'includes0':'\\n','includes':'\\n'},\n 'docs':['\"Fortran 90/95 modules:\\\\n\"'],\n 'latexdoc':[]}\n fhooks=['']\n def fadd(line,s=fhooks): s[0] = '%s\\n %s'%(s[0],line)\n doc = ['']\n def dadd(line,s=doc): s[0] = '%s\\n%s'%(s[0],line)\n for m in findf90modules(pymod):\n sargs,fargs,efargs,modobjs,notvars,onlyvars=[],[],[],[],[m['name']],[]\n sargsp = []\n ifargs = []\n mfargs = []\n if hasbody(m):\n for b in m['body']: notvars.append(b['name'])\n for n in m['vars'].keys():\n var = m['vars'][n]\n if (n not in notvars) and (not l_or(isintent_hide,isprivate)(var)):\n onlyvars.append(n)\n mfargs.append(n)\n outmess('\\t\\tConstructing F90 module support for \"%s\"...\\n'%(m['name']))\n if onlyvars:\n outmess('\\t\\t Variables: %s\\n'%(string.join(onlyvars)))\n chooks=['']\n def cadd(line,s=chooks): s[0] = '%s\\n%s'%(s[0],line)\n ihooks=['']\n def iadd(line,s=ihooks): s[0] = '%s\\n%s'%(s[0],line)\n\n vrd=capi_maps.modsign2map(m)\n cadd('static FortranDataDef f2py_%s_def[] = {'%(m['name']))\n dadd('\\\\subsection{Fortran 90/95 module \\\\texttt{%s}}\\n'%(m['name']))\n if hasnote(m):\n note = m['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd(note)\n if onlyvars:\n dadd('\\\\begin{description}')\n for n in onlyvars:\n var = m['vars'][n]\n modobjs.append(n)\n ct = capi_maps.getctype(var)\n at = capi_maps.c2capi_map[ct]\n dm = capi_maps.getarrdims(n,var)\n dms = string.strip(string.replace(dm['dims'],'*','-1'))\n dms = string.strip(string.replace(dms,':','-1'))\n if not dms: dms='-1'\n use_fgetdims2 = fgetdims2\n if isstringarray(var):\n if var.has_key('charselector') and var['charselector'].has_key('len'):\n cadd('\\t{\"%s\",%s,{{%s,%s}},%s},'\\\n %(undo_rmbadname1(n),dm['rank'],dms,var['charselector']['len'],at))\n use_fgetdims2 = fgetdims2_sa\n else:\n cadd('\\t{\"%s\",%s,{{%s}},%s},'%(undo_rmbadname1(n),dm['rank'],dms,at))\n else:\n cadd('\\t{\"%s\",%s,{{%s}},%s},'%(undo_rmbadname1(n),dm['rank'],dms,at))\n dadd('\\\\item[]{{}\\\\verb@%s@{}}'%(capi_maps.getarrdocsign(n,var)))\n if hasnote(var):\n note = var['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd('--- %s'%(note))\n if isallocatable(var):\n fargs.append('f2py_%s_getdims_%s'%(m['name'],n))\n efargs.append(fargs[-1])\n sargs.append('void (*%s)(int*,int*,void(*)(char*,int*),int*)'%(n))\n sargsp.append('void (*)(int*,int*,void(*)(char*,int*),int*)')\n iadd('\\tf2py_%s_def[i_f2py++].func = %s;'%(m['name'],n))\n fadd('subroutine %s(r,s,f2pysetdata,flag)'%(fargs[-1]))\n fadd('use %s, only: d => %s\\n'%(m['name'],undo_rmbadname1(n)))\n fadd('integer flag\\n')\n fhooks[0]=fhooks[0]+fgetdims1\n dms = eval('range(1,%s+1)'%(dm['rank']))\n fadd(' allocate(d(%s))\\n'%(string.join(map(lambda i:'s(%s)'%i,dms),',')))\n fhooks[0]=fhooks[0]+use_fgetdims2\n fadd('end subroutine %s'%(fargs[-1]))\n else:\n fargs.append(n)\n sargs.append('char *%s'%(n))\n sargsp.append('char*')\n iadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(m['name'],n))\n if onlyvars:\n dadd('\\\\end{description}')\n if hasbody(m):\n for b in m['body']:\n if not isroutine(b):\n print 'Skipping',b['block'],b['name']\n continue\n modobjs.append('%s()'%(b['name']))\n b['modulename'] = m['name']\n api,wrap=rules.buildapi(b)\n if isfunction(b):\n fhooks[0]=fhooks[0]+wrap\n fargs.append('f2pywrap_%s_%s'%(m['name'],b['name']))\n #efargs.append(fargs[-1])\n ifargs.append(func2subr.createfuncwrapper(b,signature=1))\n else:\n fargs.append(b['name'])\n mfargs.append(fargs[-1])\n #if options.has_key('--external-modroutines') and options['--external-modroutines']:\n # outmess('\\t\\t\\tapplying --external-modroutines for %s\\n'%(b['name']))\n # efargs.append(fargs[-1])\n api['externroutines']=[]\n ar=applyrules(api,vrd)\n ar['docs']=[]\n ar['docshort']=[]\n ret=dictappend(ret,ar)\n cadd('\\t{\"%s\",-1,{{-1}},0,NULL,(void *)f2py_rout_#modulename#_%s_%s,doc_f2py_rout_#modulename#_%s_%s},'%(b['name'],m['name'],b['name'],m['name'],b['name']))\n sargs.append('char *%s'%(b['name']))\n sargsp.append('char *')\n iadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(m['name'],b['name']))\n cadd('\\t{NULL}\\n};\\n')\n iadd('}')\n ihooks[0]='static void f2py_setup_%s(%s) {\\n\\tint i_f2py=0;%s'%(m['name'],string.join(sargs,','),ihooks[0])\n if '_' in m['name']:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n iadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void (*)(%s));'\\\n %(F_FUNC,m['name'],string.upper(m['name']),string.join(sargsp,',')))\n iadd('static void f2py_init_%s(void) {'%(m['name']))\n iadd('\\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'\\\n %(F_FUNC,m['name'],string.upper(m['name']),m['name']))\n iadd('}\\n')\n ret['f90modhooks']=ret['f90modhooks']+chooks+ihooks\n ret['initf90modhooks']=['\\tPyDict_SetItemString(d, \"%s\", PyFortranObject_New(f2py_%s_def,f2py_init_%s));'%(m['name'],m['name'],m['name'])]+ret['initf90modhooks']\n fadd('')\n fadd('subroutine f2pyinit%s(f2pysetupfunc)'%(m['name']))\n #fadd('use %s'%(m['name']))\n if mfargs:\n for a in undo_rmbadname(mfargs):\n fadd('use %s, only : %s'%(m['name'],a))\n if ifargs:\n fadd(string.join(['interface']+ifargs))\n fadd('end interface')\n fadd('external f2pysetupfunc')\n if efargs:\n for a in undo_rmbadname(efargs):\n fadd('external %s'%(a))\n fadd('call f2pysetupfunc(%s)'%(string.join(undo_rmbadname(fargs),',')))\n fadd('end subroutine f2pyinit%s\\n'%(m['name']))\n\n dadd(string.replace(string.join(ret['latexdoc'],'\\n'),r'\\subsection{',r'\\subsubsection{'))\n \n ret['latexdoc']=[]\n ret['docs'].append('\"\\t%s --- %s\"'%(m['name'],\n string.join(undo_rmbadname(modobjs),',')))\n\n ret['routine_defs']=''\n ret['doc']=[]\n ret['docshort']=[]\n ret['latexdoc']=doc[0]\n if len(ret['docs'])<=1: ret['docs']=''\n return ret,fhooks[0]\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nBuild F90 module support for f2py2e.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/02/03 19:30:23 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.27 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\nimport rules\nimport func2subr\nfrom crackfortran import undo_rmbadname, undo_rmbadname1\n\noptions={}\n\ndef findf90modules(m):\n if ismodule(m): return [m]\n if not hasbody(m): return []\n ret = []\n for b in m['body']:\n if ismodule(b): ret.append(b)\n else: ret=ret+findf90modules(b)\n return ret\n\nfgetdims1 = \"\"\"\\\n external f2pysetdata\n logical ns\n integer s(*),r,i,j\n ns = .FALSE.\n if (allocated(d)) then\n do i=1,r\n if ((size(d,i).ne.s(i)).and.(s(i).ge.0)) then\n ns = .TRUE.\n end if\n end do\n if (ns) then \n deallocate(d) \n end if\n end if\n if ((.not.allocated(d)).and.(s(1).ge.1)) then\"\"\"\n\nfgetdims2=\"\"\"\\\n end if\n if (allocated(d)) then\n do i=1,r\n s(i) = size(d,i)\n end do\n end if\n flag = 1\n call f2pysetdata(d,allocated(d))\"\"\"\n\nfgetdims2_sa=\"\"\"\\\n end if\n if (allocated(d)) then\n do i=1,r\n s(i) = size(d,i)\n end do\n !s(r) must be equal to len(d(1))\n end if\n flag = 2\n call f2pysetdata(d,allocated(d))\"\"\"\n\n\ndef buildhooks(pymod):\n global fgetdims1,fgetdims2\n ret = {'f90modhooks':[],'initf90modhooks':[],'body':[],\n 'need':['F_FUNC','arrayobject.h'],\n 'separatorsfor':{'includes0':'\\n','includes':'\\n'},\n 'docs':['\"Fortran 90/95 modules:\\\\n\"'],\n 'latexdoc':[]}\n fhooks=['']\n def fadd(line,s=fhooks): s[0] = '%s\\n %s'%(s[0],line)\n doc = ['']\n def dadd(line,s=doc): s[0] = '%s\\n%s'%(s[0],line)\n for m in findf90modules(pymod):\n sargs,fargs,efargs,modobjs,notvars,onlyvars=[],[],[],[],[m['name']],[]\n sargsp = []\n ifargs = []\n mfargs = []\n if hasbody(m):\n for b in m['body']: notvars.append(b['name'])\n for n in m['vars'].keys():\n var = m['vars'][n]\n if (n not in notvars) and (not l_or(isintent_hide,isprivate)(var)):\n onlyvars.append(n)\n mfargs.append(n)\n outmess('\\t\\tConstructing F90 module support for \"%s\"...\\n'%(m['name']))\n if onlyvars:\n outmess('\\t\\t Variables: %s\\n'%(string.join(onlyvars)))\n chooks=['']\n def cadd(line,s=chooks): s[0] = '%s\\n%s'%(s[0],line)\n ihooks=['']\n def iadd(line,s=ihooks): s[0] = '%s\\n%s'%(s[0],line)\n\n vrd=capi_maps.modsign2map(m)\n cadd('static FortranDataDef f2py_%s_def[] = {'%(m['name']))\n dadd('\\\\subsection{Fortran 90/95 module \\\\texttt{%s}}\\n'%(m['name']))\n if hasnote(m):\n note = m['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd(note)\n if onlyvars:\n dadd('\\\\begin{description}')\n for n in onlyvars:\n var = m['vars'][n]\n modobjs.append(n)\n ct = capi_maps.getctype(var)\n at = capi_maps.c2capi_map[ct]\n dm = capi_maps.getarrdims(n,var)\n dms = string.strip(string.replace(dm['dims'],'*','-1'))\n dms = string.strip(string.replace(dms,':','-1'))\n if not dms: dms='-1'\n use_fgetdims2 = fgetdims2\n if isstringarray(var):\n if var.has_key('charselector') and var['charselector'].has_key('len'):\n cadd('\\t{\"%s\",%s,{{%s,%s}},%s},'\\\n %(undo_rmbadname1(n),dm['rank'],dms,var['charselector']['len'],at))\n use_fgetdims2 = fgetdims2_sa\n else:\n cadd('\\t{\"%s\",%s,{{%s}},%s},'%(undo_rmbadname1(n),dm['rank'],dms,at))\n else:\n cadd('\\t{\"%s\",%s,{{%s}},%s},'%(undo_rmbadname1(n),dm['rank'],dms,at))\n dadd('\\\\item[]{{}\\\\verb@%s@{}}'%(capi_maps.getarrdocsign(n,var)))\n if hasnote(var):\n note = var['note']\n if type(note) is type([]): note=string.join(note,'\\n')\n dadd('--- %s'%(note))\n if isallocatable(var):\n fargs.append('f2py_%s_getdims_%s'%(m['name'],n))\n efargs.append(fargs[-1])\n sargs.append('void (*%s)(int*,int*,void(*)(char*,int*),int*)'%(n))\n sargsp.append('void (*)(int*,int*,void(*)(char*,int*),int*)')\n iadd('\\tf2py_%s_def[i_f2py++].func = %s;'%(m['name'],n))\n fadd('subroutine %s(r,s,f2pysetdata,flag)'%(fargs[-1]))\n fadd('use %s, only: d => %s\\n'%(m['name'],undo_rmbadname1(n)))\n fadd('integer flag\\n')\n fhooks[0]=fhooks[0]+fgetdims1\n dms = eval('range(1,%s+1)'%(dm['rank']))\n fadd(' allocate(d(%s))\\n'%(string.join(map(lambda i:'s(%s)'%i,dms),',')))\n fhooks[0]=fhooks[0]+use_fgetdims2\n fadd('end subroutine %s'%(fargs[-1]))\n else:\n fargs.append(n)\n sargs.append('char *%s'%(n))\n sargsp.append('char*')\n iadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(m['name'],n))\n if onlyvars:\n dadd('\\\\end{description}')\n if hasbody(m):\n for b in m['body']:\n if not isroutine(b):\n print 'Skipping',b['block'],b['name']\n continue\n modobjs.append('%s()'%(b['name']))\n b['modulename'] = m['name']\n api,wrap=rules.buildapi(b)\n if isfunction(b):\n fhooks[0]=fhooks[0]+wrap\n fargs.append('f2pywrap_%s_%s'%(m['name'],b['name']))\n #efargs.append(fargs[-1])\n ifargs.append(func2subr.createfuncwrapper(b,signature=1))\n else:\n fargs.append(b['name'])\n mfargs.append(fargs[-1])\n #if options.has_key('--external-modroutines') and options['--external-modroutines']:\n # outmess('\\t\\t\\tapplying --external-modroutines for %s\\n'%(b['name']))\n # efargs.append(fargs[-1])\n api['externroutines']=[]\n ar=applyrules(api,vrd)\n ar['docs']=[]\n ar['docshort']=[]\n ret=dictappend(ret,ar)\n cadd('\\t{\"%s\",-1,{{-1}},0,NULL,(void *)f2py_rout_#modulename#_%s_%s,doc_f2py_rout_#modulename#_%s_%s},'%(b['name'],m['name'],b['name'],m['name'],b['name']))\n sargs.append('char *%s'%(b['name']))\n sargsp.append('char *')\n iadd('\\tf2py_%s_def[i_f2py++].data = %s;'%(m['name'],b['name']))\n cadd('\\t{NULL}\\n};\\n')\n iadd('}')\n ihooks[0]='static void f2py_setup_%s(%s) {\\n\\tint i_f2py=0;%s'%(m['name'],string.join(sargs,','),ihooks[0])\n if '_' in m['name']:\n F_FUNC='F_FUNC_US'\n else:\n F_FUNC='F_FUNC'\n iadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void (*)(%s));'\\\n %(F_FUNC,m['name'],string.upper(m['name']),string.join(sargsp,',')))\n iadd('static void f2py_init_%s(void) {'%(m['name']))\n iadd('\\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'\\\n %(F_FUNC,m['name'],string.upper(m['name']),m['name']))\n iadd('}\\n')\n ret['f90modhooks']=ret['f90modhooks']+chooks+ihooks\n ret['initf90modhooks']=['\\tPyDict_SetItemString(d, \"%s\", PyFortranObject_New(f2py_%s_def,f2py_init_%s));'%(m['name'],m['name'],m['name'])]+ret['initf90modhooks']\n fadd('')\n fadd('subroutine f2pyinit%s(f2pysetupfunc)'%(m['name']))\n #fadd('use %s'%(m['name']))\n if mfargs:\n for a in undo_rmbadname(mfargs):\n fadd('use %s, only : %s'%(m['name'],a))\n if ifargs:\n fadd(string.join(['interface']+ifargs))\n fadd('end interface')\n fadd('external f2pysetupfunc')\n if efargs:\n for a in undo_rmbadname(efargs):\n fadd('external %s'%(a))\n fadd('call f2pysetupfunc(%s)'%(string.join(undo_rmbadname(fargs),',')))\n fadd('end subroutine f2pyinit%s\\n'%(m['name']))\n\n dadd(string.replace(string.join(ret['latexdoc'],'\\n'),r'\\subsection{',r'\\subsubsection{'))\n \n ret['latexdoc']=[]\n ret['docs'].append('\"\\t%s --- %s\"'%(m['name'],\n string.join(undo_rmbadname(modobjs),',')))\n\n ret['routine_defs']=''\n ret['doc']=[]\n ret['docshort']=[]\n ret['latexdoc']=doc[0]\n if len(ret['docs'])<=1: ret['docs']=''\n return ret,fhooks[0]\n\n\n", + "methods": [ + { + "name": "findf90modules", + "long_name": "findf90modules( m )", + "filename": "f90mod_rules.py", + "nloc": 8, + "complexity": 5, + "token_count": 61, + "parameters": [ + "m" + ], + "start_line": 35, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "buildhooks.buildhooks.dadd.iadd", + "long_name": "buildhooks.buildhooks.dadd.iadd( line , s = ihooks )", + "filename": "f90mod_rules.py", + "nloc": 8, + "complexity": 3, + "token_count": 92, + "parameters": [ + "line", + "s" + ], + "start_line": 112, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 2 + }, + { + "name": "buildhooks.dadd", + "long_name": "buildhooks.dadd( line , s = doc )", + "filename": "f90mod_rules.py", + "nloc": 122, + "complexity": 28, + "token_count": 1235, + "parameters": [ + "line", + "s" + ], + "start_line": 93, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 1 + }, + { + "name": "buildhooks", + "long_name": "buildhooks( pymod )", + "filename": "f90mod_rules.py", + "nloc": 15, + "complexity": 2, + "token_count": 118, + "parameters": [ + "pymod" + ], + "start_line": 83, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 156, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "findf90modules", + "long_name": "findf90modules( m )", + "filename": "f90mod_rules.py", + "nloc": 8, + "complexity": 5, + "token_count": 61, + "parameters": [ + "m" + ], + "start_line": 35, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "buildhooks.buildhooks.dadd.iadd", + "long_name": "buildhooks.buildhooks.dadd.iadd( line , s = ihooks )", + "filename": "f90mod_rules.py", + "nloc": 8, + "complexity": 3, + "token_count": 92, + "parameters": [ + "line", + "s" + ], + "start_line": 112, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 2 + }, + { + "name": "buildhooks.dadd", + "long_name": "buildhooks.dadd( line , s = doc )", + "filename": "f90mod_rules.py", + "nloc": 122, + "complexity": 28, + "token_count": 1235, + "parameters": [ + "line", + "s" + ], + "start_line": 93, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 1 + }, + { + "name": "buildhooks", + "long_name": "buildhooks( pymod )", + "filename": "f90mod_rules.py", + "nloc": 15, + "complexity": 2, + "token_count": 118, + "parameters": [ + "pymod" + ], + "start_line": 83, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 156, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 217, + "complexity": 38, + "token_count": 1641, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/func2subr.py", + "new_path": "numpy/f2py/func2subr.py", + "filename": "func2subr.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n Copyright 1999,2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2004/11/26 11:13:06 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nRules for building C/API module with f2py2e.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2004/11/26 11:13:06 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.16 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint,copy\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\ndef var2fixfortran(vars,a,fa=None,f90mode=None):\n if fa is None:\n fa = a\n if not vars.has_key(a):\n show(vars)\n outmess('var2fixfortran: No definition for argument \"%s\".\\n'%a)\n return ''\n if not vars[a].has_key('typespec'):\n show(vars[a])\n outmess('var2fixfortran: No typespec for argument \"%s\".\\n'%a)\n return ''\n vardef=vars[a]['typespec']\n if vardef=='type' and vars[a].has_key('typename'):\n vardef='%s(%s)'%(vardef,vars[a]['typename'])\n selector={}\n lk = ''\n if vars[a].has_key('kindselector'):\n selector=vars[a]['kindselector']\n lk = 'kind'\n elif vars[a].has_key('charselector'):\n selector=vars[a]['charselector']\n lk = 'len'\n if selector.has_key('*'):\n if f90mode:\n if selector['*'] in ['*',':','(*)']:\n vardef='%s(len=*)'%(vardef)\n else:\n vardef='%s(%s=%s)'%(vardef,lk,selector['*'])\n else:\n if selector['*'] in ['*',':']:\n vardef='%s*(%s)'%(vardef,selector['*'])\n else:\n vardef='%s*%s'%(vardef,selector['*'])\n else:\n if selector.has_key('len'):\n vardef='%s(len=%s'%(vardef,selector['len'])\n if selector.has_key('kind'):\n vardef='%s,kind=%s)'%(vardef,selector['kind'])\n else:\n vardef='%s)'%(vardef)\n elif selector.has_key('kind'):\n vardef='%s(kind=%s)'%(vardef,selector['kind'])\n\n vardef='%s %s'%(vardef,fa)\n if vars[a].has_key('dimension'):\n vardef='%s(%s)'%(vardef,string.join(vars[a]['dimension'],','))\n return vardef\n\ndef createfuncwrapper(rout,signature=0):\n assert isfunction(rout)\n ret = ['']\n def add(line,ret=ret):\n ret[0] = '%s\\n %s'%(ret[0],line)\n name = rout['name']\n fortranname = getfortranname(rout)\n f90mode = ismoduleroutine(rout)\n newname = '%sf2pywrap'%(name)\n vars = rout['vars']\n if not vars.has_key(newname):\n vars[newname] = vars[name]\n args = [newname]+rout['args'][1:]\n else:\n args = [newname]+rout['args']\n\n l = var2fixfortran(vars,name,newname,f90mode)\n return_char_star = 0\n if l[:13]=='character*(*)':\n return_char_star = 1\n if f90mode: l = 'character(len=10)'+l[13:]\n else: l = 'character*10'+l[13:]\n charselect = vars[name]['charselector']\n if charselect.get('*','')=='(*)':\n charselect['*'] = '10'\n if f90mode:\n sargs = string.join(args,', ')\n add('subroutine f2pywrap_%s_%s (%s)'%(rout['modulename'],name,sargs))\n if not signature:\n add('use %s, only : %s'%(rout['modulename'],fortranname))\n else:\n add('subroutine f2pywrap%s (%s)'%(name,string.join(args,', ')))\n add('external %s'%(fortranname))\n #if not return_char_star:\n l = l + ', '+fortranname\n args = args[1:]\n dumped_args = []\n for a in args:\n if isexternal(vars[a]):\n add('external %s'%(a))\n dumped_args.append(a)\n for a in args:\n if a in dumped_args: continue\n if isscalar(vars[a]):\n add(var2fixfortran(vars,a,f90mode=f90mode))\n dumped_args.append(a)\n for a in args:\n if a in dumped_args: continue\n add(var2fixfortran(vars,a,f90mode=f90mode))\n\n add(l)\n\n if not signature:\n if islogicalfunction(rout):\n add('%s = .not.(.not.%s(%s))'%(newname,fortranname,string.join(args,', ')))\n else:\n add('%s = %s(%s)'%(newname,fortranname,string.join(args,', ')))\n if f90mode:\n add('end subroutine f2pywrap_%s_%s'%(rout['modulename'],name))\n else:\n add('end')\n #print '**'*10\n #print ret[0]\n #print '**'*10\n return ret[0]\n\ndef assubr(rout):\n if not isfunction_wrap(rout): return rout,''\n fortranname = getfortranname(rout)\n name = rout['name']\n outmess('\\t\\tCreating wrapper for Fortran function \"%s\"(\"%s\")...\\n'%(name,fortranname))\n rout = copy.copy(rout)\n fname = name\n rname = fname\n if rout.has_key('result'):\n rname = rout['result']\n rout['vars'][fname]=rout['vars'][rname]\n fvar = rout['vars'][fname]\n if not isintent_out(fvar):\n if not fvar.has_key('intent'): fvar['intent']=[]\n fvar['intent'].append('out')\n flag=1\n for i in fvar['intent']:\n if i.startswith('out='):\n flag = 0\n break\n if flag:\n fvar['intent'].append('out=%s' % (rname))\n \n rout['args'] = [fname] + rout['args']\n return rout,createfuncwrapper(rout)\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nRules for building C/API module with f2py2e.\n\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2004/11/26 11:13:06 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.16 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint,copy\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\ndef var2fixfortran(vars,a,fa=None,f90mode=None):\n if fa is None:\n fa = a\n if not vars.has_key(a):\n show(vars)\n outmess('var2fixfortran: No definition for argument \"%s\".\\n'%a)\n return ''\n if not vars[a].has_key('typespec'):\n show(vars[a])\n outmess('var2fixfortran: No typespec for argument \"%s\".\\n'%a)\n return ''\n vardef=vars[a]['typespec']\n if vardef=='type' and vars[a].has_key('typename'):\n vardef='%s(%s)'%(vardef,vars[a]['typename'])\n selector={}\n lk = ''\n if vars[a].has_key('kindselector'):\n selector=vars[a]['kindselector']\n lk = 'kind'\n elif vars[a].has_key('charselector'):\n selector=vars[a]['charselector']\n lk = 'len'\n if selector.has_key('*'):\n if f90mode:\n if selector['*'] in ['*',':','(*)']:\n vardef='%s(len=*)'%(vardef)\n else:\n vardef='%s(%s=%s)'%(vardef,lk,selector['*'])\n else:\n if selector['*'] in ['*',':']:\n vardef='%s*(%s)'%(vardef,selector['*'])\n else:\n vardef='%s*%s'%(vardef,selector['*'])\n else:\n if selector.has_key('len'):\n vardef='%s(len=%s'%(vardef,selector['len'])\n if selector.has_key('kind'):\n vardef='%s,kind=%s)'%(vardef,selector['kind'])\n else:\n vardef='%s)'%(vardef)\n elif selector.has_key('kind'):\n vardef='%s(kind=%s)'%(vardef,selector['kind'])\n\n vardef='%s %s'%(vardef,fa)\n if vars[a].has_key('dimension'):\n vardef='%s(%s)'%(vardef,string.join(vars[a]['dimension'],','))\n return vardef\n\ndef createfuncwrapper(rout,signature=0):\n assert isfunction(rout)\n ret = ['']\n def add(line,ret=ret):\n ret[0] = '%s\\n %s'%(ret[0],line)\n name = rout['name']\n fortranname = getfortranname(rout)\n f90mode = ismoduleroutine(rout)\n newname = '%sf2pywrap'%(name)\n vars = rout['vars']\n if not vars.has_key(newname):\n vars[newname] = vars[name]\n args = [newname]+rout['args'][1:]\n else:\n args = [newname]+rout['args']\n\n l = var2fixfortran(vars,name,newname,f90mode)\n return_char_star = 0\n if l[:13]=='character*(*)':\n return_char_star = 1\n if f90mode: l = 'character(len=10)'+l[13:]\n else: l = 'character*10'+l[13:]\n charselect = vars[name]['charselector']\n if charselect.get('*','')=='(*)':\n charselect['*'] = '10'\n if f90mode:\n sargs = string.join(args,', ')\n add('subroutine f2pywrap_%s_%s (%s)'%(rout['modulename'],name,sargs))\n if not signature:\n add('use %s, only : %s'%(rout['modulename'],fortranname))\n else:\n add('subroutine f2pywrap%s (%s)'%(name,string.join(args,', ')))\n add('external %s'%(fortranname))\n #if not return_char_star:\n l = l + ', '+fortranname\n args = args[1:]\n dumped_args = []\n for a in args:\n if isexternal(vars[a]):\n add('external %s'%(a))\n dumped_args.append(a)\n for a in args:\n if a in dumped_args: continue\n if isscalar(vars[a]):\n add(var2fixfortran(vars,a,f90mode=f90mode))\n dumped_args.append(a)\n for a in args:\n if a in dumped_args: continue\n add(var2fixfortran(vars,a,f90mode=f90mode))\n\n add(l)\n\n if not signature:\n if islogicalfunction(rout):\n add('%s = .not.(.not.%s(%s))'%(newname,fortranname,string.join(args,', ')))\n else:\n add('%s = %s(%s)'%(newname,fortranname,string.join(args,', ')))\n if f90mode:\n add('end subroutine f2pywrap_%s_%s'%(rout['modulename'],name))\n else:\n add('end')\n #print '**'*10\n #print ret[0]\n #print '**'*10\n return ret[0]\n\ndef assubr(rout):\n if not isfunction_wrap(rout): return rout,''\n fortranname = getfortranname(rout)\n name = rout['name']\n outmess('\\t\\tCreating wrapper for Fortran function \"%s\"(\"%s\")...\\n'%(name,fortranname))\n rout = copy.copy(rout)\n fname = name\n rname = fname\n if rout.has_key('result'):\n rname = rout['result']\n rout['vars'][fname]=rout['vars'][rname]\n fvar = rout['vars'][fname]\n if not isintent_out(fvar):\n if not fvar.has_key('intent'): fvar['intent']=[]\n fvar['intent'].append('out')\n flag=1\n for i in fvar['intent']:\n if i.startswith('out='):\n flag = 0\n break\n if flag:\n fvar['intent'].append('out=%s' % (rname))\n \n rout['args'] = [fname] + rout['args']\n return rout,createfuncwrapper(rout)\n", + "methods": [ + { + "name": "var2fixfortran", + "long_name": "var2fixfortran( vars , a , fa = None , f90mode = None )", + "filename": "func2subr.py", + "nloc": 46, + "complexity": 16, + "token_count": 366, + "parameters": [ + "vars", + "a", + "fa", + "f90mode" + ], + "start_line": 27, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "createfuncwrapper.add", + "long_name": "createfuncwrapper.add( line , ret = ret )", + "filename": "func2subr.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "line", + "ret" + ], + "start_line": 78, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "createfuncwrapper", + "long_name": "createfuncwrapper( rout , signature = 0 )", + "filename": "func2subr.py", + "nloc": 57, + "complexity": 17, + "token_count": 435, + "parameters": [ + "rout", + "signature" + ], + "start_line": 75, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + }, + { + "name": "assubr", + "long_name": "assubr( rout )", + "filename": "func2subr.py", + "nloc": 24, + "complexity": 8, + "token_count": 181, + "parameters": [ + "rout" + ], + "start_line": 141, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "var2fixfortran", + "long_name": "var2fixfortran( vars , a , fa = None , f90mode = None )", + "filename": "func2subr.py", + "nloc": 46, + "complexity": 16, + "token_count": 366, + "parameters": [ + "vars", + "a", + "fa", + "f90mode" + ], + "start_line": 27, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "createfuncwrapper.add", + "long_name": "createfuncwrapper.add( line , ret = ret )", + "filename": "func2subr.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "line", + "ret" + ], + "start_line": 78, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "createfuncwrapper", + "long_name": "createfuncwrapper( rout , signature = 0 )", + "filename": "func2subr.py", + "nloc": 57, + "complexity": 17, + "token_count": 435, + "parameters": [ + "rout", + "signature" + ], + "start_line": 75, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "top_nesting_level": 0 + }, + { + "name": "assubr", + "long_name": "assubr( rout )", + "filename": "func2subr.py", + "nloc": 24, + "complexity": 8, + "token_count": 181, + "parameters": [ + "rout" + ], + "start_line": 141, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 149, + "complexity": 42, + "token_count": 1058, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/rules.py", + "new_path": "numpy/f2py/rules.py", + "filename": "rules.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -44,7 +44,7 @@\n Copyright 1999,2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2005/08/30 08:58:42 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nRules for building C/API module with f2py2e.\n\nHere is a skeleton of a new wrapper function (13Dec2001):\n\nwrapper_function(args)\n declarations\n get_python_arguments, say, `a' and `b'\n\n get_a_from_python\n if (successful) {\n\n get_b_from_python\n if (successful) {\n\n callfortran\n if (succesful) {\n\n put_a_to_python\n if (succesful) {\n\n put_b_to_python\n if (succesful) {\n\n buildvalue = ...\n\n }\n\n }\n \n }\n\n }\n cleanup_b\n\n }\n cleanup_a\n\n return buildvalue\n\"\"\"\n\"\"\"\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/08/30 08:58:42 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.129 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nfrom capi_maps import *\nimport cfuncs\nimport common_rules\nimport use_rules\nimport f90mod_rules\nimport func2subr\noptions={}\n\nsepdict={}\n#for k in ['need_cfuncs']: sepdict[k]=','\nfor k in ['decl',\n 'frompyobj',\n 'cleanupfrompyobj',\n 'topyarr','method',\n 'pyobjfrom','closepyobjfrom',\n 'freemem',\n 'userincludes',\n 'includes0','includes','typedefs','typedefs_generated',\n 'cppmacros','cfuncs','callbacks',\n 'latexdoc',\n 'restdoc',\n 'routine_defs','externroutines',\n 'initf2pywraphooks',\n 'commonhooks','initcommonhooks',\n 'f90modhooks','initf90modhooks']:\n sepdict[k]='\\n'\n\n#################### Rules for C/API module #################\n\nmodule_rules={\n 'modulebody':\"\"\"\\\n/* File: #modulename#module.c\n * This file is auto-generated with f2py (version:#f2py_version#).\n * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,\n * written by Pearu Peterson .\n * See http://cens.ioc.ee/projects/f2py2e/\n * Generation date: \"\"\"+time.asctime(time.localtime(time.time()))+\"\"\"\n * $R\"\"\"+\"\"\"evision:$\n * $D\"\"\"+\"\"\"ate:$\n * Do not edit this file directly unless you know what you are doing!!!\n */\n#ifdef __cplusplus\nextern \\\"C\\\" {\n#endif\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: includes\")+\"\"\"\n#includes#\n#includes0#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: mod_rules['modulebody']\")+\"\"\"\nstatic PyObject *#modulename#_error;\nstatic PyObject *#modulename#_module;\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: typedefs\")+\"\"\"\n#typedefs#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: typedefs_generated\")+\"\"\"\n#typedefs_generated#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: cppmacros\")+\"\"\"\n#cppmacros#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: cfuncs\")+\"\"\"\n#cfuncs#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: userincludes\")+\"\"\"\n#userincludes#\n\n\"\"\"+gentitle(\"See f2py2e/capi_rules.py: usercode\")+\"\"\"\n#usercode#\n\n/* See f2py2e/rules.py */\n#externroutines#\n\n\"\"\"+gentitle(\"See f2py2e/capi_rules.py: usercode1\")+\"\"\"\n#usercode1#\n\n\"\"\"+gentitle(\"See f2py2e/cb_rules.py: buildcallback\")+\"\"\"\n#callbacks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: buildapi\")+\"\"\"\n#body#\n\n\"\"\"+gentitle(\"See f2py2e/f90mod_rules.py: buildhooks\")+\"\"\"\n#f90modhooks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: module_rules['modulebody']\")+\"\"\"\n\n\"\"\"+gentitle(\"See f2py2e/common_rules.py: buildhooks\")+\"\"\"\n#commonhooks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py\")+\"\"\"\n\nstatic FortranDataDef f2py_routine_defs[] = {\n#routine_defs#\n\\t{NULL}\n};\n\nstatic PyMethodDef f2py_module_methods[] = {\n#pymethoddef#\n\\t{NULL,NULL}\n};\n\nDL_EXPORT(void) init#modulename#(void) {\n\\tint i;\n\\tPyObject *m,*d, *s;\n\\tm = #modulename#_module = Py_InitModule(\\\"#modulename#\\\", f2py_module_methods);\n\\tPyFortran_Type.ob_type = &PyType_Type;\n\\timport_array();\n\\tif (PyErr_Occurred())\n\\t\\tPy_FatalError(\\\"can't initialize module #modulename# (failed to import numpy)\\\");\n\\td = PyModule_GetDict(m);\n\\ts = PyString_FromString(\\\"$R\"\"\"+\"\"\"evision: $\\\");\n\\tPyDict_SetItemString(d, \\\"__version__\\\", s);\n\\ts = PyString_FromString(\\\"This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\\\\nFunctions:\\\\n\\\"\\n#docs#\\\".\\\");\n\\tPyDict_SetItemString(d, \\\"__doc__\\\", s);\n\\t#modulename#_error = PyErr_NewException (\\\"#modulename#.error\\\", NULL, NULL);\n\\tPy_DECREF(s);\n\\tfor(i=0;f2py_routine_defs[i].name!=NULL;i++)\n\\t\\tPyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i]));\n#initf2pywraphooks#\n#initf90modhooks#\n#initcommonhooks#\n#interface_usercode#\n\\tif (PyErr_Occurred())\n\\t\\tPy_FatalError(\\\"can't initialize module #modulename#\\\");\n\n#ifdef F2PY_REPORT_ATEXIT\n\\ton_exit(f2py_report_on_exit,(void*)\\\"#modulename#\\\");\n#endif\n\n}\n#ifdef __cplusplus\n}\n#endif\n\"\"\",\n 'separatorsfor':{'latexdoc':'\\n\\n',\n 'restdoc':'\\n\\n'},\n 'latexdoc':['\\\\section{Module \\\\texttt{#texmodulename#}}\\n',\n '#modnote#\\n',\n '#latexdoc#'],\n 'restdoc':['Module #modulename#\\n'+'='*80,\n '\\n#restdoc#']\n }\n\ndefmod_rules=[\n {'body':'/*eof body*/',\n 'method':'/*eof method*/',\n 'externroutines':'/*eof externroutines*/',\n 'routine_defs':'/*eof routine_defs*/',\n 'initf90modhooks':'/*eof initf90modhooks*/',\n 'initf2pywraphooks':'/*eof initf2pywraphooks*/',\n 'initcommonhooks':'/*eof initcommonhooks*/',\n 'latexdoc':'',\n 'restdoc':'',\n 'modnote':{hasnote:'#note#',l_not(hasnote):''},\n }\n ]\n\nroutine_rules={\n 'separatorsfor':sepdict,\n 'body':\"\"\"\n#begintitle#\nstatic char doc_#apiname#[] = \\\"\\\\\\nFunction signature:\\\\n\\\\\\n\\t#docreturn##name#(#docsignatureshort#)\\\\n\\\\\\n#docstrsigns#\\\";\n/* #declfortranroutine# */\nstatic PyObject *#apiname#(const PyObject *capi_self,\n PyObject *capi_args,\n PyObject *capi_keywds,\n #functype# (*f2py_func)(#callprotoargument#)) {\n\\tPyObject * volatile capi_buildvalue = NULL;\n\\tvolatile int f2py_success = 1;\n#decl#\n\\tstatic char *capi_kwlist[] = {#kwlist##kwlistopt##kwlistxa#NULL};\n#usercode#\n#routdebugenter#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_clock();\n#endif\n\\tif (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\\\\\n\\t\\t\\\"#argformat#|#keyformat##xaformat#:#pyname#\\\",\\\\\n\\t\\tcapi_kwlist#args_capi##keys_capi##keys_xa#))\\n\\t\\treturn NULL;\n#frompyobj#\n/*end of frompyobj*/\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_call_clock();\n#endif\n#callfortranroutine#\nif (PyErr_Occurred())\n f2py_success = 0;\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_call_clock();\n#endif\n/*end of callfortranroutine*/\n\\t\\tif (f2py_success) {\n#pyobjfrom#\n/*end of pyobjfrom*/\n\\t\\tCFUNCSMESS(\\\"Building return value.\\\\n\\\");\n\\t\\tcapi_buildvalue = Py_BuildValue(\\\"#returnformat#\\\"#return#);\n/*closepyobjfrom*/\n#closepyobjfrom#\n\\t\\t} /*if (f2py_success) after callfortranroutine*/\n/*cleanupfrompyobj*/\n#cleanupfrompyobj#\n\\tif (capi_buildvalue == NULL) {\n#routdebugfailure#\n\\t} else {\n#routdebugleave#\n\\t}\n\\tCFUNCSMESS(\\\"Freeing memory.\\\\n\\\");\n#freemem#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_clock();\n#endif\n\\treturn capi_buildvalue;\n}\n#endtitle#\n\"\"\",\n 'routine_defs':'#routine_def#',\n 'initf2pywraphooks':'#initf2pywraphook#',\n 'externroutines':'#declfortranroutine#',\n 'doc':'#docreturn##name#(#docsignature#)',\n 'docshort':'#docreturn##name#(#docsignatureshort#)',\n 'docs':'\"\\t#docreturn##name#(#docsignature#)\\\\n\"\\n',\n 'need':['arrayobject.h','CFUNCSMESS','MINMAX'],\n 'cppmacros':{debugcapi:'#define DEBUGCFUNCS'},\n 'latexdoc':['\\\\subsection{Wrapper function \\\\texttt{#texname#}}\\n',\n \"\"\"\n\\\\noindent{{}\\\\verb@#docreturn##name#@{}}\\\\texttt{(#latexdocsignatureshort#)}\n#routnote#\n\n#latexdocstrsigns#\n\"\"\"],\n 'restdoc':['Wrapped function ``#name#``\\n'+'-'*80,\n \n ]\n }\n\n################## Rules for C/API function ##############\n\nrout_rules=[\n { # Init\n 'separatorsfor': {'callfortranroutine':'\\n','routdebugenter':'\\n','decl':'\\n',\n 'routdebugleave':'\\n','routdebugfailure':'\\n',\n 'setjmpbuf':' || ',\n 'docstrreq':'\\n','docstropt':'\\n','docstrout':'\\n',\n 'docstrcbs':'\\n','docstrsigns':'\\\\n\"\\n\"',\n 'latexdocstrsigns':'\\n',\n 'latexdocstrreq':'\\n','latexdocstropt':'\\n',\n 'latexdocstrout':'\\n','latexdocstrcbs':'\\n',\n },\n 'kwlist':'','kwlistopt':'','callfortran':'','callfortranappend':'',\n 'docsign':'','docsignopt':'','decl':'/*decl*/',\n 'freemem':'/*freemem*/',\n 'docsignshort':'','docsignoptshort':'',\n 'docstrsigns':'','latexdocstrsigns':'',\n 'docstrreq':'Required arguments:',\n 'docstropt':'Optional arguments:',\n 'docstrout':'Return objects:',\n 'docstrcbs':'Call-back functions:',\n 'latexdocstrreq':'\\\\noindent Required arguments:',\n 'latexdocstropt':'\\\\noindent Optional arguments:',\n 'latexdocstrout':'\\\\noindent Return objects:',\n 'latexdocstrcbs':'\\\\noindent Call-back functions:',\n 'args_capi':'','keys_capi':'','functype':'',\n 'frompyobj':'/*frompyobj*/',\n 'cleanupfrompyobj':['/*end of cleanupfrompyobj*/'], #this list will be reversed\n 'pyobjfrom':'/*pyobjfrom*/',\n 'closepyobjfrom':['/*end of closepyobjfrom*/'], #this list will be reversed\n 'topyarr':'/*topyarr*/','routdebugleave':'/*routdebugleave*/',\n 'routdebugenter':'/*routdebugenter*/',\n 'routdebugfailure':'/*routdebugfailure*/',\n 'callfortranroutine':'/*callfortranroutine*/',\n 'argformat':'','keyformat':'','need_cfuncs':'',\n 'docreturn':'','return':'','returnformat':'','rformat':'',\n 'kwlistxa':'','keys_xa':'','xaformat':'','docsignxa':'','docsignxashort':'',\n 'initf2pywraphook':'',\n 'routnote':{hasnote:'--- #note#',l_not(hasnote):''},\n },{\n 'apiname':'f2py_rout_#modulename#_#name#',\n 'pyname':'#modulename#.#name#',\n 'decl':'',\n '_check':l_not(ismoduleroutine)\n },{\n 'apiname':'f2py_rout_#modulename#_#f90modulename#_#name#',\n 'pyname':'#modulename#.#f90modulename#.#name#',\n 'decl':'',\n '_check':ismoduleroutine\n },{ # Subroutine\n 'functype':'void',\n 'declfortranroutine':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'extern void #fortranname#(#callprotoargument#);',\n ismoduleroutine:'',\n isdummyroutine:''\n },\n 'routine_def':{l_not(l_or(ismoduleroutine,isintent_c,isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isdummyroutine):'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'need':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'F_FUNC'},\n 'callfortranroutine':[\n {debugcapi:[\"\"\"\\tfprintf(stderr,\\\"debug-capi:Fortran subroutine `#fortranname#(#callfortran#)\\'\\\\n\\\");\"\"\"]},\n {hasexternals:\"\"\"\\\n\\t\\tif (#setjmpbuf#) {\n\\t\\t\\tf2py_success = 0;\n\\t\\t} else {\"\"\"},\n {isthreadsafe:'\\t\\t\\tPy_BEGIN_ALLOW_THREADS'},\n {hascallstatement:'''\\t\\t\\t\\t#callstatement#;\n\\t\\t\\t\\t/*(*f2py_func)(#callfortran#);*/'''},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t\\t\\t\\t(*f2py_func)(#callfortran#);'},\n {isthreadsafe:'\\t\\t\\tPy_END_ALLOW_THREADS'},\n {hasexternals:\"\"\"\\t\\t}\"\"\"}\n ],\n '_check':issubroutine,\n },{ # Wrapped function\n 'functype':'void',\n 'declfortranroutine':{l_not(l_or(ismoduleroutine,isdummyroutine)):'extern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);',\n isdummyroutine:'',\n },\n\n 'routine_def':{l_not(l_or(ismoduleroutine,isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_WRAPPEDFUNC#(#name_lower#,#NAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n isdummyroutine:'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'initf2pywraphook':{l_not(l_or(ismoduleroutine,isdummyroutine)):'''\n {\n extern #ctype# #F_FUNC#(#name_lower#,#NAME#)(void);\n PyObject* o = PyDict_GetItemString(d,\"#name#\");\n PyObject_SetAttrString(o,\"_cpointer\", PyCObject_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL));\n }\n '''},\n 'need':{l_not(l_or(ismoduleroutine,isdummyroutine)):['F_WRAPPEDFUNC','F_FUNC']},\n 'callfortranroutine':[\n {debugcapi:[\"\"\"\\tfprintf(stderr,\\\"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)\\'\\\\n\\\");\"\"\"]},\n {hasexternals:\"\"\"\\\n\\tif (#setjmpbuf#) {\n\\t\\tf2py_success = 0;\n\\t} else {\"\"\"},\n {isthreadsafe:'\\tPy_BEGIN_ALLOW_THREADS'},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t(*f2py_func)(#callfortran#);'},\n {hascallstatement:'\\t#callstatement#;\\n\\t/*(*f2py_func)(#callfortran#);*/'},\n {isthreadsafe:'\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t}'}\n ],\n '_check':isfunction_wrap,\n },{ # Function\n 'functype':'#ctype#',\n 'docreturn':{l_not(isintent_hide):'#rname#,'},\n 'docstrout':'\\t#pydocsignout#',\n 'latexdocstrout':['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {hasresultnote:'--- #resultnote#'}],\n 'callfortranroutine':[{l_and(debugcapi,isstringfunction):\"\"\"\\\n#ifdef USESCOMPAQFORTRAN\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callcompaqfortran#)\\\\n\\\");\n#else\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\\\n\\\");\n#endif\n\"\"\"},\n {l_and(debugcapi,l_not(isstringfunction)):\"\"\"\\\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\\\n\\\");\n\"\"\"}\n ],\n '_check':l_and(isfunction,l_not(isfunction_wrap))\n },{ # Scalar function\n 'declfortranroutine':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'extern #ctype# #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'extern #ctype# #fortranname#(#callprotoargument#);',\n isdummyroutine:''\n },\n 'routine_def':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},',\n isdummyroutine:'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'decl':[{iscomplexfunction_warn:'\\t#ctype# #name#_return_value={0,0};',\n l_not(iscomplexfunction):'\\t#ctype# #name#_return_value=0;'},\n {iscomplexfunction:'\\tPyObject *#name#_return_value_capi = Py_None;'}\n ],\n 'callfortranroutine':[\n {hasexternals:\"\"\"\\\n\\tif (#setjmpbuf#) {\n\\t\\tf2py_success = 0;\n\\t} else {\"\"\"},\n {isthreadsafe:'\\tPy_BEGIN_ALLOW_THREADS'},\n {hascallstatement:'''\\t#callstatement#;\n/*\\t#name#_return_value = (*f2py_func)(#callfortran#);*/\n'''},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t#name#_return_value = (*f2py_func)(#callfortran#);'},\n {isthreadsafe:'\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t}'},\n {l_and(debugcapi,iscomplexfunction):'\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value.r,#name#_return_value.i);'},\n {l_and(debugcapi,l_not(iscomplexfunction)):'\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value);'}],\n 'pyobjfrom':{iscomplexfunction:'\\t#name#_return_value_capi = pyobj_from_#ctype#1(#name#_return_value);'},\n 'need':[{l_not(isdummyroutine):'F_FUNC'},\n {iscomplexfunction:'pyobj_from_#ctype#1'},\n {islong_longfunction:'long_long'},\n {islong_doublefunction:'long_double'}],\n 'returnformat':{l_not(isintent_hide):'#rformat#'},\n 'return':{iscomplexfunction:',#name#_return_value_capi',\n l_not(l_or(iscomplexfunction,isintent_hide)):',#name#_return_value'},\n '_check':l_and(isfunction,l_not(isstringfunction),l_not(isfunction_wrap))\n },{ # String function # in use for --no-wrap\n 'declfortranroutine':'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n 'routine_def':{l_not(l_or(ismoduleroutine,isintent_c)):\n# '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)F_FUNC(#fortranname#,#FORTRANNAME#),(void *)#apiname#,doc_#apiname#},',\n '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c):\n# '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(void *)#apiname#,doc_#apiname#},'\n '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},'\n },\n 'decl':['\\t#ctype# #name#_return_value = NULL;',\n '\\tint #name#_return_value_len = 0;'],\n 'callfortran':'#name#_return_value,#name#_return_value_len,',\n 'callfortranroutine':['\\t#name#_return_value_len = #rlength#;',\n '\\tif ((#name#_return_value = (string)malloc(sizeof(char)*(#name#_return_value_len+1))) == NULL) {',\n '\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"out of memory\\\");',\n '\\t\\tf2py_success = 0;',\n '\\t} else {',\n \"\\t\\t(#name#_return_value)[#name#_return_value_len] = '\\\\0';\",\n '\\t}',\n '\\tif (f2py_success) {',\n {hasexternals:\"\"\"\\\n\\t\\tif (#setjmpbuf#) {\n\\t\\t\\tf2py_success = 0;\n\\t\\t} else {\"\"\"},\n {isthreadsafe:'\\t\\tPy_BEGIN_ALLOW_THREADS'},\n \"\"\"\\\n#ifdef USESCOMPAQFORTRAN\n\\t\\t(*f2py_func)(#callcompaqfortran#);\n#else\n\\t\\t(*f2py_func)(#callfortran#);\n#endif\n\"\"\",\n {isthreadsafe:'\\t\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t\\t}'},\n {debugcapi:'\\t\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value_len,#name#_return_value);'},\n '\\t} /* if (f2py_success) after (string)malloc */',\n ],\n 'returnformat':'#rformat#',\n 'return':',#name#_return_value',\n 'freemem':'\\tSTRINGFREE(#name#_return_value);',\n 'need':['F_FUNC','#ctype#','STRINGFREE'],\n '_check':l_and(isstringfunction,l_not(isfunction_wrap)) # ???obsolete\n },\n { # Debugging\n 'routdebugenter':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#(#docsignature#)\\\\n\");',\n 'routdebugleave':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#: successful.\\\\n\");',\n 'routdebugfailure':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#: failure.\\\\n\");',\n '_check':debugcapi\n }\n ]\n\n################ Rules for arguments ##################\n\ntypedef_need_dict = {islong_long:'long_long',\n islong_double:'long_double',\n islong_complex:'complex_long_double',\n isunsigned_char:'unsigned_char',\n isunsigned_short:'unsigned_short',\n isunsigned:'unsigned',\n isunsigned_long_long:'unsigned_long_long'}\n\naux_rules=[\n {\n 'separatorsfor':sepdict\n },\n { # Common\n 'frompyobj':['\\t/* Processing auxiliary variable #varname# */',\n {debugcapi:'\\tfprintf(stderr,\"#vardebuginfo#\\\\n\");'},],\n 'cleanupfrompyobj':'\\t/* End of cleaning variable #varname# */',\n 'need':typedef_need_dict,\n },\n# Scalars (not complex)\n { # Common\n 'decl':'\\t#ctype# #varname# = 0;',\n 'need':{hasinitvalue:'math.h'},\n 'frompyobj':{hasinitvalue:'\\t#varname# = #init#;'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n },\n {\n 'return':',#varname#',\n 'docstrout':'\\t#pydocsignout#',\n 'docreturn':'#outvarname#,',\n 'returnformat':'#varrformat#',\n '_check':l_and(isscalar,l_not(iscomplex),isintent_out),\n },\n# Complex scalars\n { # Common\n 'decl':'\\t#ctype# #varname#;',\n 'frompyobj': {hasinitvalue:'\\t#varname#.r = #init.r#, #varname#.i = #init.i#;'},\n '_check':iscomplex\n },\n# String\n { # Common\n 'decl':['\\t#ctype# #varname# = NULL;',\n '\\tint slen(#varname#);',\n ],\n 'need':['len..'],\n '_check':isstring\n },\n# Array\n { # Common\n 'decl':['\\t#ctype# *#varname# = NULL;',\n '\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n '\\tconst int #varname#_Rank = #rank#;',\n ],\n 'need':['len..',{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}],\n '_check':isarray\n },\n# Scalararray\n { # Common\n '_check':l_and(isarray,l_not(iscomplexarray))\n },{ # Not hidden\n '_check':l_and(isarray,l_not(iscomplexarray),isintent_nothide)\n },\n# Integer*1 array\n {'need':'#ctype#',\n '_check':isint1array,\n '_depend':''\n },\n# Integer*-1 array\n {'need':'#ctype#',\n '_check':isunsigned_chararray,\n '_depend':''\n },\n# Integer*-2 array\n {'need':'#ctype#',\n '_check':isunsigned_shortarray,\n '_depend':''\n },\n# Integer*-8 array\n {'need':'#ctype#',\n '_check':isunsigned_long_longarray,\n '_depend':''\n },\n# Complexarray\n {'need':'#ctype#',\n '_check':iscomplexarray,\n '_depend':''\n },\n# Stringarray\n {\n 'callfortranappend':{isarrayofstrings:'flen(#varname#),'},\n 'need':'string',\n '_check':isstringarray\n }\n ]\n\narg_rules=[\n {\n 'separatorsfor':sepdict\n },\n { # Common\n 'frompyobj':['\\t/* Processing variable #varname# */',\n {debugcapi:'\\tfprintf(stderr,\"#vardebuginfo#\\\\n\");'},],\n 'cleanupfrompyobj':'\\t/* End of cleaning variable #varname# */',\n '_depend':'',\n 'need':typedef_need_dict,\n },\n# Doc signatures\n {\n 'docstropt':{l_and(isoptional,isintent_nothide):'\\t#pydocsign#'},\n 'docstrreq':{l_and(isrequired,isintent_nothide):'\\t#pydocsign#'},\n 'docstrout':{isintent_out:'\\t#pydocsignout#'},\n 'latexdocstropt':{l_and(isoptional,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrreq':{l_and(isrequired,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrout':{isintent_out:['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {l_and(hasnote,isintent_hide):'--- #note#',\n l_and(hasnote,isintent_nothide):'--- See above.'}]},\n 'depend':''\n },\n# Required/Optional arguments\n {\n 'kwlist':'\"#varname#\",',\n 'docsign':'#varname#,',\n '_check':l_and(isintent_nothide,l_not(isoptional))\n },\n {\n 'kwlistopt':'\"#varname#\",',\n 'docsignopt':'#varname#=#showinit#,',\n 'docsignoptshort':'#varname#,',\n '_check':l_and(isintent_nothide,isoptional)\n },\n# Docstring/BuildValue\n {\n 'docreturn':'#outvarname#,',\n 'returnformat':'#varrformat#',\n '_check':isintent_out\n },\n# Externals (call-back functions)\n { # Common\n 'docsignxa':{isintent_nothide:'#varname#_extra_args=(),'},\n 'docsignxashort':{isintent_nothide:'#varname#_extra_args,'},\n 'docstropt':{isintent_nothide:'\\t#varname#_extra_args := () input tuple'},\n 'docstrcbs':'#cbdocstr#',\n 'latexdocstrcbs':'\\\\item[] #cblatexdocstr#',\n 'latexdocstropt':{isintent_nothide:'\\\\item[]{{}\\\\verb@#varname#_extra_args := () input tuple@{}} --- Extra arguments for call-back function {{}\\\\verb@#varname#@{}}.'},\n 'decl':['\\tPyObject *#varname#_capi = Py_None;',\n '\\tPyTupleObject *#varname#_xa_capi = NULL;',\n '\\tPyTupleObject *#varname#_args_capi = NULL;',\n '\\tint #varname#_nofargs_capi = 0;',\n {l_not(isintent_callback):'\\t#cbname#_typedef #varname#_cptr;'}\n ],\n 'kwlistxa':{isintent_nothide:'\"#varname#_extra_args\",'},\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'xaformat':{isintent_nothide:'O!'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'keys_xa':',&PyTuple_Type,&#varname#_xa_capi',\n 'setjmpbuf':'(setjmp(#cbname#_jmpbuf))',\n 'callfortran':{l_not(isintent_callback):'#varname#_cptr,'},\n 'need':['#cbname#','setjmp.h'],\n '_check':isexternal\n },\n {\n 'frompyobj':[{l_not(isintent_callback):\"\"\"\\\nif(PyCObject_Check(#varname#_capi)) {\n #varname#_cptr = PyCObject_AsVoidPtr(#varname#_capi);\n} else {\n #varname#_cptr = #cbname#;\n}\n\"\"\"},{isintent_callback:\"\"\"\\\nif (#varname#_capi==Py_None) {\n #varname#_capi = PyObject_GetAttrString(#modulename#_module,\\\"#varname#\\\");\n if (#varname#_capi) {\n if (#varname#_xa_capi==NULL) {\n if (PyObject_HasAttrString(#modulename#_module,\\\"#varname#_extra_args\\\")) {\n PyObject* capi_tmp = PyObject_GetAttrString(#modulename#_module,\\\"#varname#_extra_args\\\");\n if (capi_tmp)\n #varname#_xa_capi = (PyTupleObject *)PySequence_Tuple(capi_tmp);\n else\n #varname#_xa_capi = (PyTupleObject *)Py_BuildValue(\\\"()\\\");\n if (#varname#_xa_capi==NULL) {\n PyErr_SetString(#modulename#_error,\\\"Failed to convert #modulename#.#varname#_extra_args to tuple.\\\\n\\\");\n return NULL;\n }\n }\n }\n }\n if (#varname#_capi==NULL) {\n PyErr_SetString(#modulename#_error,\\\"Callback #varname# not defined (as an argument or module #modulename# attribute).\\\\n\\\");\n return NULL;\n }\n}\n\"\"\"},\n## {l_not(isintent_callback):\"\"\"\\\n## if (#varname#_capi==Py_None) {\n## printf(\\\"hoi\\\\n\\\");\n## }\n## \"\"\"},\n\"\"\"\\\n\\t#varname#_nofargs_capi = #cbname#_nofargs;\n\\tif (create_cb_arglist(#varname#_capi,#varname#_xa_capi,#maxnofargs#,#nofoptargs#,&#cbname#_nofargs,&#varname#_args_capi,\\\"failed in processing argument list for call-back #varname#.\\\")) {\n\\t\\tjmp_buf #varname#_jmpbuf;\"\"\",\n{debugcapi:[\"\"\"\\\n\\t\\tfprintf(stderr,\\\"debug-capi:Assuming %d arguments; at most #maxnofargs#(-#nofoptargs#) is expected.\\\\n\\\",#cbname#_nofargs);\n\\t\\tCFUNCSMESSPY(\\\"for #varname#=\\\",#cbname#_capi);\"\"\",\n{l_not(isintent_callback):\"\"\"\\t\\tfprintf(stderr,\\\"#vardebugshowvalue# (call-back in C).\\\\n\\\",#cbname#);\"\"\"}]},\n \"\"\"\\\n\\t\\tCFUNCSMESS(\\\"Saving jmpbuf for `#varname#`.\\\\n\\\");\n\\t\\tSWAP(#varname#_capi,#cbname#_capi,PyObject);\n\\t\\tSWAP(#varname#_args_capi,#cbname#_args_capi,PyTupleObject);\n\\t\\tmemcpy(&#varname#_jmpbuf,&#cbname#_jmpbuf,sizeof(jmp_buf));\"\"\",\n ],\n'cleanupfrompyobj':\n\"\"\"\\\n\\t\\tCFUNCSMESS(\\\"Restoring jmpbuf for `#varname#`.\\\\n\\\");\n\\t\\t#cbname#_capi = #varname#_capi;\n\\t\\tPy_DECREF(#cbname#_args_capi);\n\\t\\t#cbname#_args_capi = #varname#_args_capi;\n\\t\\t#cbname#_nofargs = #varname#_nofargs_capi;\n\\t\\tmemcpy(&#cbname#_jmpbuf,&#varname#_jmpbuf,sizeof(jmp_buf));\n\\t}\"\"\",\n 'need':['SWAP','create_cb_arglist'],\n '_check':isexternal,\n '_depend':''\n },\n# Scalars (not complex)\n { # Common\n 'decl':'\\t#ctype# #varname# = 0;',\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#);'},\n 'callfortran':{isintent_c:'#varname#,',l_not(isintent_c):'&#varname#,'},\n 'return':{isintent_out:',#varname#'},\n '_check':l_and(isscalar,l_not(iscomplex))\n },{\n 'need':{hasinitvalue:'math.h'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n #'_depend':''\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'pyobjfrom':{isintent_inout:\"\"\"\\\n\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);\n\\tif (f2py_success) {\"\"\"},\n 'closepyobjfrom':{isintent_inout:\"\\t} /*if (f2py_success) of #varname# pyobjfrom*/\"},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n '_check':l_and(isscalar,l_not(iscomplex),isintent_nothide)\n },{\n 'frompyobj':[\n# hasinitvalue...\n# if pyobj is None:\n# varname = init\n# else\n# from_pyobj(varname)\n# \n# isoptional and noinitvalue...\n# if pyobj is not None:\n# from_pyobj(varname)\n# else:\n# varname is uninitialized\n#\n# ...\n# from_pyobj(varname)\n#\n {hasinitvalue:'\\tif (#varname#_capi == Py_None) #varname# = #init#; else',\n '_depend':''},\n {l_and(isoptional,l_not(hasinitvalue)):'\\tif (#varname#_capi != Py_None)',\n '_depend':''}, \n {l_not(islogical):'''\\\n\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#pyname#() #nth# (#varname#) can\\'t be converted to #ctype#\");\n\\tif (f2py_success) {'''},\n {islogical:'''\\\n\\t\\t#varname# = (#ctype#)PyObject_IsTrue(#varname#_capi);\n\\t\\tf2py_success = 1;\n\\tif (f2py_success) {'''},\n ],\n 'cleanupfrompyobj':'\\t} /*if (f2py_success) of #varname#*/',\n 'need':{l_not(islogical):'#ctype#_from_pyobj'},\n '_check':l_and(isscalar,l_not(iscomplex),isintent_nothide),\n '_depend':''\n# },{ # Hidden\n# '_check':l_and(isscalar,l_not(iscomplex),isintent_hide)\n },{ # Hidden\n 'frompyobj':{hasinitvalue:'\\t#varname# = #init#;'},\n 'need':typedef_need_dict,\n '_check':l_and(isscalar,l_not(iscomplex),isintent_hide),\n '_depend':''\n },{ # Common\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#);'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n '_depend':''\n },\n# Complex scalars\n { # Common\n 'decl':'\\t#ctype# #varname#;',\n 'callfortran':{isintent_c:'#varname#,',l_not(isintent_c):'&#varname#,'},\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#.r,#varname#.i);'},\n 'return':{isintent_out:',#varname#_capi'},\n '_check':iscomplex\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n 'pyobjfrom':{isintent_inout:\"\"\"\\\n\\t\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);\n\\t\\tif (f2py_success) {\"\"\"},\n 'closepyobjfrom':{isintent_inout:\"\\t\\t} /*if (f2py_success) of #varname# pyobjfrom*/\"},\n '_check':l_and(iscomplex,isintent_nothide)\n },{\n 'frompyobj':[{hasinitvalue:'\\tif (#varname#_capi==Py_None) {#varname#.r = #init.r#, #varname#.i = #init.i#;} else'},\n {l_and(isoptional,l_not(hasinitvalue)):'\\tif (#varname#_capi != Py_None)'},\n# '\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#ctype#_from_pyobj failed in converting #nth# `#varname#\\' of #pyname# to C #ctype#\\\\n\");'\n '\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#pyname#() #nth# (#varname#) can\\'t be converted to #ctype#\");'\n '\\n\\tif (f2py_success) {'],\n 'cleanupfrompyobj':'\\t} /*if (f2py_success) of #varname# frompyobj*/',\n 'need':['#ctype#_from_pyobj'],\n '_check':l_and(iscomplex,isintent_nothide),\n '_depend':''\n },{ # Hidden\n 'decl':{isintent_out:'\\tPyObject *#varname#_capi = Py_None;'},\n '_check':l_and(iscomplex,isintent_hide)\n },{\n 'frompyobj': {hasinitvalue:'\\t#varname#.r = #init.r#, #varname#.i = #init.i#;'},\n '_check':l_and(iscomplex,isintent_hide),\n '_depend':''\n },{ # Common\n 'pyobjfrom':{isintent_out:'\\t#varname#_capi = pyobj_from_#ctype#1(#varname#);'},\n 'need':['pyobj_from_#ctype#1'],\n '_check':iscomplex\n },{\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#.r,#varname#.i);'},\n '_check':iscomplex,\n '_depend':''\n },\n# String\n { # Common\n 'decl':['\\t#ctype# #varname# = NULL;',\n '\\tint slen(#varname#);',\n '\\tPyObject *#varname#_capi = Py_None;'],\n 'callfortran':'#varname#,',\n 'callfortranappend':'slen(#varname#),',\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",slen(#varname#),#varname#);'},\n# 'freemem':'\\tSTRINGFREE(#varname#);',\n 'return':{isintent_out:',#varname#'},\n 'need':['len..'],#'STRINGFREE'],\n '_check':isstring\n },{ # Common\n 'frompyobj':\"\"\"\\\n\\tslen(#varname#) = #length#;\n\\tf2py_success = #ctype#_from_pyobj(&#varname#,&slen(#varname#),#init#,#varname#_capi,\\\"#ctype#_from_pyobj failed in converting #nth# `#varname#\\' of #pyname# to C #ctype#\\\");\n\\tif (f2py_success) {\"\"\",\n 'cleanupfrompyobj':\"\"\"\\\n\\t\\tSTRINGFREE(#varname#);\n\\t} /*if (f2py_success) of #varname#*/\"\"\",\n 'need':['#ctype#_from_pyobj','len..','STRINGFREE'],\n '_check':isstring,\n '_depend':''\n },{ # Not hidden\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'pyobjfrom':{isintent_inout:'''\\\n\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,#varname#);\n\\tif (f2py_success) {'''},\n 'closepyobjfrom':{isintent_inout:'\\t} /*if (f2py_success) of #varname# pyobjfrom*/'},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n '_check':l_and(isstring,isintent_nothide)\n },{ # Hidden\n '_check':l_and(isstring,isintent_hide)\n },{\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",slen(#varname#),#varname#);'},\n '_check':isstring,\n '_depend':''\n },\n# Array\n { # Common\n 'decl':['\\t#ctype# *#varname# = NULL;',\n '\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n '\\tconst int #varname#_Rank = #rank#;',\n '\\tPyArrayObject *capi_#varname#_tmp = NULL;',\n '\\tint capi_#varname#_intent = 0;',\n ],\n 'callfortran':'#varname#,',\n 'return':{isintent_out:',capi_#varname#_tmp'},\n 'need':'len..',\n '_check':isarray\n },{ # intent(overwrite) array\n 'decl':'\\tint capi_overwrite_#varname# = 1;',\n 'kwlistxa':'\"overwrite_#varname#\",',\n 'xaformat':'i',\n 'keys_xa':',&capi_overwrite_#varname#',\n 'docsignxa':'overwrite_#varname#=1,',\n 'docsignxashort':'overwrite_#varname#,',\n 'docstropt':'\\toverwrite_#varname# := 1 input int',\n '_check':l_and(isarray,isintent_overwrite),\n },{\n 'frompyobj':'\\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',\n '_check':l_and(isarray,isintent_overwrite),\n '_depend':'',\n },\n { # intent(copy) array\n 'decl':'\\tint capi_overwrite_#varname# = 0;',\n 'kwlistxa':'\"overwrite_#varname#\",',\n 'xaformat':'i',\n 'keys_xa':',&capi_overwrite_#varname#',\n 'docsignxa':'overwrite_#varname#=0,',\n 'docsignxashort':'overwrite_#varname#,',\n 'docstropt':'\\toverwrite_#varname# := 0 input int',\n '_check':l_and(isarray,isintent_copy),\n },{\n 'frompyobj':'\\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',\n '_check':l_and(isarray,isintent_copy),\n '_depend':'',\n },{ \n 'need':[{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}],\n '_check':isarray,\n '_depend':''\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n# 'pyobjfrom':{isintent_inout:\"\"\"\\\n# /* Partly because of the following hack, intent(inout) is depreciated,\n# Use intent(in,out) instead.\n \n# \\tif ((#varname#_capi != Py_None) && PyArray_Check(#varname#_capi) \\\\\n# \\t\\t&& (#varname#_capi != (PyObject *)capi_#varname#_tmp)) {\n# \\t\\tif (((PyArrayObject *)#varname#_capi)->nd != capi_#varname#_tmp->nd) {\n# \\t\\t\\tif (#varname#_capi != capi_#varname#_tmp->base)\n# \\t\\t\\t\\tcopy_ND_array((PyArrayObject *)capi_#varname#_tmp->base,(PyArrayObject *)#varname#_capi);\n# \\t\\t} else\n# \\t\\t\\tcopy_ND_array(capi_#varname#_tmp,(PyArrayObject *)#varname#_capi);\n# \\t}\n# */\n# \"\"\"},\n# 'need':{isintent_inout:'copy_ND_array'},\n '_check':l_and(isarray,isintent_nothide)\n },{\n 'frompyobj':['\\t#setdims#;',\n '\\tcapi_#varname#_intent |= #intent#;',\n {isintent_hide:'\\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,Py_None);'},\n {isintent_nothide:'\\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'},\n \"\"\"\\\n\\tif (capi_#varname#_tmp == NULL) {\n\\t\\tif (!PyErr_Occurred())\n\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"failed in converting #nth# `#varname#\\' of #pyname# to C/Fortran array\\\" );\n\\t} else {\n\\t\\t#varname# = (#ctype# *)(capi_#varname#_tmp->data);\n\"\"\",\n{hasinitvalue:[\n {isintent_nothide:'\\tif (#varname#_capi == Py_None) {'},\n {isintent_hide:'\\t{'},\n {iscomplexarray:'\\t\\t#ctype# capi_c;'},\n \"\"\"\\\n\\t\\tint *_i,capi_i=0;\n\\t\\tCFUNCSMESS(\\\"#name#: Initializing #varname#=#init#\\\\n\\\");\n\\t\\tif (initforcomb(capi_#varname#_tmp->dimensions,capi_#varname#_tmp->nd,1)) {\n\\t\\t\\twhile ((_i = nextforcomb()))\n\\t\\t\\t\\t#varname#[capi_i++] = #init#; /* fortran way */\n\\t\\t} else {\n\\t\\t\\tif (!PyErr_Occurred())\n\\t\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"Initialization of #nth# #varname# failed (initforcomb).\\\");\n\\t\\t\\tf2py_success = 0;\n\\t\\t}\n\\t}\n\\tif (f2py_success) {\"\"\"]},\n ],\n 'cleanupfrompyobj':[ # note that this list will be reversed\n '\\t} /*if (capi_#varname#_tmp == NULL) ... else of #varname#*/',\n {l_not(l_or(isintent_out,isintent_hide)):\"\"\"\\\n\\tif((PyObject *)capi_#varname#_tmp!=#varname#_capi) {\n\\t\\tPy_XDECREF(capi_#varname#_tmp); }\"\"\"},\n {l_and(isintent_hide,l_not(isintent_out)):\"\"\"\\t\\tPy_XDECREF(capi_#varname#_tmp);\"\"\"},\n {hasinitvalue:'\\t} /*if (f2py_success) of #varname# init*/'},\n ],\n '_check':isarray,\n '_depend':''\n },\n# { # Hidden\n# 'freemem':{l_not(isintent_out):'\\tPy_XDECREF(capi_#varname#_tmp);'},\n# '_check':l_and(isarray,isintent_hide)\n# },\n# Scalararray\n { # Common\n '_check':l_and(isarray,l_not(iscomplexarray))\n },{ # Not hidden\n '_check':l_and(isarray,l_not(iscomplexarray),isintent_nothide)\n },\n# Integer*1 array\n {'need':'#ctype#',\n '_check':isint1array,\n '_depend':''\n },\n# Integer*-1 array\n {'need':'#ctype#',\n '_check':isunsigned_chararray,\n '_depend':''\n },\n# Integer*-2 array\n {'need':'#ctype#',\n '_check':isunsigned_shortarray,\n '_depend':''\n },\n# Integer*-8 array\n {'need':'#ctype#',\n '_check':isunsigned_long_longarray,\n '_depend':''\n },\n# Complexarray\n {'need':'#ctype#',\n '_check':iscomplexarray,\n '_depend':''\n },\n# Stringarray\n {\n 'callfortranappend':{isarrayofstrings:'flen(#varname#),'},\n 'need':'string',\n '_check':isstringarray\n }\n ]\n\n################# Rules for checking ###############\n\ncheck_rules=[\n {\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\\\"debug-capi:Checking `#check#\\'\\\\n\\\");'},\n 'need':'len..'\n },{\n 'frompyobj':'\\tCHECKSCALAR(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\",\\\"#varshowvalue#\\\",#varname#) {',\n 'cleanupfrompyobj':'\\t} /*CHECKSCALAR(#check#)*/',\n 'need':'CHECKSCALAR',\n '_check':l_and(isscalar,l_not(iscomplex)),\n '_break':''\n },{\n 'frompyobj':'\\tCHECKSTRING(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\",\\\"#varshowvalue#\\\",#varname#) {',\n 'cleanupfrompyobj':'\\t} /*CHECKSTRING(#check#)*/',\n 'need':'CHECKSTRING',\n '_check':isstring,\n '_break':''\n },{\n 'need':'CHECKARRAY',\n 'frompyobj':'\\tCHECKARRAY(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\") {',\n 'cleanupfrompyobj':'\\t} /*CHECKARRAY(#check#)*/',\n '_check':isarray,\n '_break':''\n },{\n 'need':'CHECKGENERIC',\n 'frompyobj':'\\tCHECKGENERIC(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\") {',\n 'cleanupfrompyobj':'\\t} /*CHECKGENERIC(#check#)*/',\n }\n]\n\n########## Applying the rules. No need to modify what follows #############\n\n#################### Build C/API module #######################\n\ndef buildmodule(m,um):\n \"\"\"\n Return \n \"\"\"\n global f2py_version,options\n outmess('\\tBuilding module \"%s\"...\\n'%(m['name']))\n ret = {}\n mod_rules=defmod_rules[:]\n vrd=modsign2map(m)\n rd=dictappend({'f2py_version':f2py_version},vrd)\n funcwrappers = []\n funcwrappers2 = [] # F90 codes\n for n in m['interfaced']:\n nb=None\n for bi in m['body']:\n if not bi['block']=='interface':\n errmess('buildmodule: Expected interface block. Skipping.\\n')\n continue\n for b in bi['body']:\n if b['name']==n: nb=b;break\n \n if not nb:\n errmess('buildmodule: Could not found the body of interfaced routine \"%s\". Skipping.\\n'%(n))\n continue\n nb_list = [nb]\n if nb.has_key('entry'):\n for k,a in nb['entry'].items():\n nb1 = copy.deepcopy(nb)\n del nb1['entry']\n nb1['name'] = k\n nb1['args'] = a\n nb_list.append(nb1)\n for nb in nb_list:\n api,wrap=buildapi(nb)\n if wrap:\n if ismoduleroutine(nb):\n funcwrappers2.append(wrap)\n else:\n funcwrappers.append(wrap)\n ar=applyrules(api,vrd)\n rd=dictappend(rd,ar)\n\n # Construct COMMON block support\n cr,wrap = common_rules.buildhooks(m)\n if wrap:\n funcwrappers.append(wrap)\n ar=applyrules(cr,vrd)\n rd=dictappend(rd,ar)\n\n # Construct F90 module support\n mr,wrap = f90mod_rules.buildhooks(m)\n if wrap:\n funcwrappers2.append(wrap)\n ar=applyrules(mr,vrd)\n rd=dictappend(rd,ar)\n\n for u in um:\n ar=use_rules.buildusevars(u,m['use'][u['name']])\n rd=dictappend(rd,ar)\n\n needs=cfuncs.get_needs()\n code={}\n for n in needs.keys():\n code[n]=[]\n for k in needs[n]:\n c=''\n if cfuncs.includes0.has_key(k): c=cfuncs.includes0[k]\n elif cfuncs.includes.has_key(k): c=cfuncs.includes[k]\n elif cfuncs.userincludes.has_key(k): c=cfuncs.userincludes[k]\n elif cfuncs.typedefs.has_key(k): c=cfuncs.typedefs[k]\n elif cfuncs.typedefs_generated.has_key(k):\n c=cfuncs.typedefs_generated[k]\n elif cfuncs.cppmacros.has_key(k): c=cfuncs.cppmacros[k]\n elif cfuncs.cfuncs.has_key(k): c=cfuncs.cfuncs[k]\n elif cfuncs.callbacks.has_key(k): c=cfuncs.callbacks[k]\n elif cfuncs.f90modhooks.has_key(k): c=cfuncs.f90modhooks[k]\n elif cfuncs.commonhooks.has_key(k): c=cfuncs.commonhooks[k]\n else: errmess('buildmodule: unknown need %s.\\n'%(`k`));continue\n code[n].append(c)\n mod_rules.append(code)\n for r in mod_rules:\n if (r.has_key('_check') and r['_check'](m)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,m)\n rd=dictappend(rd,ar)\n ar=applyrules(module_rules,rd)\n\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.c')\n ret['csrc'] = fn\n f=open(fn,'w')\n f.write(string.replace(ar['modulebody'],'\\t',2*' '))\n f.close()\n outmess('\\tWrote C/API module \"%s\" to file \"%s/%smodule.c\"\\n'%(m['name'],options['buildpath'],vrd['modulename']))\n\n if options['dorestdoc']:\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.rest')\n f=open(fn,'w')\n f.write('.. -*- rest -*-\\n')\n f.write(string.join(ar['restdoc'],'\\n'))\n f.close()\n outmess('\\tReST Documentation is saved to file \"%s/%smodule.rest\"\\n'%(options['buildpath'],vrd['modulename']))\n if options['dolatexdoc']:\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.tex')\n ret['ltx'] = fn\n f=open(fn,'w')\n f.write('%% This file is auto-generated with f2py (version:%s)\\n'%(f2py_version))\n if not options.has_key('shortlatex'):\n f.write('\\\\documentclass{article}\\n\\\\usepackage{a4wide}\\n\\\\begin{document}\\n\\\\tableofcontents\\n\\n')\n f.write(string.join(ar['latexdoc'],'\\n'))\n if not options.has_key('shortlatex'):\n f.write('\\\\end{document}')\n f.close()\n outmess('\\tDocumentation is saved to file \"%s/%smodule.tex\"\\n'%(options['buildpath'],vrd['modulename']))\n if funcwrappers:\n wn = os.path.join(options['buildpath'],'%s-f2pywrappers.f'%(vrd['modulename']))\n ret['fsrc'] = wn\n f=open(wn,'w')\n f.write('C -*- fortran -*-\\n')\n f.write('C This file is autogenerated with f2py (version:%s)\\n'%(f2py_version))\n f.write('C It contains Fortran 77 wrappers to fortran functions.\\n')\n lines = []\n for l in string.split(string.join(funcwrappers,'\\n\\n')+'\\n','\\n'):\n if l and l[0]==' ':\n while len(l)>=66:\n lines.append(l[:66]+'\\n &')\n l = l[66:]\n lines.append(l+'\\n')\n else: lines.append(l+'\\n')\n lines = string.join(lines,'').replace('\\n &\\n','\\n')\n f.write(lines)\n f.close()\n outmess('\\tFortran 77 wrappers are saved to \"%s\"\\n'%(wn))\n if funcwrappers2:\n wn = os.path.join(options['buildpath'],'%s-f2pywrappers2.f90'%(vrd['modulename']))\n ret['fsrc'] = wn\n f=open(wn,'w')\n f.write('! -*- f90 -*-\\n')\n f.write('! This file is autogenerated with f2py (version:%s)\\n'%(f2py_version))\n f.write('! It contains Fortran 90 wrappers to fortran functions.\\n')\n lines = []\n for l in string.split(string.join(funcwrappers2,'\\n\\n')+'\\n','\\n'):\n if len(l)>72 and l[0]==' ':\n lines.append(l[:72]+'&\\n &')\n l = l[72:]\n while len(l)>66:\n lines.append(l[:66]+'&\\n &')\n l = l[66:]\n lines.append(l+'\\n')\n else: lines.append(l+'\\n')\n lines = string.join(lines,'').replace('\\n &\\n','\\n')\n f.write(lines)\n f.close()\n outmess('\\tFortran 90 wrappers are saved to \"%s\"\\n'%(wn))\n return ret\n\n################## Build C/API function #############\n\nstnd={1:'st',2:'nd',3:'rd',4:'th',5:'th',6:'th',7:'th',8:'th',9:'th',0:'th'}\ndef buildapi(rout):\n rout,wrap = func2subr.assubr(rout)\n args,depargs=getargs2(rout)\n capi_maps.depargs=depargs\n var=rout['vars']\n auxvars = [a for a in var.keys() if isintent_aux(var[a])]\n \n if ismoduleroutine(rout):\n outmess('\\t\\t\\tConstructing wrapper function \"%s.%s\"...\\n'%(rout['modulename'],rout['name']))\n else:\n outmess('\\t\\tConstructing wrapper function \"%s\"...\\n'%(rout['name']))\n # Routine\n vrd=routsign2map(rout)\n rd=dictappend({},vrd)\n for r in rout_rules:\n if (r.has_key('_check') and r['_check'](rout)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,rout)\n rd=dictappend(rd,ar)\n\n # Args\n nth,nthk=0,0\n savevrd={}\n for a in args:\n vrd=sign2map(a,var[a])\n if isintent_aux(var[a]):\n _rules = aux_rules\n else:\n _rules = arg_rules\n if not isintent_hide(var[a]):\n if not isoptional(var[a]):\n nth=nth+1\n vrd['nth']=`nth`+stnd[nth%10]+' argument'\n else:\n nthk=nthk+1\n vrd['nth']=`nthk`+stnd[nthk%10]+' keyword'\n else: vrd['nth']='hidden' \n savevrd[a]=vrd\n for r in _rules:\n if r.has_key('_depend'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in depargs:\n if isintent_aux(var[a]):\n _rules = aux_rules\n else:\n _rules = arg_rules\n vrd=savevrd[a]\n for r in _rules:\n if not r.has_key('_depend'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n if var[a].has_key('check'):\n for c in var[a]['check']:\n vrd['check']=c\n ar=applyrules(check_rules,vrd,var[a])\n rd=dictappend(rd,ar)\n if type(rd['cleanupfrompyobj']) is types.ListType:\n rd['cleanupfrompyobj'].reverse()\n if type(rd['closepyobjfrom']) is types.ListType:\n rd['closepyobjfrom'].reverse()\n rd['docsignature']=stripcomma(replace('#docsign##docsignopt##docsignxa#',\n {'docsign':rd['docsign'],\n 'docsignopt':rd['docsignopt'],\n 'docsignxa':rd['docsignxa']}))\n optargs=stripcomma(replace('#docsignopt##docsignxa#',\n {'docsignxa':rd['docsignxashort'],\n 'docsignopt':rd['docsignoptshort']}\n ))\n if optargs=='':\n rd['docsignatureshort']=stripcomma(replace('#docsign#',{'docsign':rd['docsign']}))\n else:\n rd['docsignatureshort']=replace('#docsign#[#docsignopt#]',\n {'docsign':rd['docsign'],\n 'docsignopt':optargs,\n })\n rd['latexdocsignatureshort']=string.replace(rd['docsignatureshort'],'_','\\\\_')\n rd['latexdocsignatureshort']=string.replace(rd['latexdocsignatureshort'],',',', ')\n cfs=stripcomma(replace('#callfortran##callfortranappend#',{'callfortran':rd['callfortran'],'callfortranappend':rd['callfortranappend']}))\n if len(rd['callfortranappend'])>1:\n rd['callcompaqfortran']=stripcomma(replace('#callfortran# 0,#callfortranappend#',{'callfortran':rd['callfortran'],'callfortranappend':rd['callfortranappend']}))\n else:\n rd['callcompaqfortran']=cfs\n rd['callfortran']=cfs\n if type(rd['docreturn'])==types.ListType:\n rd['docreturn']=stripcomma(replace('#docreturn#',{'docreturn':rd['docreturn']}))+' = '\n rd['docstrsigns']=[]\n rd['latexdocstrsigns']=[]\n for k in ['docstrreq','docstropt','docstrout','docstrcbs']:\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['docstrsigns']=rd['docstrsigns']+rd[k]\n k='latex'+k\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['latexdocstrsigns']=rd['latexdocstrsigns']+rd[k][0:1]+\\\n ['\\\\begin{description}']+rd[k][1:]+\\\n ['\\\\end{description}']\n ar=applyrules(routine_rules,rd)\n if ismoduleroutine(rout):\n outmess('\\t\\t\\t %s\\n'%(ar['docshort']))\n else:\n outmess('\\t\\t %s\\n'%(ar['docshort']))\n return ar,wrap\n\n\n#################### EOF rules.py #######################\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nRules for building C/API module with f2py2e.\n\nHere is a skeleton of a new wrapper function (13Dec2001):\n\nwrapper_function(args)\n declarations\n get_python_arguments, say, `a' and `b'\n\n get_a_from_python\n if (successful) {\n\n get_b_from_python\n if (successful) {\n\n callfortran\n if (succesful) {\n\n put_a_to_python\n if (succesful) {\n\n put_b_to_python\n if (succesful) {\n\n buildvalue = ...\n\n }\n\n }\n \n }\n\n }\n cleanup_b\n\n }\n cleanup_a\n\n return buildvalue\n\"\"\"\n\"\"\"\nCopyright 1999,2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2005/08/30 08:58:42 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.129 $\"[10:-1]\n\nimport __version__\nf2py_version = __version__.version\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nfrom capi_maps import *\nimport cfuncs\nimport common_rules\nimport use_rules\nimport f90mod_rules\nimport func2subr\noptions={}\n\nsepdict={}\n#for k in ['need_cfuncs']: sepdict[k]=','\nfor k in ['decl',\n 'frompyobj',\n 'cleanupfrompyobj',\n 'topyarr','method',\n 'pyobjfrom','closepyobjfrom',\n 'freemem',\n 'userincludes',\n 'includes0','includes','typedefs','typedefs_generated',\n 'cppmacros','cfuncs','callbacks',\n 'latexdoc',\n 'restdoc',\n 'routine_defs','externroutines',\n 'initf2pywraphooks',\n 'commonhooks','initcommonhooks',\n 'f90modhooks','initf90modhooks']:\n sepdict[k]='\\n'\n\n#################### Rules for C/API module #################\n\nmodule_rules={\n 'modulebody':\"\"\"\\\n/* File: #modulename#module.c\n * This file is auto-generated with f2py (version:#f2py_version#).\n * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,\n * written by Pearu Peterson .\n * See http://cens.ioc.ee/projects/f2py2e/\n * Generation date: \"\"\"+time.asctime(time.localtime(time.time()))+\"\"\"\n * $R\"\"\"+\"\"\"evision:$\n * $D\"\"\"+\"\"\"ate:$\n * Do not edit this file directly unless you know what you are doing!!!\n */\n#ifdef __cplusplus\nextern \\\"C\\\" {\n#endif\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: includes\")+\"\"\"\n#includes#\n#includes0#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: mod_rules['modulebody']\")+\"\"\"\nstatic PyObject *#modulename#_error;\nstatic PyObject *#modulename#_module;\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: typedefs\")+\"\"\"\n#typedefs#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: typedefs_generated\")+\"\"\"\n#typedefs_generated#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: cppmacros\")+\"\"\"\n#cppmacros#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: cfuncs\")+\"\"\"\n#cfuncs#\n\n\"\"\"+gentitle(\"See f2py2e/cfuncs.py: userincludes\")+\"\"\"\n#userincludes#\n\n\"\"\"+gentitle(\"See f2py2e/capi_rules.py: usercode\")+\"\"\"\n#usercode#\n\n/* See f2py2e/rules.py */\n#externroutines#\n\n\"\"\"+gentitle(\"See f2py2e/capi_rules.py: usercode1\")+\"\"\"\n#usercode1#\n\n\"\"\"+gentitle(\"See f2py2e/cb_rules.py: buildcallback\")+\"\"\"\n#callbacks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: buildapi\")+\"\"\"\n#body#\n\n\"\"\"+gentitle(\"See f2py2e/f90mod_rules.py: buildhooks\")+\"\"\"\n#f90modhooks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py: module_rules['modulebody']\")+\"\"\"\n\n\"\"\"+gentitle(\"See f2py2e/common_rules.py: buildhooks\")+\"\"\"\n#commonhooks#\n\n\"\"\"+gentitle(\"See f2py2e/rules.py\")+\"\"\"\n\nstatic FortranDataDef f2py_routine_defs[] = {\n#routine_defs#\n\\t{NULL}\n};\n\nstatic PyMethodDef f2py_module_methods[] = {\n#pymethoddef#\n\\t{NULL,NULL}\n};\n\nDL_EXPORT(void) init#modulename#(void) {\n\\tint i;\n\\tPyObject *m,*d, *s;\n\\tm = #modulename#_module = Py_InitModule(\\\"#modulename#\\\", f2py_module_methods);\n\\tPyFortran_Type.ob_type = &PyType_Type;\n\\timport_array();\n\\tif (PyErr_Occurred())\n\\t\\tPy_FatalError(\\\"can't initialize module #modulename# (failed to import numpy)\\\");\n\\td = PyModule_GetDict(m);\n\\ts = PyString_FromString(\\\"$R\"\"\"+\"\"\"evision: $\\\");\n\\tPyDict_SetItemString(d, \\\"__version__\\\", s);\n\\ts = PyString_FromString(\\\"This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\\\\nFunctions:\\\\n\\\"\\n#docs#\\\".\\\");\n\\tPyDict_SetItemString(d, \\\"__doc__\\\", s);\n\\t#modulename#_error = PyErr_NewException (\\\"#modulename#.error\\\", NULL, NULL);\n\\tPy_DECREF(s);\n\\tfor(i=0;f2py_routine_defs[i].name!=NULL;i++)\n\\t\\tPyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i]));\n#initf2pywraphooks#\n#initf90modhooks#\n#initcommonhooks#\n#interface_usercode#\n\\tif (PyErr_Occurred())\n\\t\\tPy_FatalError(\\\"can't initialize module #modulename#\\\");\n\n#ifdef F2PY_REPORT_ATEXIT\n\\ton_exit(f2py_report_on_exit,(void*)\\\"#modulename#\\\");\n#endif\n\n}\n#ifdef __cplusplus\n}\n#endif\n\"\"\",\n 'separatorsfor':{'latexdoc':'\\n\\n',\n 'restdoc':'\\n\\n'},\n 'latexdoc':['\\\\section{Module \\\\texttt{#texmodulename#}}\\n',\n '#modnote#\\n',\n '#latexdoc#'],\n 'restdoc':['Module #modulename#\\n'+'='*80,\n '\\n#restdoc#']\n }\n\ndefmod_rules=[\n {'body':'/*eof body*/',\n 'method':'/*eof method*/',\n 'externroutines':'/*eof externroutines*/',\n 'routine_defs':'/*eof routine_defs*/',\n 'initf90modhooks':'/*eof initf90modhooks*/',\n 'initf2pywraphooks':'/*eof initf2pywraphooks*/',\n 'initcommonhooks':'/*eof initcommonhooks*/',\n 'latexdoc':'',\n 'restdoc':'',\n 'modnote':{hasnote:'#note#',l_not(hasnote):''},\n }\n ]\n\nroutine_rules={\n 'separatorsfor':sepdict,\n 'body':\"\"\"\n#begintitle#\nstatic char doc_#apiname#[] = \\\"\\\\\\nFunction signature:\\\\n\\\\\\n\\t#docreturn##name#(#docsignatureshort#)\\\\n\\\\\\n#docstrsigns#\\\";\n/* #declfortranroutine# */\nstatic PyObject *#apiname#(const PyObject *capi_self,\n PyObject *capi_args,\n PyObject *capi_keywds,\n #functype# (*f2py_func)(#callprotoargument#)) {\n\\tPyObject * volatile capi_buildvalue = NULL;\n\\tvolatile int f2py_success = 1;\n#decl#\n\\tstatic char *capi_kwlist[] = {#kwlist##kwlistopt##kwlistxa#NULL};\n#usercode#\n#routdebugenter#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_clock();\n#endif\n\\tif (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\\\\\n\\t\\t\\\"#argformat#|#keyformat##xaformat#:#pyname#\\\",\\\\\n\\t\\tcapi_kwlist#args_capi##keys_capi##keys_xa#))\\n\\t\\treturn NULL;\n#frompyobj#\n/*end of frompyobj*/\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_call_clock();\n#endif\n#callfortranroutine#\nif (PyErr_Occurred())\n f2py_success = 0;\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_call_clock();\n#endif\n/*end of callfortranroutine*/\n\\t\\tif (f2py_success) {\n#pyobjfrom#\n/*end of pyobjfrom*/\n\\t\\tCFUNCSMESS(\\\"Building return value.\\\\n\\\");\n\\t\\tcapi_buildvalue = Py_BuildValue(\\\"#returnformat#\\\"#return#);\n/*closepyobjfrom*/\n#closepyobjfrom#\n\\t\\t} /*if (f2py_success) after callfortranroutine*/\n/*cleanupfrompyobj*/\n#cleanupfrompyobj#\n\\tif (capi_buildvalue == NULL) {\n#routdebugfailure#\n\\t} else {\n#routdebugleave#\n\\t}\n\\tCFUNCSMESS(\\\"Freeing memory.\\\\n\\\");\n#freemem#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_clock();\n#endif\n\\treturn capi_buildvalue;\n}\n#endtitle#\n\"\"\",\n 'routine_defs':'#routine_def#',\n 'initf2pywraphooks':'#initf2pywraphook#',\n 'externroutines':'#declfortranroutine#',\n 'doc':'#docreturn##name#(#docsignature#)',\n 'docshort':'#docreturn##name#(#docsignatureshort#)',\n 'docs':'\"\\t#docreturn##name#(#docsignature#)\\\\n\"\\n',\n 'need':['arrayobject.h','CFUNCSMESS','MINMAX'],\n 'cppmacros':{debugcapi:'#define DEBUGCFUNCS'},\n 'latexdoc':['\\\\subsection{Wrapper function \\\\texttt{#texname#}}\\n',\n \"\"\"\n\\\\noindent{{}\\\\verb@#docreturn##name#@{}}\\\\texttt{(#latexdocsignatureshort#)}\n#routnote#\n\n#latexdocstrsigns#\n\"\"\"],\n 'restdoc':['Wrapped function ``#name#``\\n'+'-'*80,\n \n ]\n }\n\n################## Rules for C/API function ##############\n\nrout_rules=[\n { # Init\n 'separatorsfor': {'callfortranroutine':'\\n','routdebugenter':'\\n','decl':'\\n',\n 'routdebugleave':'\\n','routdebugfailure':'\\n',\n 'setjmpbuf':' || ',\n 'docstrreq':'\\n','docstropt':'\\n','docstrout':'\\n',\n 'docstrcbs':'\\n','docstrsigns':'\\\\n\"\\n\"',\n 'latexdocstrsigns':'\\n',\n 'latexdocstrreq':'\\n','latexdocstropt':'\\n',\n 'latexdocstrout':'\\n','latexdocstrcbs':'\\n',\n },\n 'kwlist':'','kwlistopt':'','callfortran':'','callfortranappend':'',\n 'docsign':'','docsignopt':'','decl':'/*decl*/',\n 'freemem':'/*freemem*/',\n 'docsignshort':'','docsignoptshort':'',\n 'docstrsigns':'','latexdocstrsigns':'',\n 'docstrreq':'Required arguments:',\n 'docstropt':'Optional arguments:',\n 'docstrout':'Return objects:',\n 'docstrcbs':'Call-back functions:',\n 'latexdocstrreq':'\\\\noindent Required arguments:',\n 'latexdocstropt':'\\\\noindent Optional arguments:',\n 'latexdocstrout':'\\\\noindent Return objects:',\n 'latexdocstrcbs':'\\\\noindent Call-back functions:',\n 'args_capi':'','keys_capi':'','functype':'',\n 'frompyobj':'/*frompyobj*/',\n 'cleanupfrompyobj':['/*end of cleanupfrompyobj*/'], #this list will be reversed\n 'pyobjfrom':'/*pyobjfrom*/',\n 'closepyobjfrom':['/*end of closepyobjfrom*/'], #this list will be reversed\n 'topyarr':'/*topyarr*/','routdebugleave':'/*routdebugleave*/',\n 'routdebugenter':'/*routdebugenter*/',\n 'routdebugfailure':'/*routdebugfailure*/',\n 'callfortranroutine':'/*callfortranroutine*/',\n 'argformat':'','keyformat':'','need_cfuncs':'',\n 'docreturn':'','return':'','returnformat':'','rformat':'',\n 'kwlistxa':'','keys_xa':'','xaformat':'','docsignxa':'','docsignxashort':'',\n 'initf2pywraphook':'',\n 'routnote':{hasnote:'--- #note#',l_not(hasnote):''},\n },{\n 'apiname':'f2py_rout_#modulename#_#name#',\n 'pyname':'#modulename#.#name#',\n 'decl':'',\n '_check':l_not(ismoduleroutine)\n },{\n 'apiname':'f2py_rout_#modulename#_#f90modulename#_#name#',\n 'pyname':'#modulename#.#f90modulename#.#name#',\n 'decl':'',\n '_check':ismoduleroutine\n },{ # Subroutine\n 'functype':'void',\n 'declfortranroutine':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'extern void #fortranname#(#callprotoargument#);',\n ismoduleroutine:'',\n isdummyroutine:''\n },\n 'routine_def':{l_not(l_or(ismoduleroutine,isintent_c,isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isdummyroutine):'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'need':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'F_FUNC'},\n 'callfortranroutine':[\n {debugcapi:[\"\"\"\\tfprintf(stderr,\\\"debug-capi:Fortran subroutine `#fortranname#(#callfortran#)\\'\\\\n\\\");\"\"\"]},\n {hasexternals:\"\"\"\\\n\\t\\tif (#setjmpbuf#) {\n\\t\\t\\tf2py_success = 0;\n\\t\\t} else {\"\"\"},\n {isthreadsafe:'\\t\\t\\tPy_BEGIN_ALLOW_THREADS'},\n {hascallstatement:'''\\t\\t\\t\\t#callstatement#;\n\\t\\t\\t\\t/*(*f2py_func)(#callfortran#);*/'''},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t\\t\\t\\t(*f2py_func)(#callfortran#);'},\n {isthreadsafe:'\\t\\t\\tPy_END_ALLOW_THREADS'},\n {hasexternals:\"\"\"\\t\\t}\"\"\"}\n ],\n '_check':issubroutine,\n },{ # Wrapped function\n 'functype':'void',\n 'declfortranroutine':{l_not(l_or(ismoduleroutine,isdummyroutine)):'extern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);',\n isdummyroutine:'',\n },\n\n 'routine_def':{l_not(l_or(ismoduleroutine,isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_WRAPPEDFUNC#(#name_lower#,#NAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n isdummyroutine:'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'initf2pywraphook':{l_not(l_or(ismoduleroutine,isdummyroutine)):'''\n {\n extern #ctype# #F_FUNC#(#name_lower#,#NAME#)(void);\n PyObject* o = PyDict_GetItemString(d,\"#name#\");\n PyObject_SetAttrString(o,\"_cpointer\", PyCObject_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL));\n }\n '''},\n 'need':{l_not(l_or(ismoduleroutine,isdummyroutine)):['F_WRAPPEDFUNC','F_FUNC']},\n 'callfortranroutine':[\n {debugcapi:[\"\"\"\\tfprintf(stderr,\\\"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)\\'\\\\n\\\");\"\"\"]},\n {hasexternals:\"\"\"\\\n\\tif (#setjmpbuf#) {\n\\t\\tf2py_success = 0;\n\\t} else {\"\"\"},\n {isthreadsafe:'\\tPy_BEGIN_ALLOW_THREADS'},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t(*f2py_func)(#callfortran#);'},\n {hascallstatement:'\\t#callstatement#;\\n\\t/*(*f2py_func)(#callfortran#);*/'},\n {isthreadsafe:'\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t}'}\n ],\n '_check':isfunction_wrap,\n },{ # Function\n 'functype':'#ctype#',\n 'docreturn':{l_not(isintent_hide):'#rname#,'},\n 'docstrout':'\\t#pydocsignout#',\n 'latexdocstrout':['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {hasresultnote:'--- #resultnote#'}],\n 'callfortranroutine':[{l_and(debugcapi,isstringfunction):\"\"\"\\\n#ifdef USESCOMPAQFORTRAN\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callcompaqfortran#)\\\\n\\\");\n#else\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\\\n\\\");\n#endif\n\"\"\"},\n {l_and(debugcapi,l_not(isstringfunction)):\"\"\"\\\n\\tfprintf(stderr,\\\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\\\n\\\");\n\"\"\"}\n ],\n '_check':l_and(isfunction,l_not(isfunction_wrap))\n },{ # Scalar function\n 'declfortranroutine':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'extern #ctype# #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'extern #ctype# #fortranname#(#callprotoargument#);',\n isdummyroutine:''\n },\n 'routine_def':{l_and(l_not(l_or(ismoduleroutine,isintent_c)),l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c,l_not(isdummyroutine)):'\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},',\n isdummyroutine:'\\t{\\\"#name#\\\",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},',\n },\n 'decl':[{iscomplexfunction_warn:'\\t#ctype# #name#_return_value={0,0};',\n l_not(iscomplexfunction):'\\t#ctype# #name#_return_value=0;'},\n {iscomplexfunction:'\\tPyObject *#name#_return_value_capi = Py_None;'}\n ],\n 'callfortranroutine':[\n {hasexternals:\"\"\"\\\n\\tif (#setjmpbuf#) {\n\\t\\tf2py_success = 0;\n\\t} else {\"\"\"},\n {isthreadsafe:'\\tPy_BEGIN_ALLOW_THREADS'},\n {hascallstatement:'''\\t#callstatement#;\n/*\\t#name#_return_value = (*f2py_func)(#callfortran#);*/\n'''},\n {l_not(l_or(hascallstatement,isdummyroutine)):'\\t#name#_return_value = (*f2py_func)(#callfortran#);'},\n {isthreadsafe:'\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t}'},\n {l_and(debugcapi,iscomplexfunction):'\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value.r,#name#_return_value.i);'},\n {l_and(debugcapi,l_not(iscomplexfunction)):'\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value);'}],\n 'pyobjfrom':{iscomplexfunction:'\\t#name#_return_value_capi = pyobj_from_#ctype#1(#name#_return_value);'},\n 'need':[{l_not(isdummyroutine):'F_FUNC'},\n {iscomplexfunction:'pyobj_from_#ctype#1'},\n {islong_longfunction:'long_long'},\n {islong_doublefunction:'long_double'}],\n 'returnformat':{l_not(isintent_hide):'#rformat#'},\n 'return':{iscomplexfunction:',#name#_return_value_capi',\n l_not(l_or(iscomplexfunction,isintent_hide)):',#name#_return_value'},\n '_check':l_and(isfunction,l_not(isstringfunction),l_not(isfunction_wrap))\n },{ # String function # in use for --no-wrap\n 'declfortranroutine':'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',\n 'routine_def':{l_not(l_or(ismoduleroutine,isintent_c)):\n# '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)F_FUNC(#fortranname#,#FORTRANNAME#),(void *)#apiname#,doc_#apiname#},',\n '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',\n l_and(l_not(ismoduleroutine),isintent_c):\n# '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(void *)#apiname#,doc_#apiname#},'\n '\\t{\\\"#name#\\\",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},'\n },\n 'decl':['\\t#ctype# #name#_return_value = NULL;',\n '\\tint #name#_return_value_len = 0;'],\n 'callfortran':'#name#_return_value,#name#_return_value_len,',\n 'callfortranroutine':['\\t#name#_return_value_len = #rlength#;',\n '\\tif ((#name#_return_value = (string)malloc(sizeof(char)*(#name#_return_value_len+1))) == NULL) {',\n '\\t\\tPyErr_SetString(PyExc_MemoryError, \\\"out of memory\\\");',\n '\\t\\tf2py_success = 0;',\n '\\t} else {',\n \"\\t\\t(#name#_return_value)[#name#_return_value_len] = '\\\\0';\",\n '\\t}',\n '\\tif (f2py_success) {',\n {hasexternals:\"\"\"\\\n\\t\\tif (#setjmpbuf#) {\n\\t\\t\\tf2py_success = 0;\n\\t\\t} else {\"\"\"},\n {isthreadsafe:'\\t\\tPy_BEGIN_ALLOW_THREADS'},\n \"\"\"\\\n#ifdef USESCOMPAQFORTRAN\n\\t\\t(*f2py_func)(#callcompaqfortran#);\n#else\n\\t\\t(*f2py_func)(#callfortran#);\n#endif\n\"\"\",\n {isthreadsafe:'\\t\\tPy_END_ALLOW_THREADS'},\n {hasexternals:'\\t\\t}'},\n {debugcapi:'\\t\\tfprintf(stderr,\"#routdebugshowvalue#\\\\n\",#name#_return_value_len,#name#_return_value);'},\n '\\t} /* if (f2py_success) after (string)malloc */',\n ],\n 'returnformat':'#rformat#',\n 'return':',#name#_return_value',\n 'freemem':'\\tSTRINGFREE(#name#_return_value);',\n 'need':['F_FUNC','#ctype#','STRINGFREE'],\n '_check':l_and(isstringfunction,l_not(isfunction_wrap)) # ???obsolete\n },\n { # Debugging\n 'routdebugenter':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#(#docsignature#)\\\\n\");',\n 'routdebugleave':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#: successful.\\\\n\");',\n 'routdebugfailure':'\\tfprintf(stderr,\"debug-capi:Python C/API function #modulename#.#name#: failure.\\\\n\");',\n '_check':debugcapi\n }\n ]\n\n################ Rules for arguments ##################\n\ntypedef_need_dict = {islong_long:'long_long',\n islong_double:'long_double',\n islong_complex:'complex_long_double',\n isunsigned_char:'unsigned_char',\n isunsigned_short:'unsigned_short',\n isunsigned:'unsigned',\n isunsigned_long_long:'unsigned_long_long'}\n\naux_rules=[\n {\n 'separatorsfor':sepdict\n },\n { # Common\n 'frompyobj':['\\t/* Processing auxiliary variable #varname# */',\n {debugcapi:'\\tfprintf(stderr,\"#vardebuginfo#\\\\n\");'},],\n 'cleanupfrompyobj':'\\t/* End of cleaning variable #varname# */',\n 'need':typedef_need_dict,\n },\n# Scalars (not complex)\n { # Common\n 'decl':'\\t#ctype# #varname# = 0;',\n 'need':{hasinitvalue:'math.h'},\n 'frompyobj':{hasinitvalue:'\\t#varname# = #init#;'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n },\n {\n 'return':',#varname#',\n 'docstrout':'\\t#pydocsignout#',\n 'docreturn':'#outvarname#,',\n 'returnformat':'#varrformat#',\n '_check':l_and(isscalar,l_not(iscomplex),isintent_out),\n },\n# Complex scalars\n { # Common\n 'decl':'\\t#ctype# #varname#;',\n 'frompyobj': {hasinitvalue:'\\t#varname#.r = #init.r#, #varname#.i = #init.i#;'},\n '_check':iscomplex\n },\n# String\n { # Common\n 'decl':['\\t#ctype# #varname# = NULL;',\n '\\tint slen(#varname#);',\n ],\n 'need':['len..'],\n '_check':isstring\n },\n# Array\n { # Common\n 'decl':['\\t#ctype# *#varname# = NULL;',\n '\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n '\\tconst int #varname#_Rank = #rank#;',\n ],\n 'need':['len..',{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}],\n '_check':isarray\n },\n# Scalararray\n { # Common\n '_check':l_and(isarray,l_not(iscomplexarray))\n },{ # Not hidden\n '_check':l_and(isarray,l_not(iscomplexarray),isintent_nothide)\n },\n# Integer*1 array\n {'need':'#ctype#',\n '_check':isint1array,\n '_depend':''\n },\n# Integer*-1 array\n {'need':'#ctype#',\n '_check':isunsigned_chararray,\n '_depend':''\n },\n# Integer*-2 array\n {'need':'#ctype#',\n '_check':isunsigned_shortarray,\n '_depend':''\n },\n# Integer*-8 array\n {'need':'#ctype#',\n '_check':isunsigned_long_longarray,\n '_depend':''\n },\n# Complexarray\n {'need':'#ctype#',\n '_check':iscomplexarray,\n '_depend':''\n },\n# Stringarray\n {\n 'callfortranappend':{isarrayofstrings:'flen(#varname#),'},\n 'need':'string',\n '_check':isstringarray\n }\n ]\n\narg_rules=[\n {\n 'separatorsfor':sepdict\n },\n { # Common\n 'frompyobj':['\\t/* Processing variable #varname# */',\n {debugcapi:'\\tfprintf(stderr,\"#vardebuginfo#\\\\n\");'},],\n 'cleanupfrompyobj':'\\t/* End of cleaning variable #varname# */',\n '_depend':'',\n 'need':typedef_need_dict,\n },\n# Doc signatures\n {\n 'docstropt':{l_and(isoptional,isintent_nothide):'\\t#pydocsign#'},\n 'docstrreq':{l_and(isrequired,isintent_nothide):'\\t#pydocsign#'},\n 'docstrout':{isintent_out:'\\t#pydocsignout#'},\n 'latexdocstropt':{l_and(isoptional,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrreq':{l_and(isrequired,isintent_nothide):['\\\\item[]{{}\\\\verb@#pydocsign#@{}}',\n {hasnote:'--- #note#'}]},\n 'latexdocstrout':{isintent_out:['\\\\item[]{{}\\\\verb@#pydocsignout#@{}}',\n {l_and(hasnote,isintent_hide):'--- #note#',\n l_and(hasnote,isintent_nothide):'--- See above.'}]},\n 'depend':''\n },\n# Required/Optional arguments\n {\n 'kwlist':'\"#varname#\",',\n 'docsign':'#varname#,',\n '_check':l_and(isintent_nothide,l_not(isoptional))\n },\n {\n 'kwlistopt':'\"#varname#\",',\n 'docsignopt':'#varname#=#showinit#,',\n 'docsignoptshort':'#varname#,',\n '_check':l_and(isintent_nothide,isoptional)\n },\n# Docstring/BuildValue\n {\n 'docreturn':'#outvarname#,',\n 'returnformat':'#varrformat#',\n '_check':isintent_out\n },\n# Externals (call-back functions)\n { # Common\n 'docsignxa':{isintent_nothide:'#varname#_extra_args=(),'},\n 'docsignxashort':{isintent_nothide:'#varname#_extra_args,'},\n 'docstropt':{isintent_nothide:'\\t#varname#_extra_args := () input tuple'},\n 'docstrcbs':'#cbdocstr#',\n 'latexdocstrcbs':'\\\\item[] #cblatexdocstr#',\n 'latexdocstropt':{isintent_nothide:'\\\\item[]{{}\\\\verb@#varname#_extra_args := () input tuple@{}} --- Extra arguments for call-back function {{}\\\\verb@#varname#@{}}.'},\n 'decl':['\\tPyObject *#varname#_capi = Py_None;',\n '\\tPyTupleObject *#varname#_xa_capi = NULL;',\n '\\tPyTupleObject *#varname#_args_capi = NULL;',\n '\\tint #varname#_nofargs_capi = 0;',\n {l_not(isintent_callback):'\\t#cbname#_typedef #varname#_cptr;'}\n ],\n 'kwlistxa':{isintent_nothide:'\"#varname#_extra_args\",'},\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'xaformat':{isintent_nothide:'O!'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'keys_xa':',&PyTuple_Type,&#varname#_xa_capi',\n 'setjmpbuf':'(setjmp(#cbname#_jmpbuf))',\n 'callfortran':{l_not(isintent_callback):'#varname#_cptr,'},\n 'need':['#cbname#','setjmp.h'],\n '_check':isexternal\n },\n {\n 'frompyobj':[{l_not(isintent_callback):\"\"\"\\\nif(PyCObject_Check(#varname#_capi)) {\n #varname#_cptr = PyCObject_AsVoidPtr(#varname#_capi);\n} else {\n #varname#_cptr = #cbname#;\n}\n\"\"\"},{isintent_callback:\"\"\"\\\nif (#varname#_capi==Py_None) {\n #varname#_capi = PyObject_GetAttrString(#modulename#_module,\\\"#varname#\\\");\n if (#varname#_capi) {\n if (#varname#_xa_capi==NULL) {\n if (PyObject_HasAttrString(#modulename#_module,\\\"#varname#_extra_args\\\")) {\n PyObject* capi_tmp = PyObject_GetAttrString(#modulename#_module,\\\"#varname#_extra_args\\\");\n if (capi_tmp)\n #varname#_xa_capi = (PyTupleObject *)PySequence_Tuple(capi_tmp);\n else\n #varname#_xa_capi = (PyTupleObject *)Py_BuildValue(\\\"()\\\");\n if (#varname#_xa_capi==NULL) {\n PyErr_SetString(#modulename#_error,\\\"Failed to convert #modulename#.#varname#_extra_args to tuple.\\\\n\\\");\n return NULL;\n }\n }\n }\n }\n if (#varname#_capi==NULL) {\n PyErr_SetString(#modulename#_error,\\\"Callback #varname# not defined (as an argument or module #modulename# attribute).\\\\n\\\");\n return NULL;\n }\n}\n\"\"\"},\n## {l_not(isintent_callback):\"\"\"\\\n## if (#varname#_capi==Py_None) {\n## printf(\\\"hoi\\\\n\\\");\n## }\n## \"\"\"},\n\"\"\"\\\n\\t#varname#_nofargs_capi = #cbname#_nofargs;\n\\tif (create_cb_arglist(#varname#_capi,#varname#_xa_capi,#maxnofargs#,#nofoptargs#,&#cbname#_nofargs,&#varname#_args_capi,\\\"failed in processing argument list for call-back #varname#.\\\")) {\n\\t\\tjmp_buf #varname#_jmpbuf;\"\"\",\n{debugcapi:[\"\"\"\\\n\\t\\tfprintf(stderr,\\\"debug-capi:Assuming %d arguments; at most #maxnofargs#(-#nofoptargs#) is expected.\\\\n\\\",#cbname#_nofargs);\n\\t\\tCFUNCSMESSPY(\\\"for #varname#=\\\",#cbname#_capi);\"\"\",\n{l_not(isintent_callback):\"\"\"\\t\\tfprintf(stderr,\\\"#vardebugshowvalue# (call-back in C).\\\\n\\\",#cbname#);\"\"\"}]},\n \"\"\"\\\n\\t\\tCFUNCSMESS(\\\"Saving jmpbuf for `#varname#`.\\\\n\\\");\n\\t\\tSWAP(#varname#_capi,#cbname#_capi,PyObject);\n\\t\\tSWAP(#varname#_args_capi,#cbname#_args_capi,PyTupleObject);\n\\t\\tmemcpy(&#varname#_jmpbuf,&#cbname#_jmpbuf,sizeof(jmp_buf));\"\"\",\n ],\n'cleanupfrompyobj':\n\"\"\"\\\n\\t\\tCFUNCSMESS(\\\"Restoring jmpbuf for `#varname#`.\\\\n\\\");\n\\t\\t#cbname#_capi = #varname#_capi;\n\\t\\tPy_DECREF(#cbname#_args_capi);\n\\t\\t#cbname#_args_capi = #varname#_args_capi;\n\\t\\t#cbname#_nofargs = #varname#_nofargs_capi;\n\\t\\tmemcpy(&#cbname#_jmpbuf,&#varname#_jmpbuf,sizeof(jmp_buf));\n\\t}\"\"\",\n 'need':['SWAP','create_cb_arglist'],\n '_check':isexternal,\n '_depend':''\n },\n# Scalars (not complex)\n { # Common\n 'decl':'\\t#ctype# #varname# = 0;',\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#);'},\n 'callfortran':{isintent_c:'#varname#,',l_not(isintent_c):'&#varname#,'},\n 'return':{isintent_out:',#varname#'},\n '_check':l_and(isscalar,l_not(iscomplex))\n },{\n 'need':{hasinitvalue:'math.h'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n #'_depend':''\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'pyobjfrom':{isintent_inout:\"\"\"\\\n\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);\n\\tif (f2py_success) {\"\"\"},\n 'closepyobjfrom':{isintent_inout:\"\\t} /*if (f2py_success) of #varname# pyobjfrom*/\"},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n '_check':l_and(isscalar,l_not(iscomplex),isintent_nothide)\n },{\n 'frompyobj':[\n# hasinitvalue...\n# if pyobj is None:\n# varname = init\n# else\n# from_pyobj(varname)\n# \n# isoptional and noinitvalue...\n# if pyobj is not None:\n# from_pyobj(varname)\n# else:\n# varname is uninitialized\n#\n# ...\n# from_pyobj(varname)\n#\n {hasinitvalue:'\\tif (#varname#_capi == Py_None) #varname# = #init#; else',\n '_depend':''},\n {l_and(isoptional,l_not(hasinitvalue)):'\\tif (#varname#_capi != Py_None)',\n '_depend':''}, \n {l_not(islogical):'''\\\n\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#pyname#() #nth# (#varname#) can\\'t be converted to #ctype#\");\n\\tif (f2py_success) {'''},\n {islogical:'''\\\n\\t\\t#varname# = (#ctype#)PyObject_IsTrue(#varname#_capi);\n\\t\\tf2py_success = 1;\n\\tif (f2py_success) {'''},\n ],\n 'cleanupfrompyobj':'\\t} /*if (f2py_success) of #varname#*/',\n 'need':{l_not(islogical):'#ctype#_from_pyobj'},\n '_check':l_and(isscalar,l_not(iscomplex),isintent_nothide),\n '_depend':''\n# },{ # Hidden\n# '_check':l_and(isscalar,l_not(iscomplex),isintent_hide)\n },{ # Hidden\n 'frompyobj':{hasinitvalue:'\\t#varname# = #init#;'},\n 'need':typedef_need_dict,\n '_check':l_and(isscalar,l_not(iscomplex),isintent_hide),\n '_depend':''\n },{ # Common\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#);'},\n '_check':l_and(isscalar,l_not(iscomplex)),\n '_depend':''\n },\n# Complex scalars\n { # Common\n 'decl':'\\t#ctype# #varname#;',\n 'callfortran':{isintent_c:'#varname#,',l_not(isintent_c):'&#varname#,'},\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#.r,#varname#.i);'},\n 'return':{isintent_out:',#varname#_capi'},\n '_check':iscomplex\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n 'pyobjfrom':{isintent_inout:\"\"\"\\\n\\t\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);\n\\t\\tif (f2py_success) {\"\"\"},\n 'closepyobjfrom':{isintent_inout:\"\\t\\t} /*if (f2py_success) of #varname# pyobjfrom*/\"},\n '_check':l_and(iscomplex,isintent_nothide)\n },{\n 'frompyobj':[{hasinitvalue:'\\tif (#varname#_capi==Py_None) {#varname#.r = #init.r#, #varname#.i = #init.i#;} else'},\n {l_and(isoptional,l_not(hasinitvalue)):'\\tif (#varname#_capi != Py_None)'},\n# '\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#ctype#_from_pyobj failed in converting #nth# `#varname#\\' of #pyname# to C #ctype#\\\\n\");'\n '\\t\\tf2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,\"#pyname#() #nth# (#varname#) can\\'t be converted to #ctype#\");'\n '\\n\\tif (f2py_success) {'],\n 'cleanupfrompyobj':'\\t} /*if (f2py_success) of #varname# frompyobj*/',\n 'need':['#ctype#_from_pyobj'],\n '_check':l_and(iscomplex,isintent_nothide),\n '_depend':''\n },{ # Hidden\n 'decl':{isintent_out:'\\tPyObject *#varname#_capi = Py_None;'},\n '_check':l_and(iscomplex,isintent_hide)\n },{\n 'frompyobj': {hasinitvalue:'\\t#varname#.r = #init.r#, #varname#.i = #init.i#;'},\n '_check':l_and(iscomplex,isintent_hide),\n '_depend':''\n },{ # Common\n 'pyobjfrom':{isintent_out:'\\t#varname#_capi = pyobj_from_#ctype#1(#varname#);'},\n 'need':['pyobj_from_#ctype#1'],\n '_check':iscomplex\n },{\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",#varname#.r,#varname#.i);'},\n '_check':iscomplex,\n '_depend':''\n },\n# String\n { # Common\n 'decl':['\\t#ctype# #varname# = NULL;',\n '\\tint slen(#varname#);',\n '\\tPyObject *#varname#_capi = Py_None;'],\n 'callfortran':'#varname#,',\n 'callfortranappend':'slen(#varname#),',\n 'pyobjfrom':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",slen(#varname#),#varname#);'},\n# 'freemem':'\\tSTRINGFREE(#varname#);',\n 'return':{isintent_out:',#varname#'},\n 'need':['len..'],#'STRINGFREE'],\n '_check':isstring\n },{ # Common\n 'frompyobj':\"\"\"\\\n\\tslen(#varname#) = #length#;\n\\tf2py_success = #ctype#_from_pyobj(&#varname#,&slen(#varname#),#init#,#varname#_capi,\\\"#ctype#_from_pyobj failed in converting #nth# `#varname#\\' of #pyname# to C #ctype#\\\");\n\\tif (f2py_success) {\"\"\",\n 'cleanupfrompyobj':\"\"\"\\\n\\t\\tSTRINGFREE(#varname#);\n\\t} /*if (f2py_success) of #varname#*/\"\"\",\n 'need':['#ctype#_from_pyobj','len..','STRINGFREE'],\n '_check':isstring,\n '_depend':''\n },{ # Not hidden\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n 'pyobjfrom':{isintent_inout:'''\\\n\\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,#varname#);\n\\tif (f2py_success) {'''},\n 'closepyobjfrom':{isintent_inout:'\\t} /*if (f2py_success) of #varname# pyobjfrom*/'},\n 'need':{isintent_inout:'try_pyarr_from_#ctype#'},\n '_check':l_and(isstring,isintent_nothide)\n },{ # Hidden\n '_check':l_and(isstring,isintent_hide)\n },{\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\"#vardebugshowvalue#\\\\n\",slen(#varname#),#varname#);'},\n '_check':isstring,\n '_depend':''\n },\n# Array\n { # Common\n 'decl':['\\t#ctype# *#varname# = NULL;',\n '\\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};',\n '\\tconst int #varname#_Rank = #rank#;',\n '\\tPyArrayObject *capi_#varname#_tmp = NULL;',\n '\\tint capi_#varname#_intent = 0;',\n ],\n 'callfortran':'#varname#,',\n 'return':{isintent_out:',capi_#varname#_tmp'},\n 'need':'len..',\n '_check':isarray\n },{ # intent(overwrite) array\n 'decl':'\\tint capi_overwrite_#varname# = 1;',\n 'kwlistxa':'\"overwrite_#varname#\",',\n 'xaformat':'i',\n 'keys_xa':',&capi_overwrite_#varname#',\n 'docsignxa':'overwrite_#varname#=1,',\n 'docsignxashort':'overwrite_#varname#,',\n 'docstropt':'\\toverwrite_#varname# := 1 input int',\n '_check':l_and(isarray,isintent_overwrite),\n },{\n 'frompyobj':'\\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',\n '_check':l_and(isarray,isintent_overwrite),\n '_depend':'',\n },\n { # intent(copy) array\n 'decl':'\\tint capi_overwrite_#varname# = 0;',\n 'kwlistxa':'\"overwrite_#varname#\",',\n 'xaformat':'i',\n 'keys_xa':',&capi_overwrite_#varname#',\n 'docsignxa':'overwrite_#varname#=0,',\n 'docsignxashort':'overwrite_#varname#,',\n 'docstropt':'\\toverwrite_#varname# := 0 input int',\n '_check':l_and(isarray,isintent_copy),\n },{\n 'frompyobj':'\\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',\n '_check':l_and(isarray,isintent_copy),\n '_depend':'',\n },{ \n 'need':[{hasinitvalue:'forcomb'},{hasinitvalue:'CFUNCSMESS'}],\n '_check':isarray,\n '_depend':''\n },{ # Not hidden\n 'decl':'\\tPyObject *#varname#_capi = Py_None;',\n 'argformat':{isrequired:'O'},\n 'keyformat':{isoptional:'O'},\n 'args_capi':{isrequired:',&#varname#_capi'},\n 'keys_capi':{isoptional:',&#varname#_capi'},\n# 'pyobjfrom':{isintent_inout:\"\"\"\\\n# /* Partly because of the following hack, intent(inout) is depreciated,\n# Use intent(in,out) instead.\n \n# \\tif ((#varname#_capi != Py_None) && PyArray_Check(#varname#_capi) \\\\\n# \\t\\t&& (#varname#_capi != (PyObject *)capi_#varname#_tmp)) {\n# \\t\\tif (((PyArrayObject *)#varname#_capi)->nd != capi_#varname#_tmp->nd) {\n# \\t\\t\\tif (#varname#_capi != capi_#varname#_tmp->base)\n# \\t\\t\\t\\tcopy_ND_array((PyArrayObject *)capi_#varname#_tmp->base,(PyArrayObject *)#varname#_capi);\n# \\t\\t} else\n# \\t\\t\\tcopy_ND_array(capi_#varname#_tmp,(PyArrayObject *)#varname#_capi);\n# \\t}\n# */\n# \"\"\"},\n# 'need':{isintent_inout:'copy_ND_array'},\n '_check':l_and(isarray,isintent_nothide)\n },{\n 'frompyobj':['\\t#setdims#;',\n '\\tcapi_#varname#_intent |= #intent#;',\n {isintent_hide:'\\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,Py_None);'},\n {isintent_nothide:'\\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'},\n \"\"\"\\\n\\tif (capi_#varname#_tmp == NULL) {\n\\t\\tif (!PyErr_Occurred())\n\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"failed in converting #nth# `#varname#\\' of #pyname# to C/Fortran array\\\" );\n\\t} else {\n\\t\\t#varname# = (#ctype# *)(capi_#varname#_tmp->data);\n\"\"\",\n{hasinitvalue:[\n {isintent_nothide:'\\tif (#varname#_capi == Py_None) {'},\n {isintent_hide:'\\t{'},\n {iscomplexarray:'\\t\\t#ctype# capi_c;'},\n \"\"\"\\\n\\t\\tint *_i,capi_i=0;\n\\t\\tCFUNCSMESS(\\\"#name#: Initializing #varname#=#init#\\\\n\\\");\n\\t\\tif (initforcomb(capi_#varname#_tmp->dimensions,capi_#varname#_tmp->nd,1)) {\n\\t\\t\\twhile ((_i = nextforcomb()))\n\\t\\t\\t\\t#varname#[capi_i++] = #init#; /* fortran way */\n\\t\\t} else {\n\\t\\t\\tif (!PyErr_Occurred())\n\\t\\t\\t\\tPyErr_SetString(#modulename#_error,\\\"Initialization of #nth# #varname# failed (initforcomb).\\\");\n\\t\\t\\tf2py_success = 0;\n\\t\\t}\n\\t}\n\\tif (f2py_success) {\"\"\"]},\n ],\n 'cleanupfrompyobj':[ # note that this list will be reversed\n '\\t} /*if (capi_#varname#_tmp == NULL) ... else of #varname#*/',\n {l_not(l_or(isintent_out,isintent_hide)):\"\"\"\\\n\\tif((PyObject *)capi_#varname#_tmp!=#varname#_capi) {\n\\t\\tPy_XDECREF(capi_#varname#_tmp); }\"\"\"},\n {l_and(isintent_hide,l_not(isintent_out)):\"\"\"\\t\\tPy_XDECREF(capi_#varname#_tmp);\"\"\"},\n {hasinitvalue:'\\t} /*if (f2py_success) of #varname# init*/'},\n ],\n '_check':isarray,\n '_depend':''\n },\n# { # Hidden\n# 'freemem':{l_not(isintent_out):'\\tPy_XDECREF(capi_#varname#_tmp);'},\n# '_check':l_and(isarray,isintent_hide)\n# },\n# Scalararray\n { # Common\n '_check':l_and(isarray,l_not(iscomplexarray))\n },{ # Not hidden\n '_check':l_and(isarray,l_not(iscomplexarray),isintent_nothide)\n },\n# Integer*1 array\n {'need':'#ctype#',\n '_check':isint1array,\n '_depend':''\n },\n# Integer*-1 array\n {'need':'#ctype#',\n '_check':isunsigned_chararray,\n '_depend':''\n },\n# Integer*-2 array\n {'need':'#ctype#',\n '_check':isunsigned_shortarray,\n '_depend':''\n },\n# Integer*-8 array\n {'need':'#ctype#',\n '_check':isunsigned_long_longarray,\n '_depend':''\n },\n# Complexarray\n {'need':'#ctype#',\n '_check':iscomplexarray,\n '_depend':''\n },\n# Stringarray\n {\n 'callfortranappend':{isarrayofstrings:'flen(#varname#),'},\n 'need':'string',\n '_check':isstringarray\n }\n ]\n\n################# Rules for checking ###############\n\ncheck_rules=[\n {\n 'frompyobj':{debugcapi:'\\tfprintf(stderr,\\\"debug-capi:Checking `#check#\\'\\\\n\\\");'},\n 'need':'len..'\n },{\n 'frompyobj':'\\tCHECKSCALAR(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\",\\\"#varshowvalue#\\\",#varname#) {',\n 'cleanupfrompyobj':'\\t} /*CHECKSCALAR(#check#)*/',\n 'need':'CHECKSCALAR',\n '_check':l_and(isscalar,l_not(iscomplex)),\n '_break':''\n },{\n 'frompyobj':'\\tCHECKSTRING(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\",\\\"#varshowvalue#\\\",#varname#) {',\n 'cleanupfrompyobj':'\\t} /*CHECKSTRING(#check#)*/',\n 'need':'CHECKSTRING',\n '_check':isstring,\n '_break':''\n },{\n 'need':'CHECKARRAY',\n 'frompyobj':'\\tCHECKARRAY(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\") {',\n 'cleanupfrompyobj':'\\t} /*CHECKARRAY(#check#)*/',\n '_check':isarray,\n '_break':''\n },{\n 'need':'CHECKGENERIC',\n 'frompyobj':'\\tCHECKGENERIC(#check#,\\\"#check#\\\",\\\"#nth# #varname#\\\") {',\n 'cleanupfrompyobj':'\\t} /*CHECKGENERIC(#check#)*/',\n }\n]\n\n########## Applying the rules. No need to modify what follows #############\n\n#################### Build C/API module #######################\n\ndef buildmodule(m,um):\n \"\"\"\n Return \n \"\"\"\n global f2py_version,options\n outmess('\\tBuilding module \"%s\"...\\n'%(m['name']))\n ret = {}\n mod_rules=defmod_rules[:]\n vrd=modsign2map(m)\n rd=dictappend({'f2py_version':f2py_version},vrd)\n funcwrappers = []\n funcwrappers2 = [] # F90 codes\n for n in m['interfaced']:\n nb=None\n for bi in m['body']:\n if not bi['block']=='interface':\n errmess('buildmodule: Expected interface block. Skipping.\\n')\n continue\n for b in bi['body']:\n if b['name']==n: nb=b;break\n \n if not nb:\n errmess('buildmodule: Could not found the body of interfaced routine \"%s\". Skipping.\\n'%(n))\n continue\n nb_list = [nb]\n if nb.has_key('entry'):\n for k,a in nb['entry'].items():\n nb1 = copy.deepcopy(nb)\n del nb1['entry']\n nb1['name'] = k\n nb1['args'] = a\n nb_list.append(nb1)\n for nb in nb_list:\n api,wrap=buildapi(nb)\n if wrap:\n if ismoduleroutine(nb):\n funcwrappers2.append(wrap)\n else:\n funcwrappers.append(wrap)\n ar=applyrules(api,vrd)\n rd=dictappend(rd,ar)\n\n # Construct COMMON block support\n cr,wrap = common_rules.buildhooks(m)\n if wrap:\n funcwrappers.append(wrap)\n ar=applyrules(cr,vrd)\n rd=dictappend(rd,ar)\n\n # Construct F90 module support\n mr,wrap = f90mod_rules.buildhooks(m)\n if wrap:\n funcwrappers2.append(wrap)\n ar=applyrules(mr,vrd)\n rd=dictappend(rd,ar)\n\n for u in um:\n ar=use_rules.buildusevars(u,m['use'][u['name']])\n rd=dictappend(rd,ar)\n\n needs=cfuncs.get_needs()\n code={}\n for n in needs.keys():\n code[n]=[]\n for k in needs[n]:\n c=''\n if cfuncs.includes0.has_key(k): c=cfuncs.includes0[k]\n elif cfuncs.includes.has_key(k): c=cfuncs.includes[k]\n elif cfuncs.userincludes.has_key(k): c=cfuncs.userincludes[k]\n elif cfuncs.typedefs.has_key(k): c=cfuncs.typedefs[k]\n elif cfuncs.typedefs_generated.has_key(k):\n c=cfuncs.typedefs_generated[k]\n elif cfuncs.cppmacros.has_key(k): c=cfuncs.cppmacros[k]\n elif cfuncs.cfuncs.has_key(k): c=cfuncs.cfuncs[k]\n elif cfuncs.callbacks.has_key(k): c=cfuncs.callbacks[k]\n elif cfuncs.f90modhooks.has_key(k): c=cfuncs.f90modhooks[k]\n elif cfuncs.commonhooks.has_key(k): c=cfuncs.commonhooks[k]\n else: errmess('buildmodule: unknown need %s.\\n'%(`k`));continue\n code[n].append(c)\n mod_rules.append(code)\n for r in mod_rules:\n if (r.has_key('_check') and r['_check'](m)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,m)\n rd=dictappend(rd,ar)\n ar=applyrules(module_rules,rd)\n\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.c')\n ret['csrc'] = fn\n f=open(fn,'w')\n f.write(string.replace(ar['modulebody'],'\\t',2*' '))\n f.close()\n outmess('\\tWrote C/API module \"%s\" to file \"%s/%smodule.c\"\\n'%(m['name'],options['buildpath'],vrd['modulename']))\n\n if options['dorestdoc']:\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.rest')\n f=open(fn,'w')\n f.write('.. -*- rest -*-\\n')\n f.write(string.join(ar['restdoc'],'\\n'))\n f.close()\n outmess('\\tReST Documentation is saved to file \"%s/%smodule.rest\"\\n'%(options['buildpath'],vrd['modulename']))\n if options['dolatexdoc']:\n fn = os.path.join(options['buildpath'],vrd['modulename']+'module.tex')\n ret['ltx'] = fn\n f=open(fn,'w')\n f.write('%% This file is auto-generated with f2py (version:%s)\\n'%(f2py_version))\n if not options.has_key('shortlatex'):\n f.write('\\\\documentclass{article}\\n\\\\usepackage{a4wide}\\n\\\\begin{document}\\n\\\\tableofcontents\\n\\n')\n f.write(string.join(ar['latexdoc'],'\\n'))\n if not options.has_key('shortlatex'):\n f.write('\\\\end{document}')\n f.close()\n outmess('\\tDocumentation is saved to file \"%s/%smodule.tex\"\\n'%(options['buildpath'],vrd['modulename']))\n if funcwrappers:\n wn = os.path.join(options['buildpath'],'%s-f2pywrappers.f'%(vrd['modulename']))\n ret['fsrc'] = wn\n f=open(wn,'w')\n f.write('C -*- fortran -*-\\n')\n f.write('C This file is autogenerated with f2py (version:%s)\\n'%(f2py_version))\n f.write('C It contains Fortran 77 wrappers to fortran functions.\\n')\n lines = []\n for l in string.split(string.join(funcwrappers,'\\n\\n')+'\\n','\\n'):\n if l and l[0]==' ':\n while len(l)>=66:\n lines.append(l[:66]+'\\n &')\n l = l[66:]\n lines.append(l+'\\n')\n else: lines.append(l+'\\n')\n lines = string.join(lines,'').replace('\\n &\\n','\\n')\n f.write(lines)\n f.close()\n outmess('\\tFortran 77 wrappers are saved to \"%s\"\\n'%(wn))\n if funcwrappers2:\n wn = os.path.join(options['buildpath'],'%s-f2pywrappers2.f90'%(vrd['modulename']))\n ret['fsrc'] = wn\n f=open(wn,'w')\n f.write('! -*- f90 -*-\\n')\n f.write('! This file is autogenerated with f2py (version:%s)\\n'%(f2py_version))\n f.write('! It contains Fortran 90 wrappers to fortran functions.\\n')\n lines = []\n for l in string.split(string.join(funcwrappers2,'\\n\\n')+'\\n','\\n'):\n if len(l)>72 and l[0]==' ':\n lines.append(l[:72]+'&\\n &')\n l = l[72:]\n while len(l)>66:\n lines.append(l[:66]+'&\\n &')\n l = l[66:]\n lines.append(l+'\\n')\n else: lines.append(l+'\\n')\n lines = string.join(lines,'').replace('\\n &\\n','\\n')\n f.write(lines)\n f.close()\n outmess('\\tFortran 90 wrappers are saved to \"%s\"\\n'%(wn))\n return ret\n\n################## Build C/API function #############\n\nstnd={1:'st',2:'nd',3:'rd',4:'th',5:'th',6:'th',7:'th',8:'th',9:'th',0:'th'}\ndef buildapi(rout):\n rout,wrap = func2subr.assubr(rout)\n args,depargs=getargs2(rout)\n capi_maps.depargs=depargs\n var=rout['vars']\n auxvars = [a for a in var.keys() if isintent_aux(var[a])]\n \n if ismoduleroutine(rout):\n outmess('\\t\\t\\tConstructing wrapper function \"%s.%s\"...\\n'%(rout['modulename'],rout['name']))\n else:\n outmess('\\t\\tConstructing wrapper function \"%s\"...\\n'%(rout['name']))\n # Routine\n vrd=routsign2map(rout)\n rd=dictappend({},vrd)\n for r in rout_rules:\n if (r.has_key('_check') and r['_check'](rout)) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,rout)\n rd=dictappend(rd,ar)\n\n # Args\n nth,nthk=0,0\n savevrd={}\n for a in args:\n vrd=sign2map(a,var[a])\n if isintent_aux(var[a]):\n _rules = aux_rules\n else:\n _rules = arg_rules\n if not isintent_hide(var[a]):\n if not isoptional(var[a]):\n nth=nth+1\n vrd['nth']=`nth`+stnd[nth%10]+' argument'\n else:\n nthk=nthk+1\n vrd['nth']=`nthk`+stnd[nthk%10]+' keyword'\n else: vrd['nth']='hidden' \n savevrd[a]=vrd\n for r in _rules:\n if r.has_key('_depend'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n for a in depargs:\n if isintent_aux(var[a]):\n _rules = aux_rules\n else:\n _rules = arg_rules\n vrd=savevrd[a]\n for r in _rules:\n if not r.has_key('_depend'): continue\n if (r.has_key('_check') and r['_check'](var[a])) or (not r.has_key('_check')):\n ar=applyrules(r,vrd,var[a])\n rd=dictappend(rd,ar)\n if r.has_key('_break'): break\n if var[a].has_key('check'):\n for c in var[a]['check']:\n vrd['check']=c\n ar=applyrules(check_rules,vrd,var[a])\n rd=dictappend(rd,ar)\n if type(rd['cleanupfrompyobj']) is types.ListType:\n rd['cleanupfrompyobj'].reverse()\n if type(rd['closepyobjfrom']) is types.ListType:\n rd['closepyobjfrom'].reverse()\n rd['docsignature']=stripcomma(replace('#docsign##docsignopt##docsignxa#',\n {'docsign':rd['docsign'],\n 'docsignopt':rd['docsignopt'],\n 'docsignxa':rd['docsignxa']}))\n optargs=stripcomma(replace('#docsignopt##docsignxa#',\n {'docsignxa':rd['docsignxashort'],\n 'docsignopt':rd['docsignoptshort']}\n ))\n if optargs=='':\n rd['docsignatureshort']=stripcomma(replace('#docsign#',{'docsign':rd['docsign']}))\n else:\n rd['docsignatureshort']=replace('#docsign#[#docsignopt#]',\n {'docsign':rd['docsign'],\n 'docsignopt':optargs,\n })\n rd['latexdocsignatureshort']=string.replace(rd['docsignatureshort'],'_','\\\\_')\n rd['latexdocsignatureshort']=string.replace(rd['latexdocsignatureshort'],',',', ')\n cfs=stripcomma(replace('#callfortran##callfortranappend#',{'callfortran':rd['callfortran'],'callfortranappend':rd['callfortranappend']}))\n if len(rd['callfortranappend'])>1:\n rd['callcompaqfortran']=stripcomma(replace('#callfortran# 0,#callfortranappend#',{'callfortran':rd['callfortran'],'callfortranappend':rd['callfortranappend']}))\n else:\n rd['callcompaqfortran']=cfs\n rd['callfortran']=cfs\n if type(rd['docreturn'])==types.ListType:\n rd['docreturn']=stripcomma(replace('#docreturn#',{'docreturn':rd['docreturn']}))+' = '\n rd['docstrsigns']=[]\n rd['latexdocstrsigns']=[]\n for k in ['docstrreq','docstropt','docstrout','docstrcbs']:\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['docstrsigns']=rd['docstrsigns']+rd[k]\n k='latex'+k\n if rd.has_key(k) and type(rd[k])==types.ListType:\n rd['latexdocstrsigns']=rd['latexdocstrsigns']+rd[k][0:1]+\\\n ['\\\\begin{description}']+rd[k][1:]+\\\n ['\\\\end{description}']\n ar=applyrules(routine_rules,rd)\n if ismoduleroutine(rout):\n outmess('\\t\\t\\t %s\\n'%(ar['docshort']))\n else:\n outmess('\\t\\t %s\\n'%(ar['docshort']))\n return ar,wrap\n\n\n#################### EOF rules.py #######################\n", + "methods": [ + { + "name": "buildmodule", + "long_name": "buildmodule( m , um )", + "filename": "rules.py", + "nloc": 141, + "complexity": 45, + "token_count": 1298, + "parameters": [ + "m", + "um" + ], + "start_line": 1081, + "end_line": 1233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 153, + "top_nesting_level": 0 + }, + { + "name": "buildapi", + "long_name": "buildapi( rout )", + "filename": "rules.py", + "nloc": 101, + "complexity": 39, + "token_count": 977, + "parameters": [ + "rout" + ], + "start_line": 1238, + "end_line": 1342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "buildmodule", + "long_name": "buildmodule( m , um )", + "filename": "rules.py", + "nloc": 141, + "complexity": 45, + "token_count": 1298, + "parameters": [ + "m", + "um" + ], + "start_line": 1081, + "end_line": 1233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 153, + "top_nesting_level": 0 + }, + { + "name": "buildapi", + "long_name": "buildapi( rout )", + "filename": "rules.py", + "nloc": 101, + "complexity": 39, + "token_count": 977, + "parameters": [ + "rout" + ], + "start_line": 1238, + "end_line": 1342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 1221, + "complexity": 84, + "token_count": 5900, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + }, + { + "old_path": "numpy/f2py/setup.py", + "new_path": "numpy/f2py/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -8,7 +8,7 @@\n Copyright 2001-2005 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Revision: 1.32 $\n@@ -79,7 +79,7 @@ def generate_f2py_py(build_dir):\n 'Development Status :: 5 - Production/Stable',\n 'Intended Audience :: Developers',\n 'Intended Audience :: Science/Research',\n- 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',\n+ 'License :: OSI Approved :: NumPy License',\n 'Natural Language :: English',\n 'Operating System :: OS Independent',\n 'Programming Language :: C',\n@@ -94,7 +94,7 @@ def generate_f2py_py(build_dir):\n author_email = \"pearu@cens.ioc.ee\",\n maintainer = \"Pearu Peterson\",\n maintainer_email = \"pearu@cens.ioc.ee\",\n- license = \"LGPL\",\n+ license = \"BSD\",\n platforms = \"Unix, Windows (mingw|cygwin), Mac OSX\",\n long_description = \"\"\"\\\n The Fortran to Python Interface Generator, or F2PY for short, is a\n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "#!/usr/bin/env python\n\"\"\"\nsetup.py for installing F2PY\n\nUsage:\n python setup.py install\n\nCopyright 2001-2005 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision: 1.32 $\n$Date: 2005/01/30 17:22:14 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: setup.py,v 1.32 2005/01/30 17:22:14 pearu Exp $\"\n\nimport os\nimport sys\nfrom distutils.dep_util import newer\nfrom numpy.distutils.core import setup\nfrom numpy.distutils.misc_util import Configuration\n\nfrom __version__ import version\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('f2py', parent_package, top_path)\n\n config.add_data_dir('docs')\n\n config.add_data_files('src/fortranobject.c',\n 'src/fortranobject.h',\n 'f2py.1'\n )\n\n config.make_svn_version_py()\n\n def generate_f2py_py(build_dir):\n f2py_exe = 'f2py'+os.path.basename(sys.executable)[6:]\n if f2py_exe[-4:]=='.exe':\n f2py_exe = f2py_exe[:-4] + '.py'\n if 'bdist_wininst' in sys.argv and f2py_exe[-3:] != '.py':\n f2py_exe = f2py_exe + '.py'\n target = os.path.join(build_dir,f2py_exe)\n if newer(__file__,target):\n print 'Creating',target\n f = open(target,'w')\n f.write('''\\\n#!/usr/bin/env %s\n# See http://cens.ioc.ee/projects/f2py2e/\nimport os\nos.environ[\"NO_SCIPY_IMPORT\"]=\"f2py\"\nimport numpy.f2py as f2py\nf2py.main()\n'''%(os.path.basename(sys.executable)))\n f.close()\n return target\n\n config.add_scripts(generate_f2py_py)\n\n print 'F2PY Version',config.get_version()\n\n return config\n\nif __name__ == \"__main__\":\n\n config = configuration(top_path='')\n version = config.get_version()\n print 'F2PY Version',version\n config = config.todict()\n\n if sys.version[:3]>='2.3':\n config['download_url'] = \"http://cens.ioc.ee/projects/f2py2e/2.x\"\\\n \"/F2PY-2-latest.tar.gz\"\n config['classifiers'] = [\n 'Development Status :: 5 - Production/Stable',\n 'Intended Audience :: Developers',\n 'Intended Audience :: Science/Research',\n 'License :: OSI Approved :: NumPy License',\n 'Natural Language :: English',\n 'Operating System :: OS Independent',\n 'Programming Language :: C',\n 'Programming Language :: Fortran',\n 'Programming Language :: Python',\n 'Topic :: Scientific/Engineering',\n 'Topic :: Software Development :: Code Generators',\n ]\n setup(version=version,\n description = \"F2PY - Fortran to Python Interface Generaton\",\n author = \"Pearu Peterson\",\n author_email = \"pearu@cens.ioc.ee\",\n maintainer = \"Pearu Peterson\",\n maintainer_email = \"pearu@cens.ioc.ee\",\n license = \"BSD\",\n platforms = \"Unix, Windows (mingw|cygwin), Mac OSX\",\n long_description = \"\"\"\\\nThe Fortran to Python Interface Generator, or F2PY for short, is a\ncommand line tool (f2py) for generating Python C/API modules for\nwrapping Fortran 77/90/95 subroutines, accessing common blocks from\nPython, and calling Python functions from Fortran (call-backs).\nInterfacing subroutines/data from Fortran 90/95 modules is supported.\"\"\",\n url = \"http://cens.ioc.ee/projects/f2py2e/\",\n keywords = ['Fortran','f2py'],\n **config)\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nsetup.py for installing F2PY\n\nUsage:\n python setup.py install\n\nCopyright 2001-2005 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision: 1.32 $\n$Date: 2005/01/30 17:22:14 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id: setup.py,v 1.32 2005/01/30 17:22:14 pearu Exp $\"\n\nimport os\nimport sys\nfrom distutils.dep_util import newer\nfrom numpy.distutils.core import setup\nfrom numpy.distutils.misc_util import Configuration\n\nfrom __version__ import version\n\ndef configuration(parent_package='',top_path=None):\n config = Configuration('f2py', parent_package, top_path)\n\n config.add_data_dir('docs')\n\n config.add_data_files('src/fortranobject.c',\n 'src/fortranobject.h',\n 'f2py.1'\n )\n\n config.make_svn_version_py()\n\n def generate_f2py_py(build_dir):\n f2py_exe = 'f2py'+os.path.basename(sys.executable)[6:]\n if f2py_exe[-4:]=='.exe':\n f2py_exe = f2py_exe[:-4] + '.py'\n if 'bdist_wininst' in sys.argv and f2py_exe[-3:] != '.py':\n f2py_exe = f2py_exe + '.py'\n target = os.path.join(build_dir,f2py_exe)\n if newer(__file__,target):\n print 'Creating',target\n f = open(target,'w')\n f.write('''\\\n#!/usr/bin/env %s\n# See http://cens.ioc.ee/projects/f2py2e/\nimport os\nos.environ[\"NO_SCIPY_IMPORT\"]=\"f2py\"\nimport numpy.f2py as f2py\nf2py.main()\n'''%(os.path.basename(sys.executable)))\n f.close()\n return target\n\n config.add_scripts(generate_f2py_py)\n\n print 'F2PY Version',config.get_version()\n\n return config\n\nif __name__ == \"__main__\":\n\n config = configuration(top_path='')\n version = config.get_version()\n print 'F2PY Version',version\n config = config.todict()\n\n if sys.version[:3]>='2.3':\n config['download_url'] = \"http://cens.ioc.ee/projects/f2py2e/2.x\"\\\n \"/F2PY-2-latest.tar.gz\"\n config['classifiers'] = [\n 'Development Status :: 5 - Production/Stable',\n 'Intended Audience :: Developers',\n 'Intended Audience :: Science/Research',\n 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',\n 'Natural Language :: English',\n 'Operating System :: OS Independent',\n 'Programming Language :: C',\n 'Programming Language :: Fortran',\n 'Programming Language :: Python',\n 'Topic :: Scientific/Engineering',\n 'Topic :: Software Development :: Code Generators',\n ]\n setup(version=version,\n description = \"F2PY - Fortran to Python Interface Generaton\",\n author = \"Pearu Peterson\",\n author_email = \"pearu@cens.ioc.ee\",\n maintainer = \"Pearu Peterson\",\n maintainer_email = \"pearu@cens.ioc.ee\",\n license = \"LGPL\",\n platforms = \"Unix, Windows (mingw|cygwin), Mac OSX\",\n long_description = \"\"\"\\\nThe Fortran to Python Interface Generator, or F2PY for short, is a\ncommand line tool (f2py) for generating Python C/API modules for\nwrapping Fortran 77/90/95 subroutines, accessing common blocks from\nPython, and calling Python functions from Fortran (call-backs).\nInterfacing subroutines/data from Fortran 90/95 modules is supported.\"\"\",\n url = \"http://cens.ioc.ee/projects/f2py2e/\",\n keywords = ['Fortran','f2py'],\n **config)\n", + "methods": [ + { + "name": "configuration.generate_f2py_py", + "long_name": "configuration.generate_f2py_py( build_dir )", + "filename": "setup.py", + "nloc": 20, + "complexity": 5, + "token_count": 122, + "parameters": [ + "build_dir" + ], + "start_line": 41, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 12, + "complexity": 1, + "token_count": 60, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 29, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration.generate_f2py_py", + "long_name": "configuration.generate_f2py_py( build_dir )", + "filename": "setup.py", + "nloc": 20, + "complexity": 5, + "token_count": 122, + "parameters": [ + "build_dir" + ], + "start_line": 41, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 12, + "complexity": 1, + "token_count": 60, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 29, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 92, + "complexity": 6, + "token_count": 348, + "diff_parsed": { + "added": [ + "terms of the NumPy License.", + " 'License :: OSI Approved :: NumPy License',", + " license = \"BSD\"," + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org", + " 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',", + " license = \"LGPL\"," + ] + } + }, + { + "old_path": "numpy/f2py/use_rules.py", + "new_path": "numpy/f2py/use_rules.py", + "filename": "use_rules.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -8,7 +8,7 @@\n Copyright 2000 Pearu Peterson all rights reserved,\n Pearu Peterson \n Permission to use, modify, and distribute this software is given under the\n-terms of the LGPL. See http://www.fsf.org\n+terms of the NumPy License.\n \n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n $Date: 2000/09/10 12:35:43 $\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\"\"\"\n\nBuild 'use others module data' mechanism for f2py2e.\n\nUnfinished.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the NumPy License.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2000/09/10 12:35:43 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.3 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\n##############\n\nusemodule_rules={\n 'body':\"\"\"\n#begintitle#\nstatic char doc_#apiname#[] = \\\"\\\\\\nVariable wrapper signature:\\\\n\\\\\n\\t #name# = get_#name#()\\\\n\\\\\nArguments:\\\\n\\\\\n#docstr#\\\";\nextern F_MODFUNC(#usemodulename#,#USEMODULENAME#,#realname#,#REALNAME#);\nstatic PyObject *#apiname#(PyObject *capi_self, PyObject *capi_args) {\n/*#decl#*/\n\\tif (!PyArg_ParseTuple(capi_args, \\\"\\\")) goto capi_fail;\nprintf(\\\"c: %d\\\\n\\\",F_MODFUNC(#usemodulename#,#USEMODULENAME#,#realname#,#REALNAME#));\n\\treturn Py_BuildValue(\\\"\\\");\ncapi_fail:\n\\treturn NULL;\n}\n\"\"\",\n 'method':'\\t{\\\"get_#name#\\\",#apiname#,METH_VARARGS|METH_KEYWORDS,doc_#apiname#},',\n 'need':['F_MODFUNC']\n }\n\n################\n\ndef buildusevars(m,r):\n ret={}\n outmess('\\t\\tBuilding use variable hooks for module \"%s\" (feature only for F90/F95)...\\n'%(m['name']))\n varsmap={}\n revmap={}\n if r.has_key('map'):\n for k in r['map'].keys():\n if revmap.has_key(r['map'][k]):\n outmess('\\t\\t\\tVariable \"%s<=%s\" is already mapped by \"%s\". Skipping.\\n'%(r['map'][k],k,revmap[r['map'][k]]))\n else:\n revmap[r['map'][k]]=k\n if r.has_key('only') and r['only']:\n for v in r['map'].keys():\n if m['vars'].has_key(r['map'][v]):\n \n if revmap[r['map'][v]]==v:\n varsmap[v]=r['map'][v]\n else:\n outmess('\\t\\t\\tIgnoring map \"%s=>%s\". See above.\\n'%(v,r['map'][v]))\n else:\n outmess('\\t\\t\\tNo definition for variable \"%s=>%s\". Skipping.\\n'%(v,r['map'][v]))\n else:\n for v in m['vars'].keys():\n if revmap.has_key(v):\n varsmap[v]=revmap[v]\n else:\n varsmap[v]=v\n for v in varsmap.keys():\n ret=dictappend(ret,buildusevar(v,varsmap[v],m['vars'],m['name']))\n return ret\ndef buildusevar(name,realname,vars,usemodulename):\n outmess('\\t\\t\\tConstructing wrapper function for variable \"%s=>%s\"...\\n'%(name,realname))\n ret={}\n vrd={'name':name,\n 'realname':realname,\n 'REALNAME':string.upper(realname),\n 'usemodulename':usemodulename,\n 'USEMODULENAME':string.upper(usemodulename),\n 'texname':string.replace(name,'_','\\\\_'),\n 'begintitle':gentitle('%s=>%s'%(name,realname)),\n 'endtitle':gentitle('end of %s=>%s'%(name,realname)),\n 'apiname':'#modulename#_use_%s_from_%s'%(realname,usemodulename)\n }\n nummap={0:'Ro',1:'Ri',2:'Rii',3:'Riii',4:'Riv',5:'Rv',6:'Rvi',7:'Rvii',8:'Rviii',9:'Rix'}\n vrd['texnamename']=name\n for i in nummap.keys():\n vrd['texnamename']=string.replace(vrd['texnamename'],`i`,nummap[i])\n if hasnote(vars[realname]): vrd['note']=vars[realname]['note']\n rd=dictappend({},vrd)\n var=vars[realname]\n \n print name,realname,vars[realname]\n ret=applyrules(usemodule_rules,rd)\n return ret\n\n\n\n\n\n\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\n\nBuild 'use others module data' mechanism for f2py2e.\n\nUnfinished.\n\nCopyright 2000 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Date: 2000/09/10 12:35:43 $\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Revision: 1.3 $\"[10:-1]\n\nf2py_version='See `f2py -v`'\n\nimport pprint\nimport sys,string,time,types,copy\nerrmess=sys.stderr.write\noutmess=sys.stdout.write\nshow=pprint.pprint\n\nfrom auxfuncs import *\nimport capi_maps\nimport cfuncs\n##############\n\nusemodule_rules={\n 'body':\"\"\"\n#begintitle#\nstatic char doc_#apiname#[] = \\\"\\\\\\nVariable wrapper signature:\\\\n\\\\\n\\t #name# = get_#name#()\\\\n\\\\\nArguments:\\\\n\\\\\n#docstr#\\\";\nextern F_MODFUNC(#usemodulename#,#USEMODULENAME#,#realname#,#REALNAME#);\nstatic PyObject *#apiname#(PyObject *capi_self, PyObject *capi_args) {\n/*#decl#*/\n\\tif (!PyArg_ParseTuple(capi_args, \\\"\\\")) goto capi_fail;\nprintf(\\\"c: %d\\\\n\\\",F_MODFUNC(#usemodulename#,#USEMODULENAME#,#realname#,#REALNAME#));\n\\treturn Py_BuildValue(\\\"\\\");\ncapi_fail:\n\\treturn NULL;\n}\n\"\"\",\n 'method':'\\t{\\\"get_#name#\\\",#apiname#,METH_VARARGS|METH_KEYWORDS,doc_#apiname#},',\n 'need':['F_MODFUNC']\n }\n\n################\n\ndef buildusevars(m,r):\n ret={}\n outmess('\\t\\tBuilding use variable hooks for module \"%s\" (feature only for F90/F95)...\\n'%(m['name']))\n varsmap={}\n revmap={}\n if r.has_key('map'):\n for k in r['map'].keys():\n if revmap.has_key(r['map'][k]):\n outmess('\\t\\t\\tVariable \"%s<=%s\" is already mapped by \"%s\". Skipping.\\n'%(r['map'][k],k,revmap[r['map'][k]]))\n else:\n revmap[r['map'][k]]=k\n if r.has_key('only') and r['only']:\n for v in r['map'].keys():\n if m['vars'].has_key(r['map'][v]):\n \n if revmap[r['map'][v]]==v:\n varsmap[v]=r['map'][v]\n else:\n outmess('\\t\\t\\tIgnoring map \"%s=>%s\". See above.\\n'%(v,r['map'][v]))\n else:\n outmess('\\t\\t\\tNo definition for variable \"%s=>%s\". Skipping.\\n'%(v,r['map'][v]))\n else:\n for v in m['vars'].keys():\n if revmap.has_key(v):\n varsmap[v]=revmap[v]\n else:\n varsmap[v]=v\n for v in varsmap.keys():\n ret=dictappend(ret,buildusevar(v,varsmap[v],m['vars'],m['name']))\n return ret\ndef buildusevar(name,realname,vars,usemodulename):\n outmess('\\t\\t\\tConstructing wrapper function for variable \"%s=>%s\"...\\n'%(name,realname))\n ret={}\n vrd={'name':name,\n 'realname':realname,\n 'REALNAME':string.upper(realname),\n 'usemodulename':usemodulename,\n 'USEMODULENAME':string.upper(usemodulename),\n 'texname':string.replace(name,'_','\\\\_'),\n 'begintitle':gentitle('%s=>%s'%(name,realname)),\n 'endtitle':gentitle('end of %s=>%s'%(name,realname)),\n 'apiname':'#modulename#_use_%s_from_%s'%(realname,usemodulename)\n }\n nummap={0:'Ro',1:'Ri',2:'Rii',3:'Riii',4:'Riv',5:'Rv',6:'Rvi',7:'Rvii',8:'Rviii',9:'Rix'}\n vrd['texnamename']=name\n for i in nummap.keys():\n vrd['texnamename']=string.replace(vrd['texnamename'],`i`,nummap[i])\n if hasnote(vars[realname]): vrd['note']=vars[realname]['note']\n rd=dictappend({},vrd)\n var=vars[realname]\n \n print name,realname,vars[realname]\n ret=applyrules(usemodule_rules,rd)\n return ret\n\n\n\n\n\n\n", + "methods": [ + { + "name": "buildusevars", + "long_name": "buildusevars( m , r )", + "filename": "use_rules.py", + "nloc": 29, + "complexity": 12, + "token_count": 285, + "parameters": [ + "m", + "r" + ], + "start_line": 56, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "buildusevar", + "long_name": "buildusevar( name , realname , vars , usemodulename )", + "filename": "use_rules.py", + "nloc": 23, + "complexity": 3, + "token_count": 243, + "parameters": [ + "name", + "realname", + "vars", + "usemodulename" + ], + "start_line": 86, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "buildusevars", + "long_name": "buildusevars( m , r )", + "filename": "use_rules.py", + "nloc": 29, + "complexity": 12, + "token_count": 285, + "parameters": [ + "m", + "r" + ], + "start_line": 56, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "buildusevar", + "long_name": "buildusevar( name , realname , vars , usemodulename )", + "filename": "use_rules.py", + "nloc": 23, + "complexity": 3, + "token_count": 243, + "parameters": [ + "name", + "realname", + "vars", + "usemodulename" + ], + "start_line": 86, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 97, + "complexity": 15, + "token_count": 599, + "diff_parsed": { + "added": [ + "terms of the NumPy License." + ], + "deleted": [ + "terms of the LGPL. See http://www.fsf.org" + ] + } + } + ] + }, + { + "hash": "97f03d64d86f6d7a7c9135c44ef97baf17e6ce15", + "msg": "Fix segfault when using subdescr.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T22:23:18+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T22:23:18+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "e45d0eb3dd55af9e1347bf39307be5695c67bd7b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 0, + "insertions": 1, + "lines": 1, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/src/arraytypes.inc.src", + "new_path": "numpy/core/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -342,6 +342,7 @@ VOID_getitem(char *ip, PyArrayObject *ap)\n \t\t\t\t\t\"invalid shape in fixed-type tuple.\");\n \t\t\treturn NULL;\n \t\t}\n+ Py_INCREF(descr->subarray->base);\n \t\tret = PyArray_NewFromDescr(&PyArray_Type,\n \t\t\t\t\t descr->subarray->base,\n \t\t\t\t\t shape.len, shape.ptr,\n", + "added_lines": 1, + "deleted_lines": 0, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + " Py_INCREF(descr->subarray->base);" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "f3a4e8ff8d76dbadd59d4d4e2efc359d3b2db091", + "msg": "Fix str representation for rank-0 arrays", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T22:28:02+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T22:28:02+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "97f03d64d86f6d7a7c9135c44ef97baf17e6ce15" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/numeric.py", + "new_path": "numpy/core/numeric.py", + "filename": "numeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -241,7 +241,7 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):\n return cName + \"(%s, dtype=%s)\" % (lst, typename)\n \n def array_str(a, max_line_width=None, precision=None, suppress_small=None):\n- return array2string(a, max_line_width, precision, suppress_small, ' ', \"\")\n+ return array2string(a, max_line_width, precision, suppress_small, ' ', \"\", str)\n \n set_string_function = multiarray.set_string_function\n set_string_function(array_str, 0)\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',\n 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtype',\n 'fromstring', 'fromfile', 'frombuffer','newbuffer',\n 'getbuffer',\n 'where', 'concatenate', 'fastCopyAndTranspose', 'lexsort',\n 'register_dtype', 'set_numeric_ops', 'can_cast',\n 'asarray', 'asanyarray', 'isfortran', 'zeros_like', 'empty_like',\n 'correlate', 'convolve', 'inner', 'dot', 'outer', 'vdot',\n 'alterdot', 'restoredot', 'cross',\n 'array2string', 'get_printoptions', 'set_printoptions',\n 'array_repr', 'array_str', 'set_string_function',\n 'little_endian',\n 'indices', 'fromfunction',\n 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',\n 'ones', 'identity', 'allclose',\n 'seterr', 'geterr', 'setbufsize', 'getbufsize',\n 'seterrcall', 'geterrcall',\n 'Inf', 'inf', 'infty', 'Infinity',\n 'nan', 'NaN', 'False_', 'True_']\n\nimport sys\nimport multiarray\nimport umath\nfrom umath import *\nimport numerictypes\nfrom numerictypes import *\n\ndef extend_all(module):\n adict = {}\n for a in __all__:\n adict[a] = 1\n try:\n mall = getattr(module, '__all__')\n except AttributeError:\n mall = [k for k in module.__dict__.keys() if not k.startswith('_')]\n for a in mall:\n if a not in adict:\n __all__.append(a)\n\nextend_all(umath)\nextend_all(numerictypes)\n\nnewaxis = None\n\nndarray = multiarray.ndarray\nbigndarray = multiarray.bigndarray\nflatiter = multiarray.flatiter\nbroadcast = multiarray.broadcast\ndtype=multiarray.dtype\nufunc = type(sin)\n\narange = multiarray.arange\narray = multiarray.array\nzeros = multiarray.zeros\nempty = multiarray.empty\nfromstring = multiarray.fromstring\nfromfile = multiarray.fromfile\nfrombuffer = multiarray.frombuffer\nnewbuffer = multiarray.newbuffer\ngetbuffer = multiarray.getbuffer\nwhere = multiarray.where\nconcatenate = multiarray.concatenate\nfastCopyAndTranspose = multiarray._fastCopyAndTranspose\nregister_dtype = multiarray.register_dtype\nset_numeric_ops = multiarray.set_numeric_ops\ncan_cast = multiarray.can_cast\nlexsort = multiarray.lexsort\n\n\ndef asarray(a, dtype=None, fortran=False):\n \"\"\"returns a as an array. Unlike array(),\n no copy is performed if a is already an array. Subclasses are converted\n to base class ndarray.\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran)\n\ndef asanyarray(a, dtype=None, copy=False, fortran=False):\n \"\"\"will pass subclasses through...\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran, subok=1)\n\ndef isfortran(a):\n return a.flags['FNC']\n\n# from Fernando Perez's IPython\ndef zeros_like(a):\n \"\"\"Return an array of zeros of the shape and typecode of a.\n\n If you don't explicitly need the array to be zeroed, you should instead\n use empty_like(), which is faster as it only allocates memory.\"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(zeros(a.shape, a.dtype, a.flags['FNC']))\n\ndef empty_like(a):\n \"\"\"Return an empty (uninitialized) array of the shape and typecode of a.\n\n Note that this does NOT initialize the returned array. If you require\n your array to be initialized, you should use zeros_like().\n\n \"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(empty(a.shape, a.dtype, a.flags['FNC']))\n\n# end Fernando's utilities\n\n_mode_from_name_dict = {'v': 0,\n 's' : 1,\n 'f' : 2}\n\ndef _mode_from_name(mode):\n if isinstance(mode, type(\"\")):\n return _mode_from_name_dict[mode.lower()[0]]\n return mode\n\ndef correlate(a,v,mode='valid'):\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,v,mode)\n\n\ndef convolve(a,v,mode='full'):\n \"\"\"Returns the discrete, linear convolution of 1-D\n sequences a and v; mode can be 0 (valid), 1 (same), or 2 (full)\n to specify size of the resulting sequence.\n \"\"\"\n if (len(v) > len(a)):\n a, v = v, a\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,asarray(v)[::-1],mode)\n\n\ninner = multiarray.inner\ndot = multiarray.dot\n\ndef outer(a,b):\n \"\"\"outer(a,b) returns the outer product of two vectors.\n result(i,j) = a(i)*b(j) when a and b are vectors\n Will accept any arguments that can be made into vectors.\n \"\"\"\n a = asarray(a)\n b = asarray(b)\n return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]\n\ndef vdot(a, b):\n \"\"\"Returns the dot product of 2 vectors (or anything that can be made into\n a vector). NB: this is not the same as `dot`, as it takes the conjugate\n of its first argument if complex and always returns a scalar.\"\"\"\n return dot(asarray(a).ravel().conj(), asarray(b).ravel())\n\n# try to import blas optimized dot if available\ntry:\n # importing this changes the dot function for basic 4 types\n # to blas-optimized versions.\n from _dotblas import dot, vdot, inner, alterdot, restoredot\nexcept ImportError:\n def alterdot():\n pass\n def restoredot():\n pass\n\n\ndef _move_axis_to_0(a, axis):\n if axis == 0:\n return a\n n = a.ndim\n if axis < 0:\n axis += n\n axes = range(1, axis+1) + [0,] + range(axis+1, n)\n return a.transpose(axes)\n\ndef cross(a, b, axisa=-1, axisb=-1, axisc=-1):\n \"\"\"Return the cross product of two (arrays of) vectors.\n\n The cross product is performed over the last axis of a and b by default,\n and can handle axes with dimensions 2 and 3. For a dimension of 2,\n the z-component of the equivalent three-dimensional cross product is\n returned.\n \"\"\"\n a = _move_axis_to_0(asarray(a), axisa)\n b = _move_axis_to_0(asarray(b), axisb)\n msg = \"incompatible dimensions for cross product\\n\"\\\n \"(dimension must be 2 or 3)\"\n if (a.shape[0] not in [2,3]) or (b.shape[0] not in [2,3]):\n raise ValueError(msg)\n if a.shape[0] == 2:\n if (b.shape[0] == 2):\n cp = a[0]*b[1] - a[1]*b[0]\n if cp.ndim == 0:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n else:\n x = a[1]*b[2]\n y = -a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n elif a.shape[0] == 3:\n if (b.shape[0] == 3):\n x = a[1]*b[2] - a[2]*b[1]\n y = a[2]*b[0] - a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n else:\n x = -a[2]*b[1]\n y = a[2]*b[0]\n z = a[0]*b[1] - a[1]*b[0]\n cp = array([x,y,z])\n if cp.ndim == 1:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n\n\n#Use numarray's printing function\nfrom arrayprint import array2string, get_printoptions, set_printoptions\n\n_typelessdata = [int_, float_, complex_]\nif issubclass(intc, int):\n _typelessdata.append(intc)\n\nif issubclass(longlong, int):\n _typelessdata.append(longlong)\n\ndef array_repr(arr, max_line_width=None, precision=None, suppress_small=None):\n if arr.size > 0 or arr.shape==(0,):\n lst = array2string(arr, max_line_width, precision, suppress_small,\n ', ', \"array(\")\n else: # show zero-length shape unless it is (0,)\n lst = \"[], shape=%s\" % (repr(arr.shape),)\n typeless = arr.dtype.type in _typelessdata\n\n if arr.__class__ is not ndarray:\n cName= arr.__class__.__name__\n else:\n cName = \"array\"\n if typeless and arr.size:\n return cName + \"(%s)\" % lst\n else:\n typename=arr.dtype.type.__name__[:-8]\n if issubclass(arr.dtype.type, flexible):\n if typename not in ['unicode','string','void']:\n typename = arr.dtype.type.__name__\n typename = \"(%s,%d)\" % (typename, arr.itemsize)\n return cName + \"(%s, dtype=%s)\" % (lst, typename)\n\ndef array_str(a, max_line_width=None, precision=None, suppress_small=None):\n return array2string(a, max_line_width, precision, suppress_small, ' ', \"\", str)\n\nset_string_function = multiarray.set_string_function\nset_string_function(array_str, 0)\nset_string_function(array_repr, 1)\n\n\nlittle_endian = (sys.byteorder == 'little')\n\ndef indices(dimensions, dtype=int_):\n \"\"\"indices(dimensions,dtype=int_) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n tmp = ones(dimensions, dtype)\n lst = []\n for i in range(len(dimensions)):\n lst.append( add.accumulate(tmp, i, )-1 )\n return array(lst)\n\ndef fromfunction(function, dimensions, **kwargs):\n \"\"\"fromfunction(function, dimensions) returns an array constructed by\n calling function on a tuple of number grids. The function should\n accept as many arguments as there are dimensions which is a list of\n numbers indicating the length of the desired output for each axis.\n\n The function can also accept keyword arguments which will be\n passed in as well.\n \"\"\"\n args = indices(dimensions)\n return function(*args,**kwargs)\n\ndef isscalar(num):\n if isinstance(num, generic):\n return True\n else:\n return type(num) in ScalarType\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is equivalent to using base_repr with base 2, but about 25x\n faster.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n import math\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n\nfrom cPickle import load, loads\n_cload = load\n_file = file\n\ndef load(file):\n if isinstance(file, type(\"\")):\n file = _file(file,\"rb\")\n return _cload(file)\n\n# These are all essentially abbreviations\n# These might wind up in a special abbreviations module\n\ndef ones(shape, dtype=int_, fortran=False):\n \"\"\"ones(shape, dtype=int_) returns an array of the given\n dimensions which is initialized to all ones. \n \"\"\"\n # This appears to be slower...\n #a = empty(shape, dtype, fortran)\n #a.fill(1)\n a = zeros(shape, dtype, fortran)\n a+=1\n return a\n\ndef identity(n,dtype=int_):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n a = array([1]+n*[0],dtype=dtype)\n b = empty((n,n),dtype=dtype)\n b.flat = a\n return b\n\ndef allclose (a, b, rtol=1.e-5, atol=1.e-8):\n \"\"\" allclose(a,b,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 The relative error rtol must be positive and << 1.0\n The absolute error atol comes into play for those elements\n of y that are very small or zero; it says how small x must be also.\n \"\"\"\n x = array(a, copy=False)\n y = array(b, copy=False)\n d = less(absolute(x-y), atol + rtol * absolute(y))\n return d.ravel().all()\n\ndef _setpyvals(lst, frame, where=0):\n if not isinstance(lst, list) or len(lst) != 3:\n raise ValueError, \"Invalid pyvalues (length 3 list needed).\"\n\n try:\n wh = where.lower()[0]\n except (AttributeError, TypeError, IndexError):\n wh = None\n\n if where==0 or wh == 'l':\n frame.f_locals[UFUNC_PYVALS_NAME] = lst\n elif where == 1 or wh == 'g':\n frame.f_globals[UFUNC_PYVALS_NAME] = lst\n elif where == 2 or wh == 'b':\n frame.f_builtins[UFUNC_PYVALS_NAME] = lst \n\n umath.update_use_defaults()\n return\n\ndef _getpyvals(frame):\n try:\n return frame.f_locals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_globals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_builtins[UFUNC_PYVALS_NAME]\n except KeyError:\n return [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n\n_errdict = {\"ignore\":ERR_IGNORE,\n \"warn\":ERR_WARN,\n \"raise\":ERR_RAISE,\n \"call\":ERR_CALL}\n\n_errdict_rev = {}\nfor key in _errdict.keys():\n _errdict_rev[_errdict[key]] = key\ndel key\n\ndef seterr(divide=\"ignore\", over=\"ignore\", under=\"ignore\",\n invalid=\"ignore\", where=0):\n maskvalue = ((_errdict[divide] << SHIFT_DIVIDEBYZERO) +\n (_errdict[over] << SHIFT_OVERFLOW ) +\n (_errdict[under] << SHIFT_UNDERFLOW) +\n (_errdict[invalid] << SHIFT_INVALID))\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[1] = maskvalue\n _setpyvals(pyvals, frame, where)\n\ndef geterr():\n frame = sys._getframe().f_back\n maskvalue = _getpyvals(frame)[1]\n\n mask = 3\n res = {}\n val = (maskvalue >> SHIFT_DIVIDEBYZERO) & mask\n res['divide'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_OVERFLOW) & mask\n res['over'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_UNDERFLOW) & mask\n res['under'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_INVALID) & mask\n res['invalid'] = _errdict_rev[val]\n return res\n\ndef setbufsize(size, where=0):\n if size > 10e6:\n raise ValueError, \"Very big buffers.. %s\" % size\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[0] = size\n _setpyvals(pyvals, frame, where)\n\ndef getbufsize():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[0]\n\ndef seterrcall(func, where=0):\n if not callable(func):\n raise ValueError, \"Only callable can be used as callback\"\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[2] = func\n _setpyvals(pyvals, frame, where)\n\ndef geterrcall():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[2]\n\ndef _setdef():\n frame = sys._getframe()\n defval = [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n frame.f_globals[UFUNC_PYVALS_NAME] = defval\n frame.f_builtins[UFUNC_PYVALS_NAME] = defval\n umath.update_use_defaults()\n\n# set the default values\n_setdef()\n\nInf = inf = infty = Infinity = PINF\nnan = NaN = NAN\nFalse_ = bool_(False)\nTrue_ = bool_(True)\n\nimport oldnumeric\nfrom oldnumeric import *\nextend_all(oldnumeric)\n", + "source_code_before": "__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',\n 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtype',\n 'fromstring', 'fromfile', 'frombuffer','newbuffer',\n 'getbuffer',\n 'where', 'concatenate', 'fastCopyAndTranspose', 'lexsort',\n 'register_dtype', 'set_numeric_ops', 'can_cast',\n 'asarray', 'asanyarray', 'isfortran', 'zeros_like', 'empty_like',\n 'correlate', 'convolve', 'inner', 'dot', 'outer', 'vdot',\n 'alterdot', 'restoredot', 'cross',\n 'array2string', 'get_printoptions', 'set_printoptions',\n 'array_repr', 'array_str', 'set_string_function',\n 'little_endian',\n 'indices', 'fromfunction',\n 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',\n 'ones', 'identity', 'allclose',\n 'seterr', 'geterr', 'setbufsize', 'getbufsize',\n 'seterrcall', 'geterrcall',\n 'Inf', 'inf', 'infty', 'Infinity',\n 'nan', 'NaN', 'False_', 'True_']\n\nimport sys\nimport multiarray\nimport umath\nfrom umath import *\nimport numerictypes\nfrom numerictypes import *\n\ndef extend_all(module):\n adict = {}\n for a in __all__:\n adict[a] = 1\n try:\n mall = getattr(module, '__all__')\n except AttributeError:\n mall = [k for k in module.__dict__.keys() if not k.startswith('_')]\n for a in mall:\n if a not in adict:\n __all__.append(a)\n\nextend_all(umath)\nextend_all(numerictypes)\n\nnewaxis = None\n\nndarray = multiarray.ndarray\nbigndarray = multiarray.bigndarray\nflatiter = multiarray.flatiter\nbroadcast = multiarray.broadcast\ndtype=multiarray.dtype\nufunc = type(sin)\n\narange = multiarray.arange\narray = multiarray.array\nzeros = multiarray.zeros\nempty = multiarray.empty\nfromstring = multiarray.fromstring\nfromfile = multiarray.fromfile\nfrombuffer = multiarray.frombuffer\nnewbuffer = multiarray.newbuffer\ngetbuffer = multiarray.getbuffer\nwhere = multiarray.where\nconcatenate = multiarray.concatenate\nfastCopyAndTranspose = multiarray._fastCopyAndTranspose\nregister_dtype = multiarray.register_dtype\nset_numeric_ops = multiarray.set_numeric_ops\ncan_cast = multiarray.can_cast\nlexsort = multiarray.lexsort\n\n\ndef asarray(a, dtype=None, fortran=False):\n \"\"\"returns a as an array. Unlike array(),\n no copy is performed if a is already an array. Subclasses are converted\n to base class ndarray.\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran)\n\ndef asanyarray(a, dtype=None, copy=False, fortran=False):\n \"\"\"will pass subclasses through...\n \"\"\"\n return array(a, dtype, copy=False, fortran=fortran, subok=1)\n\ndef isfortran(a):\n return a.flags['FNC']\n\n# from Fernando Perez's IPython\ndef zeros_like(a):\n \"\"\"Return an array of zeros of the shape and typecode of a.\n\n If you don't explicitly need the array to be zeroed, you should instead\n use empty_like(), which is faster as it only allocates memory.\"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(zeros(a.shape, a.dtype, a.flags['FNC']))\n\ndef empty_like(a):\n \"\"\"Return an empty (uninitialized) array of the shape and typecode of a.\n\n Note that this does NOT initialize the returned array. If you require\n your array to be initialized, you should use zeros_like().\n\n \"\"\"\n a = asanyarray(a)\n return a.__array_wrap__(empty(a.shape, a.dtype, a.flags['FNC']))\n\n# end Fernando's utilities\n\n_mode_from_name_dict = {'v': 0,\n 's' : 1,\n 'f' : 2}\n\ndef _mode_from_name(mode):\n if isinstance(mode, type(\"\")):\n return _mode_from_name_dict[mode.lower()[0]]\n return mode\n\ndef correlate(a,v,mode='valid'):\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,v,mode)\n\n\ndef convolve(a,v,mode='full'):\n \"\"\"Returns the discrete, linear convolution of 1-D\n sequences a and v; mode can be 0 (valid), 1 (same), or 2 (full)\n to specify size of the resulting sequence.\n \"\"\"\n if (len(v) > len(a)):\n a, v = v, a\n mode = _mode_from_name(mode)\n return multiarray.correlate(a,asarray(v)[::-1],mode)\n\n\ninner = multiarray.inner\ndot = multiarray.dot\n\ndef outer(a,b):\n \"\"\"outer(a,b) returns the outer product of two vectors.\n result(i,j) = a(i)*b(j) when a and b are vectors\n Will accept any arguments that can be made into vectors.\n \"\"\"\n a = asarray(a)\n b = asarray(b)\n return a.ravel()[:,newaxis]*b.ravel()[newaxis,:]\n\ndef vdot(a, b):\n \"\"\"Returns the dot product of 2 vectors (or anything that can be made into\n a vector). NB: this is not the same as `dot`, as it takes the conjugate\n of its first argument if complex and always returns a scalar.\"\"\"\n return dot(asarray(a).ravel().conj(), asarray(b).ravel())\n\n# try to import blas optimized dot if available\ntry:\n # importing this changes the dot function for basic 4 types\n # to blas-optimized versions.\n from _dotblas import dot, vdot, inner, alterdot, restoredot\nexcept ImportError:\n def alterdot():\n pass\n def restoredot():\n pass\n\n\ndef _move_axis_to_0(a, axis):\n if axis == 0:\n return a\n n = a.ndim\n if axis < 0:\n axis += n\n axes = range(1, axis+1) + [0,] + range(axis+1, n)\n return a.transpose(axes)\n\ndef cross(a, b, axisa=-1, axisb=-1, axisc=-1):\n \"\"\"Return the cross product of two (arrays of) vectors.\n\n The cross product is performed over the last axis of a and b by default,\n and can handle axes with dimensions 2 and 3. For a dimension of 2,\n the z-component of the equivalent three-dimensional cross product is\n returned.\n \"\"\"\n a = _move_axis_to_0(asarray(a), axisa)\n b = _move_axis_to_0(asarray(b), axisb)\n msg = \"incompatible dimensions for cross product\\n\"\\\n \"(dimension must be 2 or 3)\"\n if (a.shape[0] not in [2,3]) or (b.shape[0] not in [2,3]):\n raise ValueError(msg)\n if a.shape[0] == 2:\n if (b.shape[0] == 2):\n cp = a[0]*b[1] - a[1]*b[0]\n if cp.ndim == 0:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n else:\n x = a[1]*b[2]\n y = -a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n elif a.shape[0] == 3:\n if (b.shape[0] == 3):\n x = a[1]*b[2] - a[2]*b[1]\n y = a[2]*b[0] - a[0]*b[2]\n z = a[0]*b[1] - a[1]*b[0]\n else:\n x = -a[2]*b[1]\n y = a[2]*b[0]\n z = a[0]*b[1] - a[1]*b[0]\n cp = array([x,y,z])\n if cp.ndim == 1:\n return cp\n else:\n return cp.swapaxes(0,axisc)\n\n\n#Use numarray's printing function\nfrom arrayprint import array2string, get_printoptions, set_printoptions\n\n_typelessdata = [int_, float_, complex_]\nif issubclass(intc, int):\n _typelessdata.append(intc)\n\nif issubclass(longlong, int):\n _typelessdata.append(longlong)\n\ndef array_repr(arr, max_line_width=None, precision=None, suppress_small=None):\n if arr.size > 0 or arr.shape==(0,):\n lst = array2string(arr, max_line_width, precision, suppress_small,\n ', ', \"array(\")\n else: # show zero-length shape unless it is (0,)\n lst = \"[], shape=%s\" % (repr(arr.shape),)\n typeless = arr.dtype.type in _typelessdata\n\n if arr.__class__ is not ndarray:\n cName= arr.__class__.__name__\n else:\n cName = \"array\"\n if typeless and arr.size:\n return cName + \"(%s)\" % lst\n else:\n typename=arr.dtype.type.__name__[:-8]\n if issubclass(arr.dtype.type, flexible):\n if typename not in ['unicode','string','void']:\n typename = arr.dtype.type.__name__\n typename = \"(%s,%d)\" % (typename, arr.itemsize)\n return cName + \"(%s, dtype=%s)\" % (lst, typename)\n\ndef array_str(a, max_line_width=None, precision=None, suppress_small=None):\n return array2string(a, max_line_width, precision, suppress_small, ' ', \"\")\n\nset_string_function = multiarray.set_string_function\nset_string_function(array_str, 0)\nset_string_function(array_repr, 1)\n\n\nlittle_endian = (sys.byteorder == 'little')\n\ndef indices(dimensions, dtype=int_):\n \"\"\"indices(dimensions,dtype=int_) returns an array representing a grid\n of indices with row-only, and column-only variation.\n \"\"\"\n tmp = ones(dimensions, dtype)\n lst = []\n for i in range(len(dimensions)):\n lst.append( add.accumulate(tmp, i, )-1 )\n return array(lst)\n\ndef fromfunction(function, dimensions, **kwargs):\n \"\"\"fromfunction(function, dimensions) returns an array constructed by\n calling function on a tuple of number grids. The function should\n accept as many arguments as there are dimensions which is a list of\n numbers indicating the length of the desired output for each axis.\n\n The function can also accept keyword arguments which will be\n passed in as well.\n \"\"\"\n args = indices(dimensions)\n return function(*args,**kwargs)\n\ndef isscalar(num):\n if isinstance(num, generic):\n return True\n else:\n return type(num) in ScalarType\n\n_lkup = {'0':'000',\n '1':'001',\n '2':'010',\n '3':'011',\n '4':'100',\n '5':'101',\n '6':'110',\n '7':'111',\n 'L':''}\n\ndef binary_repr(num):\n \"\"\"Return the binary representation of the input number as a string.\n\n This is equivalent to using base_repr with base 2, but about 25x\n faster.\n \"\"\"\n ostr = oct(num)\n bin = ''\n for ch in ostr[1:]:\n bin += _lkup[ch]\n ind = 0\n while bin[ind] == '0':\n ind += 1\n return bin[ind:]\n\ndef base_repr (number, base=2, padding=0):\n \"\"\"Return the representation of a number in any given base.\n \"\"\"\n chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n import math\n lnb = math.log(base)\n res = padding*chars[0]\n if number == 0:\n return res + chars[0]\n exponent = int (math.log (number)/lnb)\n while(exponent >= 0):\n term = long(base)**exponent\n lead_digit = int(number / term)\n res += chars[lead_digit]\n number -= term*lead_digit\n exponent -= 1\n return res\n\nfrom cPickle import load, loads\n_cload = load\n_file = file\n\ndef load(file):\n if isinstance(file, type(\"\")):\n file = _file(file,\"rb\")\n return _cload(file)\n\n# These are all essentially abbreviations\n# These might wind up in a special abbreviations module\n\ndef ones(shape, dtype=int_, fortran=False):\n \"\"\"ones(shape, dtype=int_) returns an array of the given\n dimensions which is initialized to all ones. \n \"\"\"\n # This appears to be slower...\n #a = empty(shape, dtype, fortran)\n #a.fill(1)\n a = zeros(shape, dtype, fortran)\n a+=1\n return a\n\ndef identity(n,dtype=int_):\n \"\"\"identity(n) returns the identity matrix of shape n x n.\n \"\"\"\n a = array([1]+n*[0],dtype=dtype)\n b = empty((n,n),dtype=dtype)\n b.flat = a\n return b\n\ndef allclose (a, b, rtol=1.e-5, atol=1.e-8):\n \"\"\" allclose(a,b,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 The relative error rtol must be positive and << 1.0\n The absolute error atol comes into play for those elements\n of y that are very small or zero; it says how small x must be also.\n \"\"\"\n x = array(a, copy=False)\n y = array(b, copy=False)\n d = less(absolute(x-y), atol + rtol * absolute(y))\n return d.ravel().all()\n\ndef _setpyvals(lst, frame, where=0):\n if not isinstance(lst, list) or len(lst) != 3:\n raise ValueError, \"Invalid pyvalues (length 3 list needed).\"\n\n try:\n wh = where.lower()[0]\n except (AttributeError, TypeError, IndexError):\n wh = None\n\n if where==0 or wh == 'l':\n frame.f_locals[UFUNC_PYVALS_NAME] = lst\n elif where == 1 or wh == 'g':\n frame.f_globals[UFUNC_PYVALS_NAME] = lst\n elif where == 2 or wh == 'b':\n frame.f_builtins[UFUNC_PYVALS_NAME] = lst \n\n umath.update_use_defaults()\n return\n\ndef _getpyvals(frame):\n try:\n return frame.f_locals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_globals[UFUNC_PYVALS_NAME]\n except KeyError:\n try:\n return frame.f_builtins[UFUNC_PYVALS_NAME]\n except KeyError:\n return [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n\n_errdict = {\"ignore\":ERR_IGNORE,\n \"warn\":ERR_WARN,\n \"raise\":ERR_RAISE,\n \"call\":ERR_CALL}\n\n_errdict_rev = {}\nfor key in _errdict.keys():\n _errdict_rev[_errdict[key]] = key\ndel key\n\ndef seterr(divide=\"ignore\", over=\"ignore\", under=\"ignore\",\n invalid=\"ignore\", where=0):\n maskvalue = ((_errdict[divide] << SHIFT_DIVIDEBYZERO) +\n (_errdict[over] << SHIFT_OVERFLOW ) +\n (_errdict[under] << SHIFT_UNDERFLOW) +\n (_errdict[invalid] << SHIFT_INVALID))\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[1] = maskvalue\n _setpyvals(pyvals, frame, where)\n\ndef geterr():\n frame = sys._getframe().f_back\n maskvalue = _getpyvals(frame)[1]\n\n mask = 3\n res = {}\n val = (maskvalue >> SHIFT_DIVIDEBYZERO) & mask\n res['divide'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_OVERFLOW) & mask\n res['over'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_UNDERFLOW) & mask\n res['under'] = _errdict_rev[val]\n val = (maskvalue >> SHIFT_INVALID) & mask\n res['invalid'] = _errdict_rev[val]\n return res\n\ndef setbufsize(size, where=0):\n if size > 10e6:\n raise ValueError, \"Very big buffers.. %s\" % size\n\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[0] = size\n _setpyvals(pyvals, frame, where)\n\ndef getbufsize():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[0]\n\ndef seterrcall(func, where=0):\n if not callable(func):\n raise ValueError, \"Only callable can be used as callback\"\n frame = sys._getframe().f_back\n pyvals = _getpyvals(frame)\n pyvals[2] = func\n _setpyvals(pyvals, frame, where)\n\ndef geterrcall():\n frame = sys._getframe().f_back\n return _getpyvals(frame)[2]\n\ndef _setdef():\n frame = sys._getframe()\n defval = [UFUNC_BUFSIZE_DEFAULT, ERR_DEFAULT, None]\n frame.f_globals[UFUNC_PYVALS_NAME] = defval\n frame.f_builtins[UFUNC_PYVALS_NAME] = defval\n umath.update_use_defaults()\n\n# set the default values\n_setdef()\n\nInf = inf = infty = Infinity = PINF\nnan = NaN = NAN\nFalse_ = bool_(False)\nTrue_ = bool_(True)\n\nimport oldnumeric\nfrom oldnumeric import *\nextend_all(oldnumeric)\n", + "methods": [ + { + "name": "extend_all", + "long_name": "extend_all( module )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 7, + "token_count": 73, + "parameters": [ + "module" + ], + "start_line": 28, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( a , dtype = None , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "dtype", + "fortran" + ], + "start_line": 70, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "asanyarray", + "long_name": "asanyarray( a , dtype = None , copy = False , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "a", + "dtype", + "copy", + "fortran" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isfortran", + "long_name": "isfortran( a )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "a" + ], + "start_line": 82, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "zeros_like", + "long_name": "zeros_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 86, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "empty_like", + "long_name": "empty_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 94, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_mode_from_name", + "long_name": "_mode_from_name( mode )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 30, + "parameters": [ + "mode" + ], + "start_line": 110, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "correlate", + "long_name": "correlate( a , v , mode = 'valid' )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 115, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convolve", + "long_name": "convolve( a , v , mode = 'full' )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 57, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 120, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "outer", + "long_name": "outer( a , b )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "a", + "b" + ], + "start_line": 134, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "vdot", + "long_name": "vdot( a , b )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 33, + "parameters": [ + "a", + "b" + ], + "start_line": 143, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "alterdot", + "long_name": "alterdot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 155, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "restoredot", + "long_name": "restoredot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 157, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_move_axis_to_0", + "long_name": "_move_axis_to_0( a , axis )", + "filename": "numeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "a", + "axis" + ], + "start_line": 161, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cross", + "long_name": "cross( a , b , axisa = - 1 , axisb = - 1 , axisc = - 1 )", + "filename": "numeric.py", + "nloc": 32, + "complexity": 9, + "token_count": 360, + "parameters": [ + "a", + "b", + "axisa", + "axisb", + "axisc" + ], + "start_line": 170, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( arr , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 20, + "complexity": 8, + "token_count": 176, + "parameters": [ + "arr", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 221, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( a , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "a", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = int_ )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 54, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 253, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( function , dimensions , ** kwargs )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "function", + "dimensions", + "kwargs" + ], + "start_line": 263, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "num" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "binary_repr", + "long_name": "binary_repr( num )", + "filename": "numeric.py", + "nloc": 9, + "complexity": 3, + "token_count": 50, + "parameters": [ + "num" + ], + "start_line": 291, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "base_repr", + "long_name": "base_repr( number , base = 2 , padding = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "number", + "base", + "padding" + ], + "start_line": 306, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "load", + "long_name": "load( file )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "file" + ], + "start_line": 329, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int_ , fortran = False )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "shape", + "dtype", + "fortran" + ], + "start_line": 337, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n , dtype = int_ )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "n", + "dtype" + ], + "start_line": 348, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "a", + "b", + "rtol", + "atol" + ], + "start_line": 356, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_setpyvals", + "long_name": "_setpyvals( lst , frame , where = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 10, + "token_count": 112, + "parameters": [ + "lst", + "frame", + "where" + ], + "start_line": 369, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_getpyvals", + "long_name": "_getpyvals( frame )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 4, + "token_count": 49, + "parameters": [ + "frame" + ], + "start_line": 388, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "seterr", + "long_name": "seterr( divide = \"ignore\" , over = \"ignore\" , under = \"ignore\" , invalid = \"ignore\" , where = 0 )", + "filename": "numeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 95, + "parameters": [ + "divide", + "over", + "under", + "invalid", + "where" + ], + "start_line": 410, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "geterr", + "long_name": "geterr( )", + "filename": "numeric.py", + "nloc": 14, + "complexity": 1, + "token_count": 107, + "parameters": [], + "start_line": 422, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "setbufsize", + "long_name": "setbufsize( size , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "size", + "where" + ], + "start_line": 438, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getbufsize", + "long_name": "getbufsize( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 447, + "end_line": 449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "seterrcall", + "long_name": "seterrcall( func , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "func", + "where" + ], + "start_line": 451, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "geterrcall", + "long_name": "geterrcall( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 459, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_setdef", + "long_name": "_setdef( )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "extend_all", + "long_name": "extend_all( module )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 7, + "token_count": 73, + "parameters": [ + "module" + ], + "start_line": 28, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( a , dtype = None , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "dtype", + "fortran" + ], + "start_line": 70, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "asanyarray", + "long_name": "asanyarray( a , dtype = None , copy = False , fortran = False )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "a", + "dtype", + "copy", + "fortran" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isfortran", + "long_name": "isfortran( a )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "a" + ], + "start_line": 82, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "zeros_like", + "long_name": "zeros_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 86, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "empty_like", + "long_name": "empty_like( a )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 35, + "parameters": [ + "a" + ], + "start_line": 94, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_mode_from_name", + "long_name": "_mode_from_name( mode )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 30, + "parameters": [ + "mode" + ], + "start_line": 110, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "correlate", + "long_name": "correlate( a , v , mode = 'valid' )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 115, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convolve", + "long_name": "convolve( a , v , mode = 'full' )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 57, + "parameters": [ + "a", + "v", + "mode" + ], + "start_line": 120, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "outer", + "long_name": "outer( a , b )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "a", + "b" + ], + "start_line": 134, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "vdot", + "long_name": "vdot( a , b )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 33, + "parameters": [ + "a", + "b" + ], + "start_line": 143, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "alterdot", + "long_name": "alterdot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 155, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "restoredot", + "long_name": "restoredot( )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 5, + "parameters": [], + "start_line": 157, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_move_axis_to_0", + "long_name": "_move_axis_to_0( a , axis )", + "filename": "numeric.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "a", + "axis" + ], + "start_line": 161, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "cross", + "long_name": "cross( a , b , axisa = - 1 , axisb = - 1 , axisc = - 1 )", + "filename": "numeric.py", + "nloc": 32, + "complexity": 9, + "token_count": 360, + "parameters": [ + "a", + "b", + "axisa", + "axisb", + "axisc" + ], + "start_line": 170, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( arr , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 20, + "complexity": 8, + "token_count": 176, + "parameters": [ + "arr", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 221, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( a , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "indices", + "long_name": "indices( dimensions , dtype = int_ )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 2, + "token_count": 54, + "parameters": [ + "dimensions", + "dtype" + ], + "start_line": 253, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "fromfunction", + "long_name": "fromfunction( function , dimensions , ** kwargs )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "function", + "dimensions", + "kwargs" + ], + "start_line": 263, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 24, + "parameters": [ + "num" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "binary_repr", + "long_name": "binary_repr( num )", + "filename": "numeric.py", + "nloc": 9, + "complexity": 3, + "token_count": 50, + "parameters": [ + "num" + ], + "start_line": 291, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "base_repr", + "long_name": "base_repr( number , base = 2 , padding = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "number", + "base", + "padding" + ], + "start_line": 306, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "load", + "long_name": "load( file )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "file" + ], + "start_line": 329, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "ones", + "long_name": "ones( shape , dtype = int_ , fortran = False )", + "filename": "numeric.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "shape", + "dtype", + "fortran" + ], + "start_line": 337, + "end_line": 346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "identity", + "long_name": "identity( n , dtype = int_ )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "n", + "dtype" + ], + "start_line": 348, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "allclose", + "long_name": "allclose( a , b , rtol = 1 . e - 5 , atol = 1 . e - 8 )", + "filename": "numeric.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "a", + "b", + "rtol", + "atol" + ], + "start_line": 356, + "end_line": 367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_setpyvals", + "long_name": "_setpyvals( lst , frame , where = 0 )", + "filename": "numeric.py", + "nloc": 15, + "complexity": 10, + "token_count": 112, + "parameters": [ + "lst", + "frame", + "where" + ], + "start_line": 369, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_getpyvals", + "long_name": "_getpyvals( frame )", + "filename": "numeric.py", + "nloc": 11, + "complexity": 4, + "token_count": 49, + "parameters": [ + "frame" + ], + "start_line": 388, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "seterr", + "long_name": "seterr( divide = \"ignore\" , over = \"ignore\" , under = \"ignore\" , invalid = \"ignore\" , where = 0 )", + "filename": "numeric.py", + "nloc": 10, + "complexity": 1, + "token_count": 95, + "parameters": [ + "divide", + "over", + "under", + "invalid", + "where" + ], + "start_line": 410, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "geterr", + "long_name": "geterr( )", + "filename": "numeric.py", + "nloc": 14, + "complexity": 1, + "token_count": 107, + "parameters": [], + "start_line": 422, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "setbufsize", + "long_name": "setbufsize( size , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "size", + "where" + ], + "start_line": 438, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "getbufsize", + "long_name": "getbufsize( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 447, + "end_line": 449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "seterrcall", + "long_name": "seterrcall( func , where = 0 )", + "filename": "numeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 49, + "parameters": [ + "func", + "where" + ], + "start_line": 451, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "geterrcall", + "long_name": "geterrcall( )", + "filename": "numeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [], + "start_line": 459, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "_setdef", + "long_name": "_setdef( )", + "filename": "numeric.py", + "nloc": 6, + "complexity": 1, + "token_count": 41, + "parameters": [], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "array_str", + "long_name": "array_str( a , max_line_width = None , precision = None , suppress_small = None )", + "filename": "numeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "a", + "max_line_width", + "precision", + "suppress_small" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "nloc": 335, + "complexity": 81, + "token_count": 2585, + "diff_parsed": { + "added": [ + " return array2string(a, max_line_width, precision, suppress_small, ' ', \"\", str)" + ], + "deleted": [ + " return array2string(a, max_line_width, precision, suppress_small, ' ', \"\")" + ] + } + } + ] + }, + { + "hash": "3249d3b68eb2132ab0e1dcbf228618bcb326c417", + "msg": "Fix so that None converts to Nan in array conversion.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T23:05:07+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T23:05:07+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f3a4e8ff8d76dbadd59d4d4e2efc359d3b2db091" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 1, + "insertions": 32, + "lines": 33, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/src/arraytypes.inc.src", + "new_path": "numpy/core/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -30,13 +30,44 @@ MyPyLong_AsUnsignedLongLong(PyObject *vv)\n \treturn PyLong_AsUnsignedLongLong(vv);\t\n }\n \n+static double \n+_getNAN(void) {\n+#ifdef NAN\n+ return NAN;\n+#else\n+ double mul = 1e100;\n+ double tmp = 0.0;\n+ double pinf=0;\n+ static double nan=0;\n+ \n+ if (nan == 0) {\n+ pinf = mul;\n+ for (;;) {\n+ pinf *= mul;\n+ if (pinf == tmp) break;\n+ tmp = pinf;\n+ }\n+ nan = pinf / pinf;\n+ }\n+ return nan;\n+#endif\n+}\n+\n+static double\n+MyPyFloat_AsDouble(PyObject *obj)\n+{\n+ if (obj == Py_None) return _getNAN();\n+ return PyFloat_AsDouble(obj); \n+}\n+\n+\n /****************** getitem and setitem **********************/\n \n /**begin repeat\n \n #TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n #func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n-#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n+#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n #typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n #typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n #kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n", + "added_lines": 32, + "deleted_lines": 1, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\nstatic double \n_getNAN(void) {\n#ifdef NAN\n return NAN;\n#else\n double mul = 1e100;\n double tmp = 0.0;\n double pinf=0;\n static double nan=0;\n \n if (nan == 0) {\n pinf = mul;\n for (;;) {\n pinf *= mul;\n if (pinf == tmp) break;\n tmp = pinf;\n }\n nan = pinf / pinf;\n }\n return nan;\n#endif\n}\n\nstatic double\nMyPyFloat_AsDouble(PyObject *obj)\n{\n if (obj == Py_None) return _getNAN();\n return PyFloat_AsDouble(obj); \n}\n\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "static double", + "_getNAN(void) {", + "#ifdef NAN", + " return NAN;", + "#else", + " double mul = 1e100;", + " double tmp = 0.0;", + " double pinf=0;", + " static double nan=0;", + "", + " if (nan == 0) {", + " pinf = mul;", + " for (;;) {", + " pinf *= mul;", + " if (pinf == tmp) break;", + " tmp = pinf;", + " }", + " nan = pinf / pinf;", + " }", + " return nan;", + "#endif", + "}", + "", + "static double", + "MyPyFloat_AsDouble(PyObject *obj)", + "{", + " if (obj == Py_None) return _getNAN();", + " return PyFloat_AsDouble(obj);", + "}", + "", + "", + "#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#" + ], + "deleted": [ + "#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#" + ] + } + } + ] + }, + { + "hash": "a0a42fce29c83184f730b08cf48828edd35bb99b", + "msg": "Fix conversions to NaN for other floating types", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T23:15:58+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T23:15:58+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "3249d3b68eb2132ab0e1dcbf228618bcb326c417" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 2, + "insertions": 8, + "lines": 10, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/src/arraytypes.inc.src", + "new_path": "numpy/core/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -159,7 +159,12 @@ static int\n \t\telse { \n op2 = op; Py_INCREF(op);\n }\n- oop = PyComplex_AsCComplex (op2);\n+ if (op2 == Py_None) {\n+ oop.real = oop.imag = _getNAN();\n+ }\n+ else {\n+ oop = PyComplex_AsCComplex (op2);\n+ }\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n@@ -193,7 +198,8 @@ LONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n- temp = (longdouble)PyFloat_AsDouble(op);\n+ if (op == Py_None) temp = (longdouble)_getNAN();\n+ else temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n", + "added_lines": 8, + "deleted_lines": 2, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\nstatic double \n_getNAN(void) {\n#ifdef NAN\n return NAN;\n#else\n double mul = 1e100;\n double tmp = 0.0;\n double pinf=0;\n static double nan=0;\n \n if (nan == 0) {\n pinf = mul;\n for (;;) {\n pinf *= mul;\n if (pinf == tmp) break;\n tmp = pinf;\n }\n nan = pinf / pinf;\n }\n return nan;\n#endif\n}\n\nstatic double\nMyPyFloat_AsDouble(PyObject *obj)\n{\n if (obj == Py_None) return _getNAN();\n return PyFloat_AsDouble(obj); \n}\n\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n if (op2 == Py_None) {\n oop.real = oop.imag = _getNAN();\n }\n else {\n oop = PyComplex_AsCComplex (op2);\n }\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n if (op == Py_None) temp = (longdouble)_getNAN();\n else temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\nstatic double \n_getNAN(void) {\n#ifdef NAN\n return NAN;\n#else\n double mul = 1e100;\n double tmp = 0.0;\n double pinf=0;\n static double nan=0;\n \n if (nan == 0) {\n pinf = mul;\n for (;;) {\n pinf *= mul;\n if (pinf == tmp) break;\n tmp = pinf;\n }\n nan = pinf / pinf;\n }\n return nan;\n#endif\n}\n\nstatic double\nMyPyFloat_AsDouble(PyObject *obj)\n{\n if (obj == Py_None) return _getNAN();\n return PyFloat_AsDouble(obj); \n}\n\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + " if (op2 == Py_None) {", + " oop.real = oop.imag = _getNAN();", + " }", + " else {", + " oop = PyComplex_AsCComplex (op2);", + " }", + " if (op == Py_None) temp = (longdouble)_getNAN();", + " else temp = (longdouble)PyFloat_AsDouble(op);" + ], + "deleted": [ + " oop = PyComplex_AsCComplex (op2);", + " temp = (longdouble)PyFloat_AsDouble(op);" + ] + } + } + ] + }, + { + "hash": "6b724c9e4798b919858c3a980c3e865eb4a055c1", + "msg": "A few safety checks for platforms where SIZEOF_LONG < SIZEOF_INTP -- windows 64-bit I think", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T23:25:44+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T23:25:44+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "a0a42fce29c83184f730b08cf48828edd35bb99b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 0, + "insertions": 12, + "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/arrayobject.c", + "new_path": "numpy/core/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -3338,15 +3338,27 @@ PyArray_IntpFromSequence(PyObject *seq, intp *vals, int maxvals)\n or, can be made into one */\n \tif ((nd=PySequence_Length(seq)) == -1) {\n \t\tif (PyErr_Occurred()) PyErr_Clear();\n+#if SIZEOF_LONG >= 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", + "added_lines": 12, + "deleted_lines": 0, + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*axis = PyArray_NDIM(temp)-1;\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\tintp sd;\n\tint i;\n\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "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\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 if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_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\t\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\t\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\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\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\t\n new_data = (char *)_pya_malloc(stride);\n\t\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\t\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\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\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\t\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\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}\t\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\t\n finish:\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\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\t\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}\t\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}\t\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\t\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\t\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\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\t\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, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\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\t\n return (PyObject *)ret;\t\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 / sizeof(Py_UNICODE);\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\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\t\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\t\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\t\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\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\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\t\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\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \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\t\t\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\t\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 i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\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\t\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 SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int 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\t\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\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\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\t\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\t\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\t\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\t\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);\t\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\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\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 }\t \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\t\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\t\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}\t\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\t\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\t\t\t\t\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\t\t\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\treturn PyArray_ToScalar(self->data, self);\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\treturn PyArray_ToScalar(self->data, self);\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\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\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\t\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\t\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\t\t\t\t\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\t\t\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\t\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\t\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\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\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 \narray_getsegcount(PyArrayObject *self, int *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 \narray_getreadbuf(PyArrayObject *self, int 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 \narray_getwritebuf(PyArrayObject *self, int 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 \narray_getcharbuf(PyArrayObject *self, int 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 (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};\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\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;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\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\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);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\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;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\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);\t \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\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\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}\t\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}\t\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 *\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 PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\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 *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\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\t\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;\t \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 an \"\\\n\t\t\t\t\"int; 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;\t \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;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \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;\t \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;\t \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*/\t\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 ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\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\n self->dimensions[0] = l;\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 ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\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\t\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\n\nstatic PySequenceMethods array_as_sequence = {\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};\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\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\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\t\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\t\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\t\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\t\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\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 0, 0);\n\t\t\t\t/* If not successful, then return the integer\n\t\t\t\t object 0. 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 0\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 /* Try to convert other to an array */\n\t\t\tif (!PyArray_Check(other)) {\n\t\t\t\tarray_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t\t self->descr->type_num, 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\t*axis = PyArray_NDIM(temp)-1;\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; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\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\t\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;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\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;\t\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 */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tmydim = newdims + oldnd;\n\tif (PyTuple_Check(old->subarray->shape)) {\n\t\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\t\t\n\t\tfor (i=0; isubarray->shape, i));\n\t\t}\n\t}\n\telse {\n\t\tnumnew = 1;\n\t\tmydim[0] = (intp) PyInt_AsLong(old->subarray->shape);\n\t}\n\t\n\tnewnd = oldnd + numnew;\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\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\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{\t\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\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);\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\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->nd = nd;\n\tself->dimensions = NULL;\n\tself->data = NULL;\n\tif (data == NULL) { /* strides is NULL too */\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\t\t\n\tsd = descr->elsize;\n\tself->descr = descr;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\t\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 {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tgoto fail;\n\t\t\t} \n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t} \t\n\t\t\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\t\tif (descr == &OBJECT_Descr) {\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 and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_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 (!(self->flags & OWNDATA)) { /* did not allocate own data */\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\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\t\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*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\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\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\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\t\t\n\t\trefcnt = REFCOUNT(self);\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\t\t\t\t\n\t\tif (newsize == 0) sd = self->descr->elsize;\t\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 0, &(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);\t\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\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\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 \"fortran\", 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\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*/\t\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\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 &fortran)) \n\t\tgoto fail;\n\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 if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\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 NULL, 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\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\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 (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\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 (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 PyObject_CallMethod(_numpy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\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;\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 != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \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 if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_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}\t\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 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\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\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\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\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\ttemp = (PyArrayObject *)\\\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\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\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\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\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\t\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}\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{\t\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{\t\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);\t\t\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\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.bigndarray\",\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 NULL, \t\t\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\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \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/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"numpy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\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\t\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;\t\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\t\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, sizeof(Py_UNICODE)*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\t\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, 2*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\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\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\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 \t\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\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\t\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\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\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\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\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\t\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 *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (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\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\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 unless return value is NULL*/\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\tPyArray_Descr *savetype=typecode;\n\t\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\t\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 return NULL;\n }\n\t\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 return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\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\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\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\t\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\t\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\t\t\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\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\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\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\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);\t\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\t\t\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*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\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\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \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\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\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\t\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\t\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\t\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 (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\t\t\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 != &PyBigArray_Type)) {\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 (subtype != &PyBigArray_Type)) {\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\t\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 != &PyBigArray_Type)) {\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\t\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}\t\t\n\t\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;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \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;\t\t \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;\t\t \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\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\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\t\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, 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, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"\");\n }\n }\n else {\n new = PyObject_CallFunction(array_meth, \"OO\", typecode, context);\n if (new == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) {\n PyErr_Clear();\n new = PyObject_CallFunction(array_meth, \"O\", 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}\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, flags);\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\t\t\t\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 PyErr_Clear();\n else\n seq = TRUE;\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\t\n\t/* Be sure we succeed here */\n\t\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 or PyBigArray_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) || PyBigArray_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 * sizeof(Py_UNICODE)\\\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.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\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\t\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\t\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\t\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\niter_length(PyArrayIterObject *self) \n{\n return (int) 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\t\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;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */ \t\n\t\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\t\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\t\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\t\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\t\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\t\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\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\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;\t\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\t{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 0, /* 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\t\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\t\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\t \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\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\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\t\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\t\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\t\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\t\n\tint i, err=0;\n\t\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\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\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);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\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\t\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\t\n return (PyObject *)multi;\n\t\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);\t\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;\t\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(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\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\n if (endian == '=') {\n endian = '<';\n if (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n }\n\n return PyString_FromFormat(\"%c%c%d\", endian, basic_,\n self->elsize);\n}\n\nstatic PyObject *\narraydescr_typename_get(PyArray_Descr *self)\n{\n int len;\n PyTypeObject *typeobj = self->typeobj;\n\tPyObject *res;\n\n\t/* Both are equivalents, but second is more resistent to changes */\n/* \tlen = strlen(typeobj->tp_name) - 8; */\n\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) {\n\t\tres = PyString_FromString(typeobj->tp_name);\n\t}\n\telse {\n\t\tlen = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);\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;\t\t\t\t\t\t \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{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\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\t{\"name\",\n\t (getter)arraydescr_typename_get,\n\t NULL,\n\t \"The array_protocol typename.\"},\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\t\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\t\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\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\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\t\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\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\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\t\t\t\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\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\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\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 0, \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", + "methods": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 3332, + "end_line": 3367, + "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": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3373, + "end_line": 3389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3393, + "end_line": 3409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3412, + "end_line": 3429, + "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": 3432, + "end_line": 3465, + "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": 3472, + "end_line": 3499, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3508, + "end_line": 3523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3543, + "end_line": 3567, + "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": 3573, + "end_line": 3595, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3599, + "end_line": 3641, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3649, + "end_line": 3807, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3816, + "end_line": 3914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3920, + "end_line": 3937, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3941, + "end_line": 3983, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3986, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4109, + "end_line": 4117, + "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": 4123, + "end_line": 4126, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4129, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4136, + "end_line": 4139, + "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": 4143, + "end_line": 4172, + "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": 4176, + "end_line": 4179, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4182, + "end_line": 4220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4224, + "end_line": 4231, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4234, + "end_line": 4242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4246, + "end_line": 4252, + "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": 4255, + "end_line": 4269, + "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": 4272, + "end_line": 4316, + "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": 4320, + "end_line": 4323, + "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": 4326, + "end_line": 4337, + "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": 4340, + "end_line": 4351, + "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": 4357, + "end_line": 4360, + "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": 4363, + "end_line": 4367, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4381, + "end_line": 4466, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4469, + "end_line": 4487, + "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": 4490, + "end_line": 4508, + "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": 4511, + "end_line": 4521, + "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": 4525, + "end_line": 4550, + "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": 4554, + "end_line": 4587, + "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": 4590, + "end_line": 4623, + "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": 4626, + "end_line": 4663, + "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": 4666, + "end_line": 4669, + "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": 4672, + "end_line": 4722, + "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": 4812, + "end_line": 4819, + "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": 4921, + "end_line": 4954, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4957, + "end_line": 4979, + "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": 4986, + "end_line": 5012, + "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": 5018, + "end_line": 5050, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5062, + "end_line": 5198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5201, + "end_line": 5224, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5229, + "end_line": 5257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5262, + "end_line": 5326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5333, + "end_line": 5342, + "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": 5348, + "end_line": 5441, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5451, + "end_line": 5497, + "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": 5507, + "end_line": 5560, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5565, + "end_line": 5694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5698, + "end_line": 5806, + "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": 5810, + "end_line": 5850, + "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": 5854, + "end_line": 5992, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5996, + "end_line": 6033, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6039, + "end_line": 6115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6120, + "end_line": 6123, + "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": 6130, + "end_line": 6143, + "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": 6189, + "end_line": 6205, + "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": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6218, + "end_line": 6234, + "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": 6240, + "end_line": 6328, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6333, + "end_line": 6361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6374, + "end_line": 6412, + "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": 6420, + "end_line": 6437, + "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": 6442, + "end_line": 6452, + "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": 6455, + "end_line": 6459, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6462, + "end_line": 6465, + "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": 6469, + "end_line": 6519, + "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": 6522, + "end_line": 6576, + "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": 6580, + "end_line": 6713, + "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": 6717, + "end_line": 6749, + "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": 6752, + "end_line": 6794, + "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": 6797, + "end_line": 6931, + "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": 6944, + "end_line": 6989, + "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": 6994, + "end_line": 6998, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7067, + "end_line": 7083, + "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": 7090, + "end_line": 7159, + "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": 7163, + "end_line": 7200, + "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": 7206, + "end_line": 7250, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7268, + "end_line": 7396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7402, + "end_line": 7474, + "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": 7477, + "end_line": 7603, + "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": 7607, + "end_line": 7616, + "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": 7687, + "end_line": 7736, + "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": 7739, + "end_line": 7784, + "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": 7787, + "end_line": 7806, + "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": 7809, + "end_line": 7816, + "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": 7819, + "end_line": 7829, + "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": 7832, + "end_line": 7842, + "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": 7845, + "end_line": 7848, + "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": 7851, + "end_line": 7863, + "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": 7893, + "end_line": 7900, + "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": 7959, + "end_line": 7968, + "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": 7986, + "end_line": 8008, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8014, + "end_line": 8024, + "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": 8042, + "end_line": 8050, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8053, + "end_line": 8065, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8068, + "end_line": 8090, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8093, + "end_line": 8112, + "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": 8119, + "end_line": 8126, + "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": 8129, + "end_line": 8136, + "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": 8139, + "end_line": 8146, + "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": 8186, + "end_line": 8238, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8244, + "end_line": 8301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8309, + "end_line": 8351, + "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": 8371, + "end_line": 8437, + "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": 8448, + "end_line": 8456, + "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": 8471, + "end_line": 8516, + "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": 8519, + "end_line": 8528, + "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": 8531, + "end_line": 8541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 29, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 68, + "end_line": 96, + "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": 102, + "end_line": 131, + "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": 137, + "end_line": 187, + "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": 210, + "end_line": 241, + "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": 244, + "end_line": 278, + "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": 294, + "end_line": 316, + "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": 322, + "end_line": 343, + "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": 347, + "end_line": 385, + "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": 390, + "end_line": 410, + "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": 424, + "end_line": 506, + "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": 513, + "end_line": 587, + "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": 590, + "end_line": 605, + "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": 611, + "end_line": 619, + "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": 635, + "end_line": 715, + "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": 719, + "end_line": 733, + "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": 746, + "end_line": 772, + "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": 778, + "end_line": 792, + "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 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 801, + "end_line": 821, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 81, + "complexity": 12, + "token_count": 483, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 830, + "end_line": 914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "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": 930, + "end_line": 933, + "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": 943, + "end_line": 965, + "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": 979, + "end_line": 1019, + "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": 1034, + "end_line": 1075, + "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": 1082, + "end_line": 1173, + "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": 1179, + "end_line": 1208, + "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": 1211, + "end_line": 1247, + "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": 1256, + "end_line": 1293, + "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": 1300, + "end_line": 1308, + "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": 1311, + "end_line": 1336, + "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 i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1339, + "end_line": 1342, + "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": 1346, + "end_line": 1381, + "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 i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1387, + "end_line": 1390, + "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": 1396, + "end_line": 1404, + "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": 1410, + "end_line": 1460, + "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": 1467, + "end_line": 1512, + "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": 1516, + "end_line": 1610, + "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": 1613, + "end_line": 1650, + "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": 1662, + "end_line": 1715, + "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": 1718, + "end_line": 1778, + "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": 1781, + "end_line": 1808, + "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": 1811, + "end_line": 1830, + "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": 1842, + "end_line": 1904, + "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": 103, + "complexity": 28, + "token_count": 666, + "parameters": [ + "self", + "op" + ], + "start_line": 1928, + "end_line": 2046, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 119, + "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": 2061, + "end_line": 2166, + "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": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 2175, + "end_line": 2178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 2197, + "end_line": 2209, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2212, + "end_line": 2227, + "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 segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2231, + "end_line": 2240, + "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 segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2243, + "end_line": 2254, + "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": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2325, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2368, + "end_line": 2407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "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": 2410, + "end_line": 2433, + "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": 2437, + "end_line": 2460, + "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": 2464, + "end_line": 2471, + "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": 2474, + "end_line": 2481, + "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": 2484, + "end_line": 2492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 2495, + "end_line": 2498, + "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": 2501, + "end_line": 2504, + "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": 2507, + "end_line": 2510, + "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": 2513, + "end_line": 2516, + "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": 2519, + "end_line": 2522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2525, + "end_line": 2528, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 2531, + "end_line": 2534, + "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": 2537, + "end_line": 2540, + "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": 2543, + "end_line": 2546, + "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": 2549, + "end_line": 2552, + "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": 2555, + "end_line": 2558, + "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": 2561, + "end_line": 2564, + "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": 2567, + "end_line": 2570, + "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": 2573, + "end_line": 2576, + "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": 2579, + "end_line": 2582, + "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": 2585, + "end_line": 2588, + "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": 2591, + "end_line": 2594, + "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": 2597, + "end_line": 2600, + "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": 2603, + "end_line": 2606, + "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 * 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_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": 2615, + "end_line": 2618, + "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": 2621, + "end_line": 2624, + "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": 2627, + "end_line": 2630, + "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": 2633, + "end_line": 2636, + "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": 2639, + "end_line": 2642, + "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": 2645, + "end_line": 2648, + "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": 2651, + "end_line": 2654, + "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": 2657, + "end_line": 2661, + "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": 2664, + "end_line": 2668, + "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": 2672, + "end_line": 2690, + "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": 2693, + "end_line": 2710, + "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": 2715, + "end_line": 2730, + "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": 2734, + "end_line": 2760, + "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": 2763, + "end_line": 2788, + "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": 2791, + "end_line": 2813, + "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": 2816, + "end_line": 2838, + "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": 2841, + "end_line": 2863, + "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": 2866, + "end_line": 2870, + "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 ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2931, + "end_line": 2971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2975, + "end_line": 2996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "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": 2999, + "end_line": 3011, + "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": 3032, + "end_line": 3079, + "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": 3082, + "end_line": 3118, + "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": 3127, + "end_line": 3144, + "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": 3147, + "end_line": 3159, + "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": 3162, + "end_line": 3174, + "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": 73, + "complexity": 15, + "token_count": 325, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 3177, + "end_line": 3266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 171, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3269, + "end_line": 3298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "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": 3304, + "end_line": 3324, + "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": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3332, + "end_line": 3355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3361, + "end_line": 3377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3381, + "end_line": 3397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 3400, + "end_line": 3417, + "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": 3420, + "end_line": 3453, + "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": 3460, + "end_line": 3487, + "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 * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3496, + "end_line": 3511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 3531, + "end_line": 3555, + "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": 3561, + "end_line": 3583, + "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)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 6, + "token_count": 229, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3587, + "end_line": 3629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "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": 130, + "complexity": 26, + "token_count": 761, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3637, + "end_line": 3795, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 159, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 82, + "complexity": 15, + "token_count": 497, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3804, + "end_line": 3902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 99, + "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": 3908, + "end_line": 3925, + "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": 41, + "complexity": 6, + "token_count": 231, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3929, + "end_line": 3971, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 103, + "complexity": 19, + "token_count": 583, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3974, + "end_line": 4093, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "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": 4097, + "end_line": 4105, + "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": 4111, + "end_line": 4114, + "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": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 4117, + "end_line": 4121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 4124, + "end_line": 4127, + "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": 4131, + "end_line": 4160, + "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": 4164, + "end_line": 4167, + "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": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 4170, + "end_line": 4208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "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": 4212, + "end_line": 4219, + "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": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4222, + "end_line": 4230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 4234, + "end_line": 4240, + "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": 4243, + "end_line": 4257, + "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": 4260, + "end_line": 4304, + "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": 4308, + "end_line": 4311, + "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": 4314, + "end_line": 4325, + "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": 4328, + "end_line": 4339, + "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": 4345, + "end_line": 4348, + "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": 4351, + "end_line": 4355, + "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": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4369, + "end_line": 4454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "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": 4457, + "end_line": 4475, + "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": 4478, + "end_line": 4496, + "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": 4499, + "end_line": 4509, + "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": 4513, + "end_line": 4538, + "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": 4542, + "end_line": 4575, + "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": 4578, + "end_line": 4611, + "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": 4614, + "end_line": 4651, + "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": 4654, + "end_line": 4657, + "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": 4660, + "end_line": 4710, + "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": 4800, + "end_line": 4807, + "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": 4909, + "end_line": 4942, + "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": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4945, + "end_line": 4967, + "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": 4974, + "end_line": 5000, + "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": 5006, + "end_line": 5038, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 5050, + "end_line": 5186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "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": 5189, + "end_line": 5212, + "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": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5217, + "end_line": 5245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 21, + "token_count": 367, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5250, + "end_line": 5314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 65, + "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": 5321, + "end_line": 5330, + "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": 5336, + "end_line": 5429, + "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": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5439, + "end_line": 5485, + "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": 5495, + "end_line": 5548, + "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": 114, + "complexity": 33, + "token_count": 676, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5553, + "end_line": 5682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5686, + "end_line": 5794, + "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": 5798, + "end_line": 5838, + "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": 5842, + "end_line": 5980, + "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": 37, + "complexity": 11, + "token_count": 221, + "parameters": [ + "op", + "typecode", + "context" + ], + "start_line": 5984, + "end_line": 6021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "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": 59, + "complexity": 20, + "token_count": 369, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags", + "context" + ], + "start_line": 6027, + "end_line": 6103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "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": 6108, + "end_line": 6111, + "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": 6118, + "end_line": 6131, + "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": 6177, + "end_line": 6193, + "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": 5, + "token_count": 89, + "parameters": [ + "op" + ], + "start_line": 6206, + "end_line": 6222, + "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": 6228, + "end_line": 6316, + "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": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6321, + "end_line": 6349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 6362, + "end_line": 6400, + "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": 6408, + "end_line": 6425, + "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": 6430, + "end_line": 6440, + "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": 6443, + "end_line": 6447, + "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": 16, + "parameters": [ + "self" + ], + "start_line": 6450, + "end_line": 6453, + "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": 6457, + "end_line": 6507, + "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": 6510, + "end_line": 6564, + "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": 6568, + "end_line": 6701, + "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": 6705, + "end_line": 6737, + "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": 6740, + "end_line": 6782, + "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": 6785, + "end_line": 6919, + "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": 6932, + "end_line": 6977, + "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": 6982, + "end_line": 6986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 7055, + "end_line": 7071, + "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": 7078, + "end_line": 7147, + "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": 7151, + "end_line": 7188, + "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": 7194, + "end_line": 7238, + "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": 98, + "complexity": 21, + "token_count": 662, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7256, + "end_line": 7384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "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": 7390, + "end_line": 7462, + "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": 7465, + "end_line": 7591, + "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": 7595, + "end_line": 7604, + "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": 7675, + "end_line": 7724, + "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": 7727, + "end_line": 7772, + "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": 7775, + "end_line": 7794, + "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": 7797, + "end_line": 7804, + "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": 7807, + "end_line": 7817, + "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": 7820, + "end_line": 7830, + "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": 7833, + "end_line": 7836, + "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": 7839, + "end_line": 7851, + "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": 7881, + "end_line": 7888, + "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": 7947, + "end_line": 7956, + "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": 7974, + "end_line": 7996, + "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": 64, + "parameters": [ + "self" + ], + "start_line": 8002, + "end_line": 8012, + "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": 8030, + "end_line": 8038, + "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": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 8041, + "end_line": 8053, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_typename_get", + "long_name": "arraydescr_typename_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 8056, + "end_line": 8078, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 8081, + "end_line": 8100, + "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": 8107, + "end_line": 8114, + "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": 8117, + "end_line": 8124, + "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": 8127, + "end_line": 8134, + "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": 8174, + "end_line": 8226, + "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": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8232, + "end_line": 8289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "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": 8297, + "end_line": 8339, + "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": 8359, + "end_line": 8425, + "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": 8436, + "end_line": 8444, + "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": 8459, + "end_line": 8504, + "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": 8507, + "end_line": 8516, + "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": 8519, + "end_line": 8529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "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": 3332, + "end_line": 3367, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + } + ], + "nloc": 6809, + "complexity": 1460, + "token_count": 40053, + "diff_parsed": { + "added": [ + "#if SIZEOF_LONG >= SIZEOF_INTP", + "#else", + "\t\tif (!(op = PyNumber_Long(seq))) return -1;", + "#endif", + "#if SIZEOF_LONG >= SIZEOF_INTP", + "#else", + "\t\tvals[0] = (intp ) PyLong_AsLongLong(op);", + "#endif", + "#if SIZEOF_LONG >= SIZEOF_INTP", + "#else", + "\t\t\tvals[i]=(intp )PyLong_AsLongLong(op);", + "#endif" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "67e756592f6ebec479e404a104380ca373ad11f1", + "msg": "Add a BSD-type LICENSE.txt file", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-20T23:50:38+00:00", + "author_timezone": 0, + "committer_date": "2006-01-20T23:50:38+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "6b724c9e4798b919858c3a980c3e865eb4a055c1" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 0, + "insertions": 30, + "lines": 30, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": null, + "new_path": "LICENSE.txt", + "filename": "LICENSE.txt", + "extension": "txt", + "change_type": "ADD", + "diff": "@@ -0,0 +1,30 @@\n+Copyright (c) 2005, NumPy Developers\n+All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are\n+met:\n+\n+ * Redistributions of source code must retain the above copyright\n+ notice, this list of conditions and the following disclaimer.\n+\n+ * Redistributions in binary form must reproduce the above\n+ copyright notice, this list of conditions and the following\n+ disclaimer in the documentation and/or other materials provided\n+ with the distribution.\n+\n+ * Neither the name of the NumPy Developers nor the names of any\n+ contributors may be used to endorse or promote products derived\n+ from this software without specific prior written permission.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n", + "added_lines": 30, + "deleted_lines": 0, + "source_code": "Copyright (c) 2005, NumPy Developers\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * Neither the name of the NumPy Developers nor the names of any\n contributors may be used to endorse or promote products derived\n from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "Copyright (c) 2005, NumPy Developers", + "All rights reserved.", + "", + "Redistribution and use in source and binary forms, with or without", + "modification, are permitted provided that the following conditions are", + "met:", + "", + " * Redistributions of source code must retain the above copyright", + " notice, this list of conditions and the following disclaimer.", + "", + " * Redistributions in binary form must reproduce the above", + " copyright notice, this list of conditions and the following", + " disclaimer in the documentation and/or other materials provided", + " with the distribution.", + "", + " * Neither the name of the NumPy Developers nor the names of any", + " contributors may be used to endorse or promote products derived", + " from this software without specific prior written permission.", + "", + "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS", + "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT", + "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR", + "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT", + "OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,", + "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT", + "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,", + "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY", + "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT", + "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE", + "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ], + "deleted": [] + } + } + ] + }, + { + "hash": "d51b059ba26db75b2358a1ee2eafdd2398eecb6a", + "msg": "Fix arange to accept None and treat it as if it hadn't been passed in.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T00:44:05+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T00:44:05+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "67e756592f6ebec479e404a104380ca373ad11f1" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/src/multiarraymodule.c", + "new_path": "numpy/core/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -4993,7 +4993,7 @@ array_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\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_DescrConverter, \n+\t\t\t\t\tPyArray_DescrConverter2,\n \t\t\t\t\t&typecode)) \n \t\treturn NULL;\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\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\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\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 dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) 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.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", 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)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\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\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\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\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "source_code_before": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\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\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\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 dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) 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.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", 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)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\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\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\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\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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_DescrConverter, \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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4389, + "end_line": 4405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4419, + "end_line": 4544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "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": 4562, + "end_line": 4600, + "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": 4604, + "end_line": 4697, + "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": 4713, + "end_line": 4730, + "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": 4736, + "end_line": 4747, + "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": 4754, + "end_line": 4760, + "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": 4767, + "end_line": 4773, + "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": 4777, + "end_line": 4783, + "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": 4787, + "end_line": 4796, + "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": 4803, + "end_line": 4854, + "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": 4860, + "end_line": 4892, + "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": 4899, + "end_line": 4983, + "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": 4989, + "end_line": 5001, + "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": 12, + "parameters": [], + "start_line": 5007, + "end_line": 5010, + "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": 5016, + "end_line": 5022, + "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": 5028, + "end_line": 5044, + "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": 5050, + "end_line": 5067, + "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": 5074, + "end_line": 5114, + "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": 5122, + "end_line": 5130, + "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": 5142, + "end_line": 5152, + "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": 5161, + "end_line": 5172, + "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": 5179, + "end_line": 5202, + "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": 5209, + "end_line": 5217, + "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": 5226, + "end_line": 5244, + "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": 5310, + "end_line": 5423, + "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": 5428, + "end_line": 5452, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5457, + "end_line": 5550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4389, + "end_line": 4405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4419, + "end_line": 4544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "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": 4562, + "end_line": 4600, + "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": 4604, + "end_line": 4697, + "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": 4713, + "end_line": 4730, + "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": 4736, + "end_line": 4747, + "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": 4754, + "end_line": 4760, + "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": 4767, + "end_line": 4773, + "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": 4777, + "end_line": 4783, + "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": 4787, + "end_line": 4796, + "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": 4803, + "end_line": 4854, + "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": 4860, + "end_line": 4892, + "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": 4899, + "end_line": 4983, + "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": 4989, + "end_line": 5001, + "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": 12, + "parameters": [], + "start_line": 5007, + "end_line": 5010, + "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": 5016, + "end_line": 5022, + "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": 5028, + "end_line": 5044, + "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": 5050, + "end_line": 5067, + "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": 5074, + "end_line": 5114, + "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": 5122, + "end_line": 5130, + "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": 5142, + "end_line": 5152, + "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": 5161, + "end_line": 5172, + "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": 5179, + "end_line": 5202, + "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": 5209, + "end_line": 5217, + "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": 5226, + "end_line": 5244, + "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": 5310, + "end_line": 5423, + "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": 5428, + "end_line": 5452, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5457, + "end_line": 5550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "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": 4989, + "end_line": 5001, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 4171, + "complexity": 914, + "token_count": 27241, + "diff_parsed": { + "added": [ + "\t\t\t\t\tPyArray_DescrConverter2," + ], + "deleted": [ + "\t\t\t\t\tPyArray_DescrConverter," + ] + } + } + ] + }, + { + "hash": "e5a5e245f19f3bf6aa606a43e262be5431ade27f", + "msg": "Added ability to read ascii strings in fromstring.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T11:28:34+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T11:28:34+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "d51b059ba26db75b2358a1ee2eafdd2398eecb6a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 33, + "insertions": 190, + "lines": 223, + "files": 3, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.1262135922330097, + "dmm_unit_interfacing": 0.11650485436893204, + "modified_files": [ + { + "old_path": "numpy/core/include/numpy/arrayobject.h", + "new_path": "numpy/core/include/numpy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -783,6 +783,7 @@ typedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp,\n \t\t\t void *);\n typedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\n typedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n+typedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);\n \n typedef int (PyArray_FillFunc)(void *, intp, void *);\n \n@@ -821,7 +822,10 @@ typedef struct {\n \t place a single value plus possible separator */\n \tPyArray_ScanFunc *scanfunc;\n \n-\t\n+\t/* Function to read a single value from a string */\n+\t/* and adjust the pointer */\n+\tPyArray_FromStrFunc *fromstr;\n+\t\t\n \t/* Function to determine if data is zero or not */\n \tPyArray_NonzeroFunc *nonzero;\n \n", + "added_lines": 5, + "deleted_lines": 1, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x00090401\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\ntypedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Function to read a single value from a string */\n\t/* and adjust the pointer */\n\tPyArray_FromStrFunc *fromstr;\n\t\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n#define _PyArray_ITER_NEXT1(it) {\t\t\\\n\t\tit->dataptr += it->strides[0];\t\\\n\t\tit->coordinates[0]++;\t\t\\\n\t}\n\t\n#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n\t\t\tit->coordinates[1]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n\t\t\tit->coordinates[0]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n\t\t\t\tit->backstrides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\t\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x00090401\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n#define _PyArray_ITER_NEXT1(it) {\t\t\\\n\t\tit->dataptr += it->strides[0];\t\\\n\t\tit->coordinates[0]++;\t\t\\\n\t}\n\t\n#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n\t\t\tit->coordinates[1]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n\t\t\tit->coordinates[0]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n\t\t\t\tit->backstrides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\t\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 283, + "complexity": 0, + "token_count": 1328, + "diff_parsed": { + "added": [ + "typedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);", + "\t/* Function to read a single value from a string */", + "\t/* and adjust the pointer */", + "\tPyArray_FromStrFunc *fromstr;", + "" + ], + "deleted": [ + "" + ] + } + }, + { + "old_path": "numpy/core/src/arraytypes.inc.src", + "new_path": "numpy/core/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -752,6 +752,48 @@ static int\n /**end repeat**/\n \n \n+/****************** fromstr *************************************/\n+\n+/**begin repeat\n+#fname=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG#\n+#type=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#\n+#func=(l,ul)*5#\n+#btype=(long,ulong)*5#\n+*/\n+static int\n+@fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)\n+{\n+\t@btype@ result;\n+\n+\tresult = PyOS_strto@func@(str, endptr, 0);\t\n+\t*ip = (@type@) result;\n+\treturn 0;\n+}\n+/**end repeat**/\n+\n+/**begin repeat\n+#fname=FLOAT,DOUBLE,LONGDOUBLE#\n+#type=float,double,longdouble#\n+*/\n+static int\n+@fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)\n+{\n+\tdouble result;\n+\n+\tresult = PyOS_ascii_strtod(str, endptr);\n+\t*ip = (@type@) result;\n+\treturn 0;\n+}\n+/**end repeat**/\n+\n+\n+\n+/**begin repeat\n+#fname=BOOL,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n+*/\n+#define @fname@_fromstr NULL\n+/**end repeat**/\n+\n \n /****************** copyswapn *************************************/\n \n@@ -1660,6 +1702,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n \t(PyArray_ArgFunc*)@from@_argmax,\n \t(PyArray_DotFunc*)NULL, \n \t(PyArray_ScanFunc*)@from@_scan,\n+\t(PyArray_FromStrFunc*)@from@_fromstr,\n \t(PyArray_NonzeroFunc*)@from@_nonzero,\n \t(PyArray_FillFunc*)NULL,\n \t{\n@@ -1728,6 +1771,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n \t(PyArray_ArgFunc*)@from@_argmax,\n \t(PyArray_DotFunc*)@from@_dot, \n \t(PyArray_ScanFunc*)@from@_scan,\n+\t(PyArray_FromStrFunc*)@from@_fromstr,\n \t(PyArray_NonzeroFunc*)@from@_nonzero,\n \t(PyArray_FillFunc*)@from@_fill,\n \t{\n", + "added_lines": 44, + "deleted_lines": 0, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\nstatic double \n_getNAN(void) {\n#ifdef NAN\n return NAN;\n#else\n double mul = 1e100;\n double tmp = 0.0;\n double pinf=0;\n static double nan=0;\n \n if (nan == 0) {\n pinf = mul;\n for (;;) {\n pinf *= mul;\n if (pinf == tmp) break;\n tmp = pinf;\n }\n nan = pinf / pinf;\n }\n return nan;\n#endif\n}\n\nstatic double\nMyPyFloat_AsDouble(PyObject *obj)\n{\n if (obj == Py_None) return _getNAN();\n return PyFloat_AsDouble(obj); \n}\n\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n if (op2 == Py_None) {\n oop.real = oop.imag = _getNAN();\n }\n else {\n oop = PyComplex_AsCComplex (op2);\n }\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n if (op == Py_None) temp = (longdouble)_getNAN();\n else temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_FromStrFunc*)@from@_fromstr,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_FromStrFunc*)@from@_fromstr,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\nstatic double \n_getNAN(void) {\n#ifdef NAN\n return NAN;\n#else\n double mul = 1e100;\n double tmp = 0.0;\n double pinf=0;\n static double nan=0;\n \n if (nan == 0) {\n pinf = mul;\n for (;;) {\n pinf *= mul;\n if (pinf == tmp) break;\n tmp = pinf;\n }\n nan = pinf / pinf;\n }\n return nan;\n#endif\n}\n\nstatic double\nMyPyFloat_AsDouble(PyObject *obj)\n{\n if (obj == Py_None) return _getNAN();\n return PyFloat_AsDouble(obj); \n}\n\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, MyPyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n if (op2 == Py_None) {\n oop.real = oop.imag = _getNAN();\n }\n else {\n oop = PyComplex_AsCComplex (op2);\n }\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n if (op == Py_None) temp = (longdouble)_getNAN();\n else temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING -- can handle both NULL-terminated and not NULL-terminated cases */\nstatic PyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\tif (ip[ap->descr->elsize-1])\n\t\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n\telse\n\t\treturn PyString_FromString(ip);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n\tPyArray_Descr* descr;\n int itemsize;\n\n\tdescr = ap->descr;\n\tif (descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* return an array of the basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn NULL;\n\t\t}\n Py_INCREF(descr->subarray->base);\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return NULL;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\treturn ret;\n\t}\n\n finish:\n\titemsize=ap->descr->elsize;\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n\treturn u; \n\t\n fail:\n return NULL;\n}\n\n\n\nstatic int PyArray_CopyObject(PyArrayObject *, PyObject *);\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n\n\tdescr = ap->descr;\n\tif (descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\tres = -1;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tres = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (res < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn res;\n\t}\n\n\tif (descr->subarray) {\n\t\t/* copy into an array of the same basic type */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyObject *ret;\n\t\tif (!(PyArray_IntpConverter(descr->subarray->shape, \n\t\t\t\t\t &shape))) {\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\treturn -1;\n\t\t}\n\t\tret = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t descr->subarray->base,\n\t\t\t\t\t shape.len, shape.ptr,\n\t\t\t\t\t NULL, ip, ap->flags, NULL);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tif (!ret) return -1;\n\t\tPyArray_BASE(ret) = (PyObject *)ap;\n\t\tPy_INCREF(ap);\n\t\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\t\tres = PyArray_CopyObject((PyArrayObject *)ret, op);\n\t\tPy_DECREF(ret);\n\t\treturn res;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n\t{\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n }\n\treturn 0;\n\n fail:\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n#convert=1*17,0*3,1*17,0*3,0*20#\n#convstr=(Int*9,Long*2,Float*3,Complex*3,Tuple*3)*3#\n*/\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\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\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\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 c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\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 c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\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 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\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize);\n}\n\n/* taken from Python */\nstatic int \nUNICODE_compare(register Py_UNICODE *ip1, register Py_UNICODE *ip2, \n\t\tPyArrayObject *ap)\n{\n register int itemsize=ap->descr->elsize;\n\tregister Py_UNICODE c1, c2;\n\n\tif (itemsize < 0) return 0;\n\t\n\twhile(itemsize-- > 0) {\n\t\tc1 = *ip1++;\n\t\tc2 = *ip2++;\n\t\t\n\t\tif (c1 != c2) \n\t\t\treturn (c1 < c2) ? -1 : 1;\n\t}\n\treturn 0;\n}\n\n/* possibly redefine compare in terms of fields and subarrays if any */\n\n/* as it is, it compares raw-bytes as it they were strings */\n#define VOID_compare STRING_compare\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE#\n#type= char, Py_UNICODE#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\n#define VOID_argmax NULL\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill,\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t},\n\t{\n\t\tNULL, NULL, NULL, NULL\n\t}\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Number)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "/****************** fromstr *************************************/", + "", + "/**begin repeat", + "#fname=BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG#", + "#type=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong#", + "#func=(l,ul)*5#", + "#btype=(long,ulong)*5#", + "*/", + "static int", + "@fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)", + "{", + "\t@btype@ result;", + "", + "\tresult = PyOS_strto@func@(str, endptr, 0);", + "\t*ip = (@type@) result;", + "\treturn 0;", + "}", + "/**end repeat**/", + "", + "/**begin repeat", + "#fname=FLOAT,DOUBLE,LONGDOUBLE#", + "#type=float,double,longdouble#", + "*/", + "static int", + "@fname@_fromstr(char *str, @type@ *ip, char **endptr, void *ignore)", + "{", + "\tdouble result;", + "", + "\tresult = PyOS_ascii_strtod(str, endptr);", + "\t*ip = (@type@) result;", + "\treturn 0;", + "}", + "/**end repeat**/", + "", + "", + "", + "/**begin repeat", + "#fname=BOOL,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#", + "*/", + "#define @fname@_fromstr NULL", + "/**end repeat**/", + "", + "\t(PyArray_FromStrFunc*)@from@_fromstr,", + "\t(PyArray_FromStrFunc*)@from@_fromstr," + ], + "deleted": [] + } + }, + { + "old_path": "numpy/core/src/multiarraymodule.c", + "new_path": "numpy/core/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -4327,59 +4327,164 @@ array_set_typeDict(PyObject *ignored, PyObject *args)\n \treturn Py_None;\n }\n \n+static 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*/\n static PyObject *\n-PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n+PyArray_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-\tif (dtype == &OBJECT_Descr) {\n-\t\tPyErr_SetString(PyExc_ValueError, \n-\t\t\t\t\"Cannot create an object array from a\"\\\n-\t\t\t\t\" string.\");\n-\t\tPy_DECREF(dtype);\n-\t\treturn NULL;\n-\t}\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-\t\n-\tif (n < 0 ) {\n-\t\tif (slen % itemsize != 0) {\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\"string size must be a multiple\"\\\n-\t\t\t\t\t\" of element size\");\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\tn = slen/itemsize;\n-\t} else {\n-\t\tif (slen < n*itemsize) {\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;\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\"string is smaller than requested\"\\\n-\t\t\t\t\t\" size\");\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-\t\n-\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n-\t\t\t\t\t\t\t dtype,\n-\t\t\t\t\t\t\t 1, &n, \n-\t\t\t\t\t\t\t NULL, NULL,\n-\t\t\t\t\t\t\t 0, NULL)) == NULL)\n-\t\treturn NULL;\n-\t\t\n-\tmemcpy(ret->data, data, n*dtype->elsize);\n \treturn (PyObject *)ret;\n }\n \n@@ -4390,18 +4495,19 @@ array_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\", NULL};\n+\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"sep\", NULL};\n \tPyArray_Descr *descr=NULL;\n \n-\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", kwlist, \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)) {\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);\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@@ -4425,6 +4531,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\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@@ -4438,6 +4545,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\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@@ -4463,6 +4571,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\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", + "added_lines": 141, + "deleted_lines": 32, + "source_code": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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;\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) 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.\";\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "source_code_before": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\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\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\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 dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) 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.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", 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)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\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\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\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\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "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": 4331, + "end_line": 4342, + "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": 709, + "parameters": [ + "data", + "slen", + "dtype", + "n", + "sep" + ], + "start_line": 4347, + "end_line": 4489, + "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": 4494, + "end_line": 4511, + "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": 4525, + "end_line": 4653, + "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": 4671, + "end_line": 4709, + "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": 4713, + "end_line": 4806, + "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": 4822, + "end_line": 4839, + "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": 4845, + "end_line": 4856, + "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": 4863, + "end_line": 4869, + "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": 4876, + "end_line": 4882, + "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": 4886, + "end_line": 4892, + "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": 4896, + "end_line": 4905, + "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": 4912, + "end_line": 4963, + "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": 4969, + "end_line": 5001, + "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": 5008, + "end_line": 5092, + "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": 5098, + "end_line": 5110, + "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": 12, + "parameters": [], + "start_line": 5116, + "end_line": 5119, + "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": 5125, + "end_line": 5131, + "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": 5137, + "end_line": 5153, + "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": 5159, + "end_line": 5176, + "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": 5183, + "end_line": 5223, + "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": 5231, + "end_line": 5239, + "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": 5251, + "end_line": 5261, + "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": 5270, + "end_line": 5281, + "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": 5288, + "end_line": 5311, + "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": 5318, + "end_line": 5326, + "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": 5335, + "end_line": 5353, + "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": 5419, + "end_line": 5532, + "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": 5537, + "end_line": 5561, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5566, + "end_line": 5659, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4389, + "end_line": 4405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 4419, + "end_line": 4544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "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": 4562, + "end_line": 4600, + "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": 4604, + "end_line": 4697, + "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": 4713, + "end_line": 4730, + "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": 4736, + "end_line": 4747, + "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": 4754, + "end_line": 4760, + "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": 4767, + "end_line": 4773, + "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": 4777, + "end_line": 4783, + "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": 4787, + "end_line": 4796, + "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": 4803, + "end_line": 4854, + "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": 4860, + "end_line": 4892, + "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": 4899, + "end_line": 4983, + "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": 4989, + "end_line": 5001, + "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": 12, + "parameters": [], + "start_line": 5007, + "end_line": 5010, + "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": 5016, + "end_line": 5022, + "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": 5028, + "end_line": 5044, + "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": 5050, + "end_line": 5067, + "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": 5074, + "end_line": 5114, + "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": 5122, + "end_line": 5130, + "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": 5142, + "end_line": 5152, + "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": 5161, + "end_line": 5172, + "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": 5179, + "end_line": 5202, + "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": 5209, + "end_line": 5217, + "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": 5226, + "end_line": 5244, + "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": 5310, + "end_line": 5423, + "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": 5428, + "end_line": 5452, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5457, + "end_line": 5550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "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": 709, + "parameters": [ + "data", + "slen", + "dtype", + "n", + "sep" + ], + "start_line": 4347, + "end_line": 4489, + "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": 4494, + "end_line": 4511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 4333, + "end_line": 4384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "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": 4331, + "end_line": 4342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "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": 4525, + "end_line": 4653, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + } + ], + "nloc": 4275, + "complexity": 932, + "token_count": 27836, + "diff_parsed": { + "added": [ + "static int", + "_skip_sep(char **ptr, char *sep)", + "{", + "\tchar *a;", + "\tint n;", + "\tn = strlen(sep);", + "\ta = *ptr;", + "\twhile(*a != '\\0' && (strncmp(a, sep, n) != 0))", + "\t\ta++;", + "\tif (*a == '\\0') return -1;", + "\t*ptr = a+strlen(sep);", + "\treturn 0;", + "}", + "", + "PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype,", + "\t\t intp n, char *sep)", + "\tBool binary;", + "", + "\tbinary = ((sep == NULL) || (strlen(sep) == 0));", + "", + "\tif (binary) {", + "\t\tif (dtype == &OBJECT_Descr) {", + "\t\t\t\t\t\"Cannot create an object array from\"\\", + "\t\t\t\t\t\" a binary string\");", + "\t\t}", + "\t\tif (n < 0 ) {", + "\t\t\tif (slen % itemsize != 0) {", + "\t\t\t\tPyErr_SetString(PyExc_ValueError,", + "\t\t\t\t\t\t\"string size must be a \"\\", + "\t\t\t\t\t\t\"multiple of element size\");", + "\t\t\t\tPy_DECREF(dtype);", + "\t\t\t\treturn NULL;", + "\t\t\t}", + "\t\t\tn = slen/itemsize;", + "\t\t} else {", + "\t\t\tif (slen < n*itemsize) {", + "\t\t\t\tPyErr_SetString(PyExc_ValueError,", + "\t\t\t\t\t\t\"string is smaller than \" \\", + "\t\t\t\t\t\t\"requested size\");", + "\t\t\t\tPy_DECREF(dtype);", + "\t\t\t\treturn NULL;", + "\t\t\t}", + "", + "\t\tif ((ret = (PyArrayObject *)\\", + "\t\t PyArray_NewFromDescr(&PyArray_Type, dtype,", + "\t\t\t\t\t 1, &n, NULL, NULL,", + "\t\t\t\t\t 0, NULL)) == NULL)", + "\t\t\treturn NULL;", + "\t\tmemcpy(ret->data, data, n*dtype->elsize);", + "\t\treturn (PyObject *)ret;", + "\t}", + "\telse { /* read from character-based string */", + "\t\tchar *ptr;", + "\t\tPyArray_FromStrFunc *fromstr;", + "\t\tchar *dptr;", + "\t\tintp nread;", + "\t\tintp index;", + "", + "\t\tfromstr = dtype->f->fromstr;", + "\t\tif (fromstr == NULL) {", + "\t\t\t\t\t\"don't know how to read \"\t\\", + "\t\t\t\t\t\"character strings for given \"\t\\", + "\t\t\t\t\t\"array type\");", + "", + "\t\tif (n!=-1) {", + "\t\t\tret = (PyArrayObject *) \\", + "\t\t\t\tPyArray_NewFromDescr(&PyArray_Type,", + "\t\t\t\t\t\t dtype, 1, &n, NULL,", + "\t\t\t\t\t\t NULL, 0, NULL);", + "\t\t\tif (ret == NULL) return NULL;", + "\t\t\tptr = data;", + "\t\t\tdptr = ret->data;", + "\t\t\tfor (index=0; index < n; index++) {", + "\t\t\t\tif (fromstr(ptr, dptr, &ptr, ret) < 0)", + "\t\t\t\t\tbreak;", + "\t\t\t\tnread += 1;", + "\t\t\t\tdptr += dtype->elsize;", + "\t\t\t\tif (_skip_sep(&ptr, sep) < 0)", + "\t\t\t\t\tbreak;", + "\t\t\t}", + "\t\t\tif (nread < n) {", + "\t\t\t\tfprintf(stderr, \"%ld items requested but \"\\", + "\t\t\t\t\t\"only %ld read\\n\",", + "\t\t\t\t\t(long) n, (long) nread);", + "\t\t\t\tret->data = \\", + "\t\t\t\t\tPyDataMem_RENEW(ret->data,", + "\t\t\t\t\t\t\tnread *\t\t\\", + "\t\t\t\t\t\t\tret->descr->elsize);", + "\t\t\t\tPyArray_DIM(ret,0) = nread;", + "\t\t\t}", + "\t\t}", + "\t\telse {", + "#define _FILEBUFNUM 4096", + "\t\t\tintp thisbuf=0;", + "\t\t\tintp size = _FILEBUFNUM;", + "\t\t\tintp bytes;", + "\t\t\tintp totalbytes;", + "\t\t\tchar *end;", + "\t\t\tint val;", + "", + "\t\t\tret = (PyArrayObject *)\\", + "\t\t\t\tPyArray_NewFromDescr(&PyArray_Type,", + "\t\t\t\t\t\t dtype,", + "\t\t\t\t\t\t 1, &size,", + "\t\t\t\t\t\t NULL, NULL,", + "\t\t\t\t\t\t 0, NULL);", + "\t\t\tif (ret==NULL) return NULL;", + "\t\t\ttotalbytes = bytes = size * dtype->elsize;", + "\t\t\tdptr = ret->data;", + "\t\t\tptr = data;", + "\t\t\tend = data+slen;", + "\t\t\twhile (ptr < end) {", + "\t\t\t\tval = fromstr(ptr, dptr, &ptr, ret);", + "\t\t\t\tif (val < 0) break;", + "\t\t\t\tnread += 1;", + "\t\t\t\tval = _skip_sep(&ptr, sep);", + "\t\t\t\tif (val < 0) break;", + "\t\t\t\tthisbuf += 1;", + "\t\t\t\tdptr += dtype->elsize;", + "\t\t\t\tif (thisbuf == size) {", + "\t\t\t\t\ttotalbytes += bytes;", + "\t\t\t\t\tret->data = PyDataMem_RENEW(ret->data,", + "\t\t\t\t\t\t\t\t totalbytes);", + "\t\t\t\t\tdptr = ret->data + \\", + "\t\t\t\t\t\t(totalbytes - bytes);", + "\t\t\t\t\tthisbuf = 0;", + "\t\t\t\t}", + "\t\t\t}", + "\t\t\tret->data = PyDataMem_RENEW(ret->data,", + "\t\t\t\t\t\t nread*ret->descr->elsize);", + "\t\t\tPyArray_DIM(ret,0) = nread;", + "#undef _FILEBUFNUM", + "\t\t}", + "\tchar *sep=NULL;", + "\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", \"sep\", NULL};", + "\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&Ls\", kwlist,", + "\t\t\t\t\t &nin, &sep)) {", + "\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin, sep);", + "\t\tPy_DECREF(typecode);", + "\t\t\tPy_DECREF(typecode);", + "\t\t\tPy_DECREF(typecode);" + ], + "deleted": [ + "PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)", + "\tif (dtype == &OBJECT_Descr) {", + "\t\tPyErr_SetString(PyExc_ValueError,", + "\t\t\t\t\"Cannot create an object array from a\"\\", + "\t\t\t\t\" string.\");", + "\t\tPy_DECREF(dtype);", + "\t\treturn NULL;", + "\t}", + "", + "", + "\tif (n < 0 ) {", + "\t\tif (slen % itemsize != 0) {", + "\t\t\t\t\t\"string size must be a multiple\"\\", + "\t\t\t\t\t\" of element size\");", + "\t\tn = slen/itemsize;", + "\t} else {", + "\t\tif (slen < n*itemsize) {", + "\t\t\t\t\t\"string is smaller than requested\"\\", + "\t\t\t\t\t\" size\");", + "", + "\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type,", + "\t\t\t\t\t\t\t dtype,", + "\t\t\t\t\t\t\t 1, &n,", + "\t\t\t\t\t\t\t NULL, NULL,", + "\t\t\t\t\t\t\t 0, NULL)) == NULL)", + "\t\treturn NULL;", + "", + "\tmemcpy(ret->data, data, n*dtype->elsize);", + "\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};", + "\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", kwlist,", + "\t\t\t\t\t &nin)) {", + "\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);" + ] + } + } + ] + }, + { + "hash": "1b409ce9fe55ebf61eaa5d295753b0b8ad1efcf2", + "msg": "Update C-API version.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T11:29:10+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T11:29:10+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "e5a5e245f19f3bf6aa606a43e262be5431ade27f" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/include/numpy/arrayobject.h", + "new_path": "numpy/core/include/numpy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -74,7 +74,7 @@ extern \"C\" {\n #define PY_SUCCEED 1\n \n \t/* Helpful to distinguish what is installed */\n-#define NDARRAY_VERSION 0x00090401\n+#define NDARRAY_VERSION 0x00090402\n \n \t/* Some platforms don't define bool, long long, or long double.\n \t Handle that here.\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x00090402\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\ntypedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Function to read a single value from a string */\n\t/* and adjust the pointer */\n\tPyArray_FromStrFunc *fromstr;\n\t\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n#define _PyArray_ITER_NEXT1(it) {\t\t\\\n\t\tit->dataptr += it->strides[0];\t\\\n\t\tit->coordinates[0]++;\t\t\\\n\t}\n\t\n#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n\t\t\tit->coordinates[1]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n\t\t\tit->coordinates[0]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n\t\t\t\tit->backstrides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\t\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n/* The array creation itself could have arbitrary dimensions but \n * all the places where static allocation is used would need to\n * be changed to dynamic (including inside of structures) \n */\n\n#define MAX_DIMS 32\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x00090401\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\ntypedef enum {\n\tPyArray_QUICKSORT=0,\n\tPyArray_HEAPSORT=1,\n\tPyArray_MERGESORT=2,\n\tPyArray_TIMSORT=3, /* the sort Python uses -- specialized */\n} PyArray_SORTKIND;\n#define PyArray_NSORTS PyArray_TIMSORT + 1\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n#define SIZEOF_INTP SIZEOF_PY_INTPTR_T\n#define SIZEOF_UINTP SIZEOF_PY_INTPTR_T\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\ntypedef int (PyArray_FromStrFunc)(char *, void *, char **, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef int (PyArray_SortFunc)(void *, intp, void *);\ntypedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Function to read a single value from a string */\n\t/* and adjust the pointer */\n\tPyArray_FromStrFunc *fromstr;\n\t\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\t/* Used for arange */\n\tPyArray_FillFunc *fill;\n\n\t/* Sorting functions */\n\tPyArray_SortFunc *sort[PyArray_NSORTS];\n\tPyArray_ArgSortFunc *argsort[PyArray_NSORTS];\n\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define BEHAVED_NS_FLAGS ALIGNED | WRITEABLE | NOTSWAPPED\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n#define _PyArray_ITER_NEXT1(it) {\t\t\\\n\t\tit->dataptr += it->strides[0];\t\\\n\t\tit->coordinates[0]++;\t\t\\\n\t}\n\t\n#define _PyArray_ITER_NEXT2(it) {\t\t\t\t\t\\\n\t\tif (it->coordinates[1] < it->dims_m1[1]) {\t\t\\\n\t\t\tit->coordinates[1]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->coordinates[1] = 0;\t\t\t\t\\\n\t\t\tit->coordinates[0]++;\t\t\t\t\\\n\t\t\tit->dataptr += it->strides[0] -\t\t\t\\\n\t\t\t\tit->backstrides[1];\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\n\t\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n if (it->nd_m1 == 0) {\t\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT1(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse if (it->contiguous) it->dataptr += it->ao->descr->elsize; \\\n\telse if (it->nd_m1 == 1) {\t\t\t\t\t\\\n\t\t_PyArray_ITER_NEXT2(it);\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n if (it->nd_m1 == 0) { \\\n it->dataptr = it->ao->data + (ind) * \\\n it->strides[0]; \\\n } \\\n else if (it->contiguous) \\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \\\n\t\t\t\t PyArray_CheckScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)\n#define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, NULL)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type), \\\n 0, 0, 0, NULL);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \\\n (((flags) & ENSURECOPY) ? \\\n ((flags) | DEFAULT_FLAGS) : (flags)), NULL) \n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \\\n (((flags) & ENSURECOPY) ? \\\n (flags) | DEFAULT_FLAGS : (flags)), NULL)\n \n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, DEFAULT_FLAGS, NULL)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, BEHAVED_FLAGS | ENSUREARRAY, NULL)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n max_depth, DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \\\n max_depth, ENSURECOPY | DEFAULT_FLAGS | ENSUREARRAY, NULL)\n \n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 283, + "complexity": 0, + "token_count": 1328, + "diff_parsed": { + "added": [ + "#define NDARRAY_VERSION 0x00090402" + ], + "deleted": [ + "#define NDARRAY_VERSION 0x00090401" + ] + } + } + ] + }, + { + "hash": "4072234146d63644ed0e658f685a5575ca051d9d", + "msg": "Fix a few more improper uses of .dtype attribute.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T19:18:18+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T19:18:18+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1b409ce9fe55ebf61eaa5d295753b0b8ad1efcf2" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 3, + "insertions": 3, + "lines": 6, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/core/defchararray.py", + "new_path": "numpy/core/defchararray.py", + "filename": "defchararray.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -93,7 +93,7 @@ def __radd__(self, other):\n def __mul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n- if not issubclass(arr.dtype, integer):\n+ if not issubclass(arr.dtype.type, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_)\n@@ -105,7 +105,7 @@ def __mul__(self, other):\n def __rmul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n- if not issubclass(arr.dtype, integer):\n+ if not issubclass(arr.dtype.type, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_) \n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "from numerictypes import character, string, unicode_, \\\n integer, object_\nfrom numeric import ndarray, broadcast, empty\nfrom numeric import array as narray\nimport sys\n\n__all__ = ['chararray']\n\n_globalvar = 0\n_unicode = unicode\n\n# special sub-class for character arrays (string and unicode_)\n# This adds equality testing and methods of str and unicode types\n# which operate on an element-by-element basis\n\n\nclass chararray(ndarray):\n def __new__(subtype, shape, itemsize=1, unicode=False, buffer=None,\n offset=0, strides=None, fortran=0):\n global _globalvar\n\n if unicode:\n dtype = unicode_\n else:\n dtype = string\n\n _globalvar = 1\n if buffer is None:\n self = ndarray.__new__(subtype, shape, (dtype, itemsize),\n fortran=fortran)\n else:\n self = ndarray.__new__(subtype, shape, (dtype, itemsize),\n buffer=buffer,\n offset=offset, strides=strides,\n fortran=fortran)\n _globalvar = 0\n return self\n\n def __array_finalize__(self, obj):\n if not _globalvar and self.dtype.char not in 'SU':\n raise ValueError, \"Can only create a chararray from string data.\"\n \n\n def _richcmpfunc(self, other, op):\n b = broadcast(self, other)\n result = empty(b.shape, dtype=bool)\n res = result.flat\n for k, val in enumerate(b):\n r1 = val[0].rstrip('\\x00')\n\t r2 = val[1]\n\t res[k] = eval(\"r1 %s r2\" % op, {'r1':r1,'r2':r2})\n return result\n \n # these should probably be moved to C\n def __eq__(self, other):\n return self._richcmpfunc(other, '==')\n\n def __ne__(self, other):\n return self._richcmpfunc(other, '!=')\n\n def __ge__(self, other):\n return self._richcmpfunc(other, '>=')\n\n def __le__(self, other):\n return self._richcmpfunc(other, '<=')\n\n def __gt__(self, other):\n return self._richcmpfunc(other, '>')\n \n def __lt__(self, other):\n return self._richcmpfunc(other, '<')\n \n def __add__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n outitem = self.itemsize + arr.itemsize\n result = chararray(b.shape, outitem, self.dtype is unicode_)\n res = result.flat\n for k, val in enumerate(b):\n res[k] = (val[0] + val[1])\n return result \n\n def __radd__(self, other):\n b = broadcast(other, self)\n outitem = b.iters[0].base.itemsize + \\\n b.iters[1].base.itemsize\n result = chararray(b.shape, outitem, self.dtype is unicode_) \n res = result.flat\n for k, val in enumerate(b):\n res[k] = (val[0] + val[1])\n return result \n\n def __mul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n if not issubclass(arr.dtype.type, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_)\n res = result.flat\n for k, val in enumerate(b):\n res[k] = val[0]*val[1]\n return result\n\n def __rmul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n if not issubclass(arr.dtype.type, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_) \n res = result.flat\n for k, val in enumerate(b):\n res[k] = val[0]*val[1]\n return result\n\n def __mod__(self, other):\n b = broadcast(self, other)\n res = [None]*b.size\n maxsize = -1\n for k,val in enumerate(b):\n newval = val[0] % val[1]\n maxsize = max(len(newval), maxsize)\n res[k] = newval\n newarr = chararray(b.shape, maxsize, self.dtype is unicode_)\n newarr[:] = res\n return newarr\n \n def __rmod__(self, other):\n return NotImplemented\n\n def _generalmethod(self, name, myiter):\n res = [None]*myiter.size\n maxsize = -1\n for k, val in enumerate(myiter):\n newval = []\n for chk in val[1:]:\n if chk.dtype is object_ and chk.item() is None:\n break\n newval.append(chk)\n newitem = getattr(val[0],name)(*newval)\n maxsize = max(len(newitem), maxsize)\n res[k] = newitem\n newarr = chararray(myiter.shape, maxsize, self.dtype is unicode_)\n\tprint res, maxsize\n newarr[:] = res\n return newarr\n\n def _typedmethod(self, name, myiter, dtype):\n result = empty(myiter.shape, dtype=dtype)\n res = result.flat\n for k, val in enumerate(myiter):\n newval = []\n for chk in val[1:]:\n if chk.dtype is object_ and chk.item() is None:\n break\n newval.append(chk)\n this_str = val[0].rstrip('\\x00')\n newitem = getattr(this_str,name)(*newval)\n res[k] = newitem\n return result\n\n def _samemethod(self, name):\n result = self.copy()\n res = result.flat\n for k, val in enumerate(self.flat):\n res[k] = getattr(val, name)()\n return result\n\n def capitalize(self):\n return self._samemethod('capitalize')\n\n if sys.version[:3] >= '2.4':\n def center(self, width, fillchar=' '):\n return self._generalmethod('center',\n broadcast(self, width, fillchar))\n def ljust(self, width, fillchar=' '):\n return self._generalmethod('ljust',\n broadcast(self, width, fillchar))\n def rjust(self, width, fillchar=' '):\n return self._generalmethod('rjust',\n broadcast(self, width, fillchar))\n def rsplit(self, sep=None, maxsplit=None):\n return self._typedmethod('rsplit', broadcast(self, sep, maxsplit),\n object)\n else:\n def ljust(self, width):\n return self._generalmethod('ljust', broadcast(self, width))\n def rjust(self, width):\n return self._generalmethod('rjust', broadcast(self, width)) \n def center(self, width):\n return self._generalmethod('center', broadcast(self, width)) \n\n def count(self, sub, start=None, end=None):\n return self._typedmethod('count', broadcast(self, sub, start, end), int)\n\n def decode(self,encoding=None,errors=None):\n return self._generalmethod('decode', broadcast(self, encoding, errors))\n \n def encode(self,encoding=None,errors=None):\n return self._generalmethod('encode', broadcast(self, encoding, errors))\n \n def endswith(self, suffix, start=None, end=None):\n return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)\n \n def expandtabs(self, tabsize=None):\n return self._generalmethod('endswith', broadcast(self, tabsize))\n\n def find(self, sub, start=None, end=None):\n return self._typedmethod('find', broadcast(self, sub, start, end), int)\n\n def index(self, sub, start=None, end=None):\n return self._typedmethod('index', broadcast(self, sub, start, end), int)\n\n def _ismethod(self, name): \n result = empty(self.shape, dtype=bool)\n res = result.flat\n for k, val in enumerate(self.flat):\n item = val.rstrip('\\x00')\n res[k] = getattr(item, name)()\n return result\n\n def isalnum(self):\n return self._ismethod('isalnum')\n\n def isalpha(self):\n return self._ismethod('isalpha')\n\n def isdigit(self):\n return self._ismethod('isdigit')\n\n def islower(self):\n return self._ismethod('islower')\n \n def isspace(self):\n return self._ismethod('isspace')\n\n def istitle(self):\n return self._ismethod('istitle')\n\n def isupper(self):\n return self._ismethod('isupper')\n\n def join(self, seq):\n return self._generalmethod('join', broadcast(self, seq))\n \n def lower(self):\n return self._samemethod('lower')\n\n def lstrip(self, chars):\n return self._generalmethod('lstrip', broadcast(self, chars))\n\n def replace(self, old, new, count=None):\n return self._generalmethod('replace', broadcast(self, old, new, count))\n\n def rfind(self, sub, start=None, end=None):\n return self._typedmethod('rfind', broadcast(self, sub, start, end), int) \n\n def rindex(self, sub, start=None, end=None):\n return self._typedmethod('rindex', broadcast(self, sub, start, end), int)\n\n def rstrip(self, chars=None):\n return self._generalmethod('rstrip', broadcast(self, chars)) \n\n def split(self, sep=None, maxsplit=None):\n return self._typedmethod('split', broadcast(self, sep, maxsplit), object)\n\n def splitlines(self, keepends=None):\n return self._typedmethod('splitlines', broadcast(self, keepends), object)\n \n def startswith(self, prefix, start=None, end=None):\n return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)\n\n def strip(self, chars=None):\n return self._generalmethod('strip', broadcast(self, chars)) \n\n def swapcase(self):\n return self._samemethod('swapcase')\n\n def title(self):\n return self._samemethod('title')\n\n def translate(self, table, deletechars=None):\n if self.dtype is unicode_:\n return self._generalmethod('translate', broadcast(self, table))\n else:\n return self._generalmethod('translate', broadcast(self, table, deletechars))\n \n def upper(self):\n return self._samemethod('upper')\n\n def zfill(self, width):\n return self._generalmethod('zfill', broadcast(self, width))\n\n \ndef array(obj, itemsize=None, copy=True, unicode=False, fortran=False):\n \n if isinstance(obj, chararray):\n if itemsize is None:\n itemsize = obj.itemsize\n if copy or (itemsize != obj.itemsize) \\\n or (not unicode and obj.dtype == unicode_) \\\n or (unicode and obj.dtype == string):\n return obj.astype(\"%s%d\" % (obj.dtype.char, itemsize))\n else:\n return obj\n\n if isinstance(obj, ndarray) and (obj.dtype in [unicode_, string]):\n new = obj.view(chararray)\n if unicode and obj.dtype == string:\n return new.astype((unicode_, obj.itemsize))\n elif obj.dtype == unicode_:\n return new.astype((string, obj.itemsize))\n\n if copy: return new.copy()\n else: return new\n \n if unicode: dtype = \"U\"\n else: dtype = \"S\"\n\n if itemsize is not None:\n dtype += str(itemsize)\n\n if isinstance(obj, (str, _unicode)):\n if itemsize is None:\n itemsize = len(obj)\n shape = len(obj) / itemsize \n return chararray(shape, itemsize=itemsize, unicode=unicode,\n buffer=obj)\n\n # default \n val = narray(obj, dtype=dtype, fortran=fortran, subok=1)\n \n return val.view(chararray)\n\ndef asarray(obj, itemsize=None, unicode=False, fortran=False):\n return array(obj, itemsize, copy=False,\n unicode=unicode, fortran=fortran)\n", + "source_code_before": "from numerictypes import character, string, unicode_, \\\n integer, object_\nfrom numeric import ndarray, broadcast, empty\nfrom numeric import array as narray\nimport sys\n\n__all__ = ['chararray']\n\n_globalvar = 0\n_unicode = unicode\n\n# special sub-class for character arrays (string and unicode_)\n# This adds equality testing and methods of str and unicode types\n# which operate on an element-by-element basis\n\n\nclass chararray(ndarray):\n def __new__(subtype, shape, itemsize=1, unicode=False, buffer=None,\n offset=0, strides=None, fortran=0):\n global _globalvar\n\n if unicode:\n dtype = unicode_\n else:\n dtype = string\n\n _globalvar = 1\n if buffer is None:\n self = ndarray.__new__(subtype, shape, (dtype, itemsize),\n fortran=fortran)\n else:\n self = ndarray.__new__(subtype, shape, (dtype, itemsize),\n buffer=buffer,\n offset=offset, strides=strides,\n fortran=fortran)\n _globalvar = 0\n return self\n\n def __array_finalize__(self, obj):\n if not _globalvar and self.dtype.char not in 'SU':\n raise ValueError, \"Can only create a chararray from string data.\"\n \n\n def _richcmpfunc(self, other, op):\n b = broadcast(self, other)\n result = empty(b.shape, dtype=bool)\n res = result.flat\n for k, val in enumerate(b):\n r1 = val[0].rstrip('\\x00')\n\t r2 = val[1]\n\t res[k] = eval(\"r1 %s r2\" % op, {'r1':r1,'r2':r2})\n return result\n \n # these should probably be moved to C\n def __eq__(self, other):\n return self._richcmpfunc(other, '==')\n\n def __ne__(self, other):\n return self._richcmpfunc(other, '!=')\n\n def __ge__(self, other):\n return self._richcmpfunc(other, '>=')\n\n def __le__(self, other):\n return self._richcmpfunc(other, '<=')\n\n def __gt__(self, other):\n return self._richcmpfunc(other, '>')\n \n def __lt__(self, other):\n return self._richcmpfunc(other, '<')\n \n def __add__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n outitem = self.itemsize + arr.itemsize\n result = chararray(b.shape, outitem, self.dtype is unicode_)\n res = result.flat\n for k, val in enumerate(b):\n res[k] = (val[0] + val[1])\n return result \n\n def __radd__(self, other):\n b = broadcast(other, self)\n outitem = b.iters[0].base.itemsize + \\\n b.iters[1].base.itemsize\n result = chararray(b.shape, outitem, self.dtype is unicode_) \n res = result.flat\n for k, val in enumerate(b):\n res[k] = (val[0] + val[1])\n return result \n\n def __mul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n if not issubclass(arr.dtype, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_)\n res = result.flat\n for k, val in enumerate(b):\n res[k] = val[0]*val[1]\n return result\n\n def __rmul__(self, other):\n b = broadcast(self, other)\n arr = b.iters[1].base\n if not issubclass(arr.dtype, integer):\n raise ValueError, \"Can only multiply by integers\"\n outitem = b.iters[0].base.itemsize * arr.max()\n result = chararray(b.shape, outitem, self.dtype is unicode_) \n res = result.flat\n for k, val in enumerate(b):\n res[k] = val[0]*val[1]\n return result\n\n def __mod__(self, other):\n b = broadcast(self, other)\n res = [None]*b.size\n maxsize = -1\n for k,val in enumerate(b):\n newval = val[0] % val[1]\n maxsize = max(len(newval), maxsize)\n res[k] = newval\n newarr = chararray(b.shape, maxsize, self.dtype is unicode_)\n newarr[:] = res\n return newarr\n \n def __rmod__(self, other):\n return NotImplemented\n\n def _generalmethod(self, name, myiter):\n res = [None]*myiter.size\n maxsize = -1\n for k, val in enumerate(myiter):\n newval = []\n for chk in val[1:]:\n if chk.dtype is object_ and chk.item() is None:\n break\n newval.append(chk)\n newitem = getattr(val[0],name)(*newval)\n maxsize = max(len(newitem), maxsize)\n res[k] = newitem\n newarr = chararray(myiter.shape, maxsize, self.dtype is unicode_)\n\tprint res, maxsize\n newarr[:] = res\n return newarr\n\n def _typedmethod(self, name, myiter, dtype):\n result = empty(myiter.shape, dtype=dtype)\n res = result.flat\n for k, val in enumerate(myiter):\n newval = []\n for chk in val[1:]:\n if chk.dtype is object_ and chk.item() is None:\n break\n newval.append(chk)\n this_str = val[0].rstrip('\\x00')\n newitem = getattr(this_str,name)(*newval)\n res[k] = newitem\n return result\n\n def _samemethod(self, name):\n result = self.copy()\n res = result.flat\n for k, val in enumerate(self.flat):\n res[k] = getattr(val, name)()\n return result\n\n def capitalize(self):\n return self._samemethod('capitalize')\n\n if sys.version[:3] >= '2.4':\n def center(self, width, fillchar=' '):\n return self._generalmethod('center',\n broadcast(self, width, fillchar))\n def ljust(self, width, fillchar=' '):\n return self._generalmethod('ljust',\n broadcast(self, width, fillchar))\n def rjust(self, width, fillchar=' '):\n return self._generalmethod('rjust',\n broadcast(self, width, fillchar))\n def rsplit(self, sep=None, maxsplit=None):\n return self._typedmethod('rsplit', broadcast(self, sep, maxsplit),\n object)\n else:\n def ljust(self, width):\n return self._generalmethod('ljust', broadcast(self, width))\n def rjust(self, width):\n return self._generalmethod('rjust', broadcast(self, width)) \n def center(self, width):\n return self._generalmethod('center', broadcast(self, width)) \n\n def count(self, sub, start=None, end=None):\n return self._typedmethod('count', broadcast(self, sub, start, end), int)\n\n def decode(self,encoding=None,errors=None):\n return self._generalmethod('decode', broadcast(self, encoding, errors))\n \n def encode(self,encoding=None,errors=None):\n return self._generalmethod('encode', broadcast(self, encoding, errors))\n \n def endswith(self, suffix, start=None, end=None):\n return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)\n \n def expandtabs(self, tabsize=None):\n return self._generalmethod('endswith', broadcast(self, tabsize))\n\n def find(self, sub, start=None, end=None):\n return self._typedmethod('find', broadcast(self, sub, start, end), int)\n\n def index(self, sub, start=None, end=None):\n return self._typedmethod('index', broadcast(self, sub, start, end), int)\n\n def _ismethod(self, name): \n result = empty(self.shape, dtype=bool)\n res = result.flat\n for k, val in enumerate(self.flat):\n item = val.rstrip('\\x00')\n res[k] = getattr(item, name)()\n return result\n\n def isalnum(self):\n return self._ismethod('isalnum')\n\n def isalpha(self):\n return self._ismethod('isalpha')\n\n def isdigit(self):\n return self._ismethod('isdigit')\n\n def islower(self):\n return self._ismethod('islower')\n \n def isspace(self):\n return self._ismethod('isspace')\n\n def istitle(self):\n return self._ismethod('istitle')\n\n def isupper(self):\n return self._ismethod('isupper')\n\n def join(self, seq):\n return self._generalmethod('join', broadcast(self, seq))\n \n def lower(self):\n return self._samemethod('lower')\n\n def lstrip(self, chars):\n return self._generalmethod('lstrip', broadcast(self, chars))\n\n def replace(self, old, new, count=None):\n return self._generalmethod('replace', broadcast(self, old, new, count))\n\n def rfind(self, sub, start=None, end=None):\n return self._typedmethod('rfind', broadcast(self, sub, start, end), int) \n\n def rindex(self, sub, start=None, end=None):\n return self._typedmethod('rindex', broadcast(self, sub, start, end), int)\n\n def rstrip(self, chars=None):\n return self._generalmethod('rstrip', broadcast(self, chars)) \n\n def split(self, sep=None, maxsplit=None):\n return self._typedmethod('split', broadcast(self, sep, maxsplit), object)\n\n def splitlines(self, keepends=None):\n return self._typedmethod('splitlines', broadcast(self, keepends), object)\n \n def startswith(self, prefix, start=None, end=None):\n return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)\n\n def strip(self, chars=None):\n return self._generalmethod('strip', broadcast(self, chars)) \n\n def swapcase(self):\n return self._samemethod('swapcase')\n\n def title(self):\n return self._samemethod('title')\n\n def translate(self, table, deletechars=None):\n if self.dtype is unicode_:\n return self._generalmethod('translate', broadcast(self, table))\n else:\n return self._generalmethod('translate', broadcast(self, table, deletechars))\n \n def upper(self):\n return self._samemethod('upper')\n\n def zfill(self, width):\n return self._generalmethod('zfill', broadcast(self, width))\n\n \ndef array(obj, itemsize=None, copy=True, unicode=False, fortran=False):\n \n if isinstance(obj, chararray):\n if itemsize is None:\n itemsize = obj.itemsize\n if copy or (itemsize != obj.itemsize) \\\n or (not unicode and obj.dtype == unicode_) \\\n or (unicode and obj.dtype == string):\n return obj.astype(\"%s%d\" % (obj.dtype.char, itemsize))\n else:\n return obj\n\n if isinstance(obj, ndarray) and (obj.dtype in [unicode_, string]):\n new = obj.view(chararray)\n if unicode and obj.dtype == string:\n return new.astype((unicode_, obj.itemsize))\n elif obj.dtype == unicode_:\n return new.astype((string, obj.itemsize))\n\n if copy: return new.copy()\n else: return new\n \n if unicode: dtype = \"U\"\n else: dtype = \"S\"\n\n if itemsize is not None:\n dtype += str(itemsize)\n\n if isinstance(obj, (str, _unicode)):\n if itemsize is None:\n itemsize = len(obj)\n shape = len(obj) / itemsize \n return chararray(shape, itemsize=itemsize, unicode=unicode,\n buffer=obj)\n\n # default \n val = narray(obj, dtype=dtype, fortran=fortran, subok=1)\n \n return val.view(chararray)\n\ndef asarray(obj, itemsize=None, unicode=False, fortran=False):\n return array(obj, itemsize, copy=False,\n unicode=unicode, fortran=fortran)\n", + "methods": [ + { + "name": "__new__", + "long_name": "__new__( subtype , shape , itemsize = 1 , unicode = False , buffer = None , offset = 0 , strides = None , fortran = 0 )", + "filename": "defchararray.py", + "nloc": 18, + "complexity": 3, + "token_count": 111, + "parameters": [ + "subtype", + "shape", + "itemsize", + "unicode", + "buffer", + "offset", + "strides", + "fortran" + ], + "start_line": 18, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array_finalize__", + "long_name": "__array_finalize__( self , obj )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 3, + "token_count": 24, + "parameters": [ + "self", + "obj" + ], + "start_line": 39, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_richcmpfunc", + "long_name": "_richcmpfunc( self , other , op )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "other", + "op" + ], + "start_line": 44, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 55, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 58, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 64, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 67, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 70, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 83, + "parameters": [ + "self", + "other" + ], + "start_line": 73, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 88, + "parameters": [ + "self", + "other" + ], + "start_line": 83, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 107, + "parameters": [ + "self", + "other" + ], + "start_line": 93, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 107, + "parameters": [ + "self", + "other" + ], + "start_line": 105, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 2, + "token_count": 90, + "parameters": [ + "self", + "other" + ], + "start_line": 117, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 129, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_generalmethod", + "long_name": "_generalmethod( self , name , myiter )", + "filename": "defchararray.py", + "nloc": 16, + "complexity": 5, + "token_count": 127, + "parameters": [ + "self", + "name", + "myiter" + ], + "start_line": 132, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "_typedmethod", + "long_name": "_typedmethod( self , name , myiter , dtype )", + "filename": "defchararray.py", + "nloc": 13, + "complexity": 5, + "token_count": 104, + "parameters": [ + "self", + "name", + "myiter", + "dtype" + ], + "start_line": 149, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_samemethod", + "long_name": "_samemethod( self , name )", + "filename": "defchararray.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "name" + ], + "start_line": 163, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "capitalize", + "long_name": "capitalize( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 170, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "center", + "long_name": "center( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 174, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "ljust", + "long_name": "ljust( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 177, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "rjust", + "long_name": "rjust( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 180, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "rsplit", + "long_name": "rsplit( self , sep = None , maxsplit = None )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "sep", + "maxsplit" + ], + "start_line": 183, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "ljust", + "long_name": "ljust( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "rjust", + "long_name": "rjust( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "center", + "long_name": "center( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 191, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "count", + "long_name": "count( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 194, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "decode", + "long_name": "decode( self , encoding = None , errors = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "encoding", + "errors" + ], + "start_line": 197, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "encode", + "long_name": "encode( self , encoding = None , errors = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "encoding", + "errors" + ], + "start_line": 200, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "endswith", + "long_name": "endswith( self , suffix , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "suffix", + "start", + "end" + ], + "start_line": 203, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "expandtabs", + "long_name": "expandtabs( self , tabsize = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "tabsize" + ], + "start_line": 206, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "find", + "long_name": "find( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 209, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "index", + "long_name": "index( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 212, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_ismethod", + "long_name": "_ismethod( self , name )", + "filename": "defchararray.py", + "nloc": 7, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self", + "name" + ], + "start_line": 215, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "isalnum", + "long_name": "isalnum( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "isalpha", + "long_name": "isalpha( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "isdigit", + "long_name": "isdigit( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "islower", + "long_name": "islower( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "isspace", + "long_name": "isspace( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 235, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "istitle", + "long_name": "istitle( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 238, + "end_line": 239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "isupper", + "long_name": "isupper( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "join", + "long_name": "join( self , seq )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "seq" + ], + "start_line": 244, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "lower", + "long_name": "lower( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "lstrip", + "long_name": "lstrip( self , chars )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "chars" + ], + "start_line": 250, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "replace", + "long_name": "replace( self , old , new , count = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "old", + "new", + "count" + ], + "start_line": 253, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rfind", + "long_name": "rfind( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 256, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rindex", + "long_name": "rindex( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 259, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rstrip", + "long_name": "rstrip( self , chars = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "chars" + ], + "start_line": 262, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "split", + "long_name": "split( self , sep = None , maxsplit = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "sep", + "maxsplit" + ], + "start_line": 265, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "splitlines", + "long_name": "splitlines( self , keepends = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "keepends" + ], + "start_line": 268, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "startswith", + "long_name": "startswith( self , prefix , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "prefix", + "start", + "end" + ], + "start_line": 271, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "strip", + "long_name": "strip( self , chars = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "chars" + ], + "start_line": 274, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "swapcase", + "long_name": "swapcase( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "title", + "long_name": "title( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 280, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "translate", + "long_name": "translate( self , table , deletechars = None )", + "filename": "defchararray.py", + "nloc": 5, + "complexity": 2, + "token_count": 50, + "parameters": [ + "self", + "table", + "deletechars" + ], + "start_line": 283, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "upper", + "long_name": "upper( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "zfill", + "long_name": "zfill( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 292, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "array", + "long_name": "array( obj , itemsize = None , copy = True , unicode = False , fortran = False )", + "filename": "defchararray.py", + "nloc": 30, + "complexity": 19, + "token_count": 273, + "parameters": [ + "obj", + "itemsize", + "copy", + "unicode", + "fortran" + ], + "start_line": 296, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( obj , itemsize = None , unicode = False , fortran = False )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "obj", + "itemsize", + "unicode", + "fortran" + ], + "start_line": 336, + "end_line": 338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__new__", + "long_name": "__new__( subtype , shape , itemsize = 1 , unicode = False , buffer = None , offset = 0 , strides = None , fortran = 0 )", + "filename": "defchararray.py", + "nloc": 18, + "complexity": 3, + "token_count": 111, + "parameters": [ + "subtype", + "shape", + "itemsize", + "unicode", + "buffer", + "offset", + "strides", + "fortran" + ], + "start_line": 18, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array_finalize__", + "long_name": "__array_finalize__( self , obj )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 3, + "token_count": 24, + "parameters": [ + "self", + "obj" + ], + "start_line": 39, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_richcmpfunc", + "long_name": "_richcmpfunc( self , other , op )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "other", + "op" + ], + "start_line": 44, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__eq__", + "long_name": "__eq__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 55, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ne__", + "long_name": "__ne__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 58, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__ge__", + "long_name": "__ge__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__le__", + "long_name": "__le__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 64, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__gt__", + "long_name": "__gt__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 67, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__lt__", + "long_name": "__lt__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "other" + ], + "start_line": 70, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 83, + "parameters": [ + "self", + "other" + ], + "start_line": 73, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "defchararray.py", + "nloc": 9, + "complexity": 2, + "token_count": 88, + "parameters": [ + "self", + "other" + ], + "start_line": 83, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 105, + "parameters": [ + "self", + "other" + ], + "start_line": 93, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 105, + "parameters": [ + "self", + "other" + ], + "start_line": 105, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__mod__", + "long_name": "__mod__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 2, + "token_count": 90, + "parameters": [ + "self", + "other" + ], + "start_line": 117, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__rmod__", + "long_name": "__rmod__( self , other )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 129, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_generalmethod", + "long_name": "_generalmethod( self , name , myiter )", + "filename": "defchararray.py", + "nloc": 16, + "complexity": 5, + "token_count": 127, + "parameters": [ + "self", + "name", + "myiter" + ], + "start_line": 132, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "_typedmethod", + "long_name": "_typedmethod( self , name , myiter , dtype )", + "filename": "defchararray.py", + "nloc": 13, + "complexity": 5, + "token_count": 104, + "parameters": [ + "self", + "name", + "myiter", + "dtype" + ], + "start_line": 149, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_samemethod", + "long_name": "_samemethod( self , name )", + "filename": "defchararray.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "name" + ], + "start_line": 163, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "capitalize", + "long_name": "capitalize( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 170, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "center", + "long_name": "center( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 174, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "ljust", + "long_name": "ljust( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 177, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "rjust", + "long_name": "rjust( self , width , fillchar = ' ' )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "width", + "fillchar" + ], + "start_line": 180, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "rsplit", + "long_name": "rsplit( self , sep = None , maxsplit = None )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "sep", + "maxsplit" + ], + "start_line": 183, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "ljust", + "long_name": "ljust( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "rjust", + "long_name": "rjust( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "center", + "long_name": "center( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 191, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "count", + "long_name": "count( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 194, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "decode", + "long_name": "decode( self , encoding = None , errors = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "encoding", + "errors" + ], + "start_line": 197, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "encode", + "long_name": "encode( self , encoding = None , errors = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "encoding", + "errors" + ], + "start_line": 200, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "endswith", + "long_name": "endswith( self , suffix , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "suffix", + "start", + "end" + ], + "start_line": 203, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "expandtabs", + "long_name": "expandtabs( self , tabsize = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "tabsize" + ], + "start_line": 206, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "find", + "long_name": "find( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 209, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "index", + "long_name": "index( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 212, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_ismethod", + "long_name": "_ismethod( self , name )", + "filename": "defchararray.py", + "nloc": 7, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self", + "name" + ], + "start_line": 215, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "isalnum", + "long_name": "isalnum( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "isalpha", + "long_name": "isalpha( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "isdigit", + "long_name": "isdigit( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "islower", + "long_name": "islower( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "isspace", + "long_name": "isspace( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 235, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "istitle", + "long_name": "istitle( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 238, + "end_line": 239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "isupper", + "long_name": "isupper( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "join", + "long_name": "join( self , seq )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "seq" + ], + "start_line": 244, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "lower", + "long_name": "lower( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "lstrip", + "long_name": "lstrip( self , chars )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "chars" + ], + "start_line": 250, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "replace", + "long_name": "replace( self , old , new , count = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "old", + "new", + "count" + ], + "start_line": 253, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rfind", + "long_name": "rfind( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 256, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rindex", + "long_name": "rindex( self , sub , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "sub", + "start", + "end" + ], + "start_line": 259, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "rstrip", + "long_name": "rstrip( self , chars = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "chars" + ], + "start_line": 262, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "split", + "long_name": "split( self , sep = None , maxsplit = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self", + "sep", + "maxsplit" + ], + "start_line": 265, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "splitlines", + "long_name": "splitlines( self , keepends = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "keepends" + ], + "start_line": 268, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "startswith", + "long_name": "startswith( self , prefix , start = None , end = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "prefix", + "start", + "end" + ], + "start_line": 271, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "strip", + "long_name": "strip( self , chars = None )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "chars" + ], + "start_line": 274, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "swapcase", + "long_name": "swapcase( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "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": "title", + "long_name": "title( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 280, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "translate", + "long_name": "translate( self , table , deletechars = None )", + "filename": "defchararray.py", + "nloc": 5, + "complexity": 2, + "token_count": 50, + "parameters": [ + "self", + "table", + "deletechars" + ], + "start_line": 283, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "upper", + "long_name": "upper( self )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "zfill", + "long_name": "zfill( self , width )", + "filename": "defchararray.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "width" + ], + "start_line": 292, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "array", + "long_name": "array( obj , itemsize = None , copy = True , unicode = False , fortran = False )", + "filename": "defchararray.py", + "nloc": 30, + "complexity": 19, + "token_count": 273, + "parameters": [ + "obj", + "itemsize", + "copy", + "unicode", + "fortran" + ], + "start_line": 296, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "asarray", + "long_name": "asarray( obj , itemsize = None , unicode = False , fortran = False )", + "filename": "defchararray.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "obj", + "itemsize", + "unicode", + "fortran" + ], + "start_line": 336, + "end_line": 338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 107, + "parameters": [ + "self", + "other" + ], + "start_line": 105, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "defchararray.py", + "nloc": 11, + "complexity": 3, + "token_count": 107, + "parameters": [ + "self", + "other" + ], + "start_line": 93, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + } + ], + "nloc": 264, + "complexity": 100, + "token_count": 2453, + "diff_parsed": { + "added": [ + " if not issubclass(arr.dtype.type, integer):", + " if not issubclass(arr.dtype.type, integer):" + ], + "deleted": [ + " if not issubclass(arr.dtype, integer):", + " if not issubclass(arr.dtype, integer):" + ] + } + }, + { + "old_path": "numpy/linalg/linalg.py", + "new_path": "numpy/linalg/linalg.py", + "filename": "linalg.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -208,7 +208,7 @@ def Heigenvalues(a, UPLO='L'):\n return w\n \n def _convertarray(a):\n- if issubclass(a.dtype, complexfloating):\n+ if issubclass(a.dtype.type, complexfloating):\n if a.dtype.char == 'D':\n a = _fastCT(a)\n else:\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"Lite version of numpy.linalg.\n\"\"\"\n# This module is a lite version of LinAlg.py module which contains\n# high-level Python interface to the LAPACK library. The lite version\n# only accesses the following LAPACK functions: dgesv, zgesv, dgeev,\n# zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf.\n\n__all__ = ['LinAlgError', 'solve_linear_equations', 'solve',\n 'inverse', 'inv', 'cholesky_decomposition', 'cholesky', 'eigenvalues',\n 'eigvals', 'Heigenvalues', 'eigvalsh', 'generalized_inverse', 'pinv',\n 'determinant', 'det', 'singular_value_decomposition', 'svd',\n 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares'\n ]\n \nfrom numpy import *\nimport lapack_lite\nimport math\n\n# Error object\nclass LinAlgError(Exception):\n pass\n\n# Helper routines\n_lapack_type = {'f': 0, 'd': 1, 'F': 2, 'D': 3}\n_lapack_letter = ['s', 'd', 'c', 'z']\n_array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n_array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n_array_type = [['f', 'd'], ['F', 'D']]\n\ndef _commonType(*arrays):\n kind = 0\n# precision = 0\n# force higher precision in lite version\n precision = 1\n for a in arrays:\n t = a.dtype.char\n kind = max(kind, _array_kind[t])\n precision = max(precision, _array_precision[t])\n return _array_type[kind][precision]\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n cast_arrays = cast_arrays + (transpose(a).astype(type),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\n# _fastCopyAndTranpose is an optimized version of _castCopyAndTranspose.\n# It assumes the input is 2D (as all the calls in here are).\n\n_fastCT = fastCopyAndTranspose\n\ndef _fastCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.dtype.char == type:\n cast_arrays = cast_arrays + (_fastCT(a),)\n else:\n cast_arrays = cast_arrays + (_fastCT(a.astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\ndef _assertRank2(*arrays):\n for a in arrays:\n if len(a.shape) != 2:\n raise LinAlgError, 'Array must be two-dimensional'\n\ndef _assertSquareness(*arrays):\n for a in arrays:\n if max(a.shape) != min(a.shape):\n raise LinAlgError, 'Array must be square'\n\n\n# Linear equations\n\ndef solve_linear_equations(a, b):\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n _assertSquareness(a)\n n_eq = a.shape[0]\n n_rhs = b.shape[1]\n if n_eq != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n# lapack_routine = _findLapackRoutine('gesv', t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesv\n else:\n lapack_routine = lapack_lite.dgesv\n a, b = _fastCopyAndTranspose(t, a, b)\n pivots = zeros(n_eq, 'i')\n results = lapack_routine(n_eq, n_rhs, a, n_eq, pivots, b, n_eq, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Singular matrix'\n if one_eq:\n return ravel(b) # I see no need to copy here\n else:\n return transpose(b) # no need to copy\n\n\n# Matrix inversion\n\ndef inverse(a):\n return solve_linear_equations(a, identity(a.shape[0]))\n\n\n# Cholesky decomposition\n\ndef cholesky_decomposition(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _castCopyAndTranspose(t, a)\n m = a.shape[0]\n n = a.shape[1]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zpotrf\n else:\n lapack_routine = lapack_lite.dpotrf\n results = lapack_routine('L', n, a, m, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Matrix is not positive definite - Cholesky decomposition cannot be computed'\n return transpose(triu(a,k=0)).copy()\n\n\n# Eigenvalues\n\ndef eigenvalues(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n dummy = zeros((1,), t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n rwork = zeros((n,),real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n else:\n w = wr+1j*wi\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\n\ndef Heigenvalues(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\ndef _convertarray(a):\n if issubclass(a.dtype.type, complexfloating):\n if a.dtype.char == 'D':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('D'))\n else:\n if a.dtype.char == 'd':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('d'))\n return a, a.dtype.char\n\n# Eigenvectors\n\ndef eig(a):\n \"\"\"eig(a) returns u,v where u is the eigenvalues and\nv is a matrix of eigenvectors with vector v[:,i] corresponds to\neigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i]\n\"\"\"\n a = asarray(a) \n _assertRank2(a)\n _assertSquareness(a)\n a,t = _convertarray(a) # convert to float_ or complex_ type\n wrap = a.__array_wrap__\n real_t = 'd'\n n = a.shape[0]\n dummy = zeros((1,), t)\n if t == 'D': # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n v = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n rwork = zeros((2*n,),real_t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n vr = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n v = vr\n else:\n w = wr+1j*wi\n v = array(vr,Complex)\n ind = nonzero(\n equal(\n equal(wi,0.0) # true for real e-vals\n ,0) # true for complex e-vals\n ) # indices of complex e-vals\n for i in range(len(ind)/2):\n v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]]\n v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]]\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(v.transpose())\n\n\ndef eigh(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(a.transpose())\n\n\n# Singular value decomposition\n\ndef svd(a, full_matrices = 1):\n _assertRank2(a)\n n = a.shape[1]\n m = a.shape[0]\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n if full_matrices:\n nu = m\n nvt = n\n option = 'A'\n else:\n nu = min(n,m)\n nvt = min(n,m)\n option = 'S'\n s = zeros((min(n,m),), real_t)\n u = zeros((nu, m), t)\n vt = zeros((n, nvt), t)\n iwork = zeros((8*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesdd\n rwork = zeros((5*min(m,n)*min(m,n) + 5*min(m,n),), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, rwork, iwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, rwork, iwork, 0)\n else:\n lapack_routine = lapack_lite.dgesdd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, iwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, iwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge'\n return wrap(transpose(u)), s, \\\n wrap(transpose(vt)) # why copy here?\n\n\n# Generalized inverse\n\ndef generalized_inverse(a, rcond = 1.e-10):\n a = array(a, copy=0)\n if a.dtype.char in typecodes['Complex']:\n a = conjugate(a)\n u, s, vt = svd(a, 0)\n m = u.shape[0]\n n = vt.shape[1]\n cutoff = rcond*maximum.reduce(s)\n for i in range(min(n,m)):\n if s[i] > cutoff:\n s[i] = 1./s[i]\n else:\n s[i] = 0.;\n wrap = a.__array_wrap__\n return wrap(dot(transpose(vt), \n multiply(s[:, NewAxis],transpose(u))))\n\n# Determinant\n\ndef determinant(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zgetrf\n else:\n lapack_routine = lapack_lite.dgetrf\n pivots = zeros((n,), 'i')\n results = lapack_routine(n, n, a, n, pivots, 0)\n sign = add.reduce(not_equal(pivots,\n arrayrange(1, n+1))) % 2\n return (1.-2.*sign)*multiply.reduce(diagonal(a),axis=-1)\n\n# Linear Least Squares\n\ndef linear_least_squares(a, b, rcond=1.e-10):\n \"\"\"returns x,resids,rank,s\nwhere x minimizes 2-norm(|b - Ax|)\n resids is the sum square residuals\n rank is the rank of A\n s is the rank of the singular values of A in descending order\n\nIf b is a matrix then x is also a matrix with corresponding columns.\nIf the rank of A is less than the number of columns of A or greater than\nthe number of rows, then residuals will be returned as an empty array\notherwise resids = sum((b-dot(A,x)**2).\nSingular values less than s[0]*rcond are treated as zero.\n\"\"\"\n a = asarray(a)\n b = asarray(b)\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n m = a.shape[0]\n n = a.shape[1]\n n_rhs = b.shape[1]\n ldb = max(n,m)\n if m != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n real_t = _array_type[0][_array_precision[t]]\n bstar = zeros((ldb,n_rhs),t)\n bstar[:b.shape[0],:n_rhs] = b.copy()\n a,bstar = _castCopyAndTranspose(t, a, bstar)\n s = zeros((min(m,n),),real_t)\n nlvl = max( 0, int( math.log( float(min( m,n ))/2. ) ) + 1 )\n iwork = zeros((3*min(m,n)*nlvl+11*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgelsd\n lwork = 1\n rwork = zeros((lwork,), real_t)\n work = zeros((lwork,),t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,rwork,iwork,0 )\n lwork = int(abs(work[0]))\n rwork = zeros((lwork,),real_t)\n a_real = zeros((m,n),real_t)\n bstar_real = zeros((ldb,n_rhs,),real_t)\n results = lapack_lite.dgelsd( m, n, n_rhs, a_real, m, bstar_real,ldb , s, rcond,\n 0,rwork,-1,iwork,0 )\n lrwork = int(rwork[0])\n work = zeros((lwork,), t)\n rwork = zeros((lrwork,), real_t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,rwork,iwork,0 )\n else:\n lapack_routine = lapack_lite.dgelsd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,iwork,0 )\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,iwork,0 )\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge in Linear Least Squares'\n resids = array([],t)\n if one_eq:\n x = ravel(bstar)[:n].copy()\n if (results['rank']==n) and (m>n):\n resids = array([sum((ravel(bstar)[n:])**2)])\n else:\n x = transpose(bstar)[:n,:].copy()\n if (results['rank']==n) and (m>n):\n resids = sum((transpose(bstar)[n:,:])**2).copy()\n return x,resids,results['rank'],s[:min(n,m)].copy()\n\ndef singular_value_decomposition(A, full_matrices=0):\n return svd(A, 0)\n\ndef eigenvectors(A):\n w, v = eig(A)\n return w, transpose(v)\n\ndef Heigenvectors(A):\n w, v = eigh(A)\n return w, transpose(v)\n\ninv = inverse\nsolve = solve_linear_equations\ncholesky = cholesky_decomposition\neigvals = eigenvalues\neigvalsh = Heigenvalues\npinv = generalized_inverse\ndet = determinant\nlstsq = linear_least_squares\n\nif __name__ == '__main__':\n def test(a, b):\n\n print \"All numbers printed should be (almost) zero:\"\n\n x = solve_linear_equations(a, b)\n check = b - matrixmultiply(a, x)\n print check\n\n\n a_inv = inverse(a)\n check = matrixmultiply(a, a_inv)-identity(a.shape[0])\n print check\n\n\n ev = eigenvalues(a)\n\n evalues, evectors = eig(a)\n check = ev-evalues\n print check\n\n evectors = transpose(evectors)\n check = matrixmultiply(a, evectors)-evectors*evalues\n print check\n\n\n u, s, vt = svd(a,0)\n check = a - matrixmultiply(u*s, vt)\n print check\n\n\n a_ginv = generalized_inverse(a)\n check = matrixmultiply(a, a_ginv)-identity(a.shape[0])\n print check\n\n\n det = determinant(a)\n check = det-multiply.reduce(evalues)\n print check\n\n x, residuals, rank, sv = linear_least_squares(a, b)\n check = b - matrixmultiply(a, x)\n print check\n print rank-a.shape[0]\n print sv-s\n\n a = array([[1.,2.], [3.,4.]])\n b = array([2., 1.])\n test(a, b)\n\n a = a+0j\n b = b+0j\n test(a, b)\n\n\n", + "source_code_before": "\"\"\"Lite version of numpy.linalg.\n\"\"\"\n# This module is a lite version of LinAlg.py module which contains\n# high-level Python interface to the LAPACK library. The lite version\n# only accesses the following LAPACK functions: dgesv, zgesv, dgeev,\n# zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf.\n\n__all__ = ['LinAlgError', 'solve_linear_equations', 'solve',\n 'inverse', 'inv', 'cholesky_decomposition', 'cholesky', 'eigenvalues',\n 'eigvals', 'Heigenvalues', 'eigvalsh', 'generalized_inverse', 'pinv',\n 'determinant', 'det', 'singular_value_decomposition', 'svd',\n 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares'\n ]\n \nfrom numpy import *\nimport lapack_lite\nimport math\n\n# Error object\nclass LinAlgError(Exception):\n pass\n\n# Helper routines\n_lapack_type = {'f': 0, 'd': 1, 'F': 2, 'D': 3}\n_lapack_letter = ['s', 'd', 'c', 'z']\n_array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n_array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n_array_type = [['f', 'd'], ['F', 'D']]\n\ndef _commonType(*arrays):\n kind = 0\n# precision = 0\n# force higher precision in lite version\n precision = 1\n for a in arrays:\n t = a.dtype.char\n kind = max(kind, _array_kind[t])\n precision = max(precision, _array_precision[t])\n return _array_type[kind][precision]\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n cast_arrays = cast_arrays + (transpose(a).astype(type),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\n# _fastCopyAndTranpose is an optimized version of _castCopyAndTranspose.\n# It assumes the input is 2D (as all the calls in here are).\n\n_fastCT = fastCopyAndTranspose\n\ndef _fastCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.dtype.char == type:\n cast_arrays = cast_arrays + (_fastCT(a),)\n else:\n cast_arrays = cast_arrays + (_fastCT(a.astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\ndef _assertRank2(*arrays):\n for a in arrays:\n if len(a.shape) != 2:\n raise LinAlgError, 'Array must be two-dimensional'\n\ndef _assertSquareness(*arrays):\n for a in arrays:\n if max(a.shape) != min(a.shape):\n raise LinAlgError, 'Array must be square'\n\n\n# Linear equations\n\ndef solve_linear_equations(a, b):\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n _assertSquareness(a)\n n_eq = a.shape[0]\n n_rhs = b.shape[1]\n if n_eq != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n# lapack_routine = _findLapackRoutine('gesv', t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesv\n else:\n lapack_routine = lapack_lite.dgesv\n a, b = _fastCopyAndTranspose(t, a, b)\n pivots = zeros(n_eq, 'i')\n results = lapack_routine(n_eq, n_rhs, a, n_eq, pivots, b, n_eq, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Singular matrix'\n if one_eq:\n return ravel(b) # I see no need to copy here\n else:\n return transpose(b) # no need to copy\n\n\n# Matrix inversion\n\ndef inverse(a):\n return solve_linear_equations(a, identity(a.shape[0]))\n\n\n# Cholesky decomposition\n\ndef cholesky_decomposition(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _castCopyAndTranspose(t, a)\n m = a.shape[0]\n n = a.shape[1]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zpotrf\n else:\n lapack_routine = lapack_lite.dpotrf\n results = lapack_routine('L', n, a, m, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Matrix is not positive definite - Cholesky decomposition cannot be computed'\n return transpose(triu(a,k=0)).copy()\n\n\n# Eigenvalues\n\ndef eigenvalues(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n dummy = zeros((1,), t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n rwork = zeros((n,),real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n else:\n w = wr+1j*wi\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\n\ndef Heigenvalues(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\ndef _convertarray(a):\n if issubclass(a.dtype, complexfloating):\n if a.dtype.char == 'D':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('D'))\n else:\n if a.dtype.char == 'd':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('d'))\n return a, a.dtype.char\n\n# Eigenvectors\n\ndef eig(a):\n \"\"\"eig(a) returns u,v where u is the eigenvalues and\nv is a matrix of eigenvectors with vector v[:,i] corresponds to\neigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i]\n\"\"\"\n a = asarray(a) \n _assertRank2(a)\n _assertSquareness(a)\n a,t = _convertarray(a) # convert to float_ or complex_ type\n wrap = a.__array_wrap__\n real_t = 'd'\n n = a.shape[0]\n dummy = zeros((1,), t)\n if t == 'D': # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n v = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n rwork = zeros((2*n,),real_t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n vr = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n v = vr\n else:\n w = wr+1j*wi\n v = array(vr,Complex)\n ind = nonzero(\n equal(\n equal(wi,0.0) # true for real e-vals\n ,0) # true for complex e-vals\n ) # indices of complex e-vals\n for i in range(len(ind)/2):\n v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]]\n v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]]\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(v.transpose())\n\n\ndef eigh(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(a.transpose())\n\n\n# Singular value decomposition\n\ndef svd(a, full_matrices = 1):\n _assertRank2(a)\n n = a.shape[1]\n m = a.shape[0]\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n if full_matrices:\n nu = m\n nvt = n\n option = 'A'\n else:\n nu = min(n,m)\n nvt = min(n,m)\n option = 'S'\n s = zeros((min(n,m),), real_t)\n u = zeros((nu, m), t)\n vt = zeros((n, nvt), t)\n iwork = zeros((8*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesdd\n rwork = zeros((5*min(m,n)*min(m,n) + 5*min(m,n),), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, rwork, iwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, rwork, iwork, 0)\n else:\n lapack_routine = lapack_lite.dgesdd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, iwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, iwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge'\n return wrap(transpose(u)), s, \\\n wrap(transpose(vt)) # why copy here?\n\n\n# Generalized inverse\n\ndef generalized_inverse(a, rcond = 1.e-10):\n a = array(a, copy=0)\n if a.dtype.char in typecodes['Complex']:\n a = conjugate(a)\n u, s, vt = svd(a, 0)\n m = u.shape[0]\n n = vt.shape[1]\n cutoff = rcond*maximum.reduce(s)\n for i in range(min(n,m)):\n if s[i] > cutoff:\n s[i] = 1./s[i]\n else:\n s[i] = 0.;\n wrap = a.__array_wrap__\n return wrap(dot(transpose(vt), \n multiply(s[:, NewAxis],transpose(u))))\n\n# Determinant\n\ndef determinant(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zgetrf\n else:\n lapack_routine = lapack_lite.dgetrf\n pivots = zeros((n,), 'i')\n results = lapack_routine(n, n, a, n, pivots, 0)\n sign = add.reduce(not_equal(pivots,\n arrayrange(1, n+1))) % 2\n return (1.-2.*sign)*multiply.reduce(diagonal(a),axis=-1)\n\n# Linear Least Squares\n\ndef linear_least_squares(a, b, rcond=1.e-10):\n \"\"\"returns x,resids,rank,s\nwhere x minimizes 2-norm(|b - Ax|)\n resids is the sum square residuals\n rank is the rank of A\n s is the rank of the singular values of A in descending order\n\nIf b is a matrix then x is also a matrix with corresponding columns.\nIf the rank of A is less than the number of columns of A or greater than\nthe number of rows, then residuals will be returned as an empty array\notherwise resids = sum((b-dot(A,x)**2).\nSingular values less than s[0]*rcond are treated as zero.\n\"\"\"\n a = asarray(a)\n b = asarray(b)\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n m = a.shape[0]\n n = a.shape[1]\n n_rhs = b.shape[1]\n ldb = max(n,m)\n if m != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n real_t = _array_type[0][_array_precision[t]]\n bstar = zeros((ldb,n_rhs),t)\n bstar[:b.shape[0],:n_rhs] = b.copy()\n a,bstar = _castCopyAndTranspose(t, a, bstar)\n s = zeros((min(m,n),),real_t)\n nlvl = max( 0, int( math.log( float(min( m,n ))/2. ) ) + 1 )\n iwork = zeros((3*min(m,n)*nlvl+11*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgelsd\n lwork = 1\n rwork = zeros((lwork,), real_t)\n work = zeros((lwork,),t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,rwork,iwork,0 )\n lwork = int(abs(work[0]))\n rwork = zeros((lwork,),real_t)\n a_real = zeros((m,n),real_t)\n bstar_real = zeros((ldb,n_rhs,),real_t)\n results = lapack_lite.dgelsd( m, n, n_rhs, a_real, m, bstar_real,ldb , s, rcond,\n 0,rwork,-1,iwork,0 )\n lrwork = int(rwork[0])\n work = zeros((lwork,), t)\n rwork = zeros((lrwork,), real_t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,rwork,iwork,0 )\n else:\n lapack_routine = lapack_lite.dgelsd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,iwork,0 )\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,iwork,0 )\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge in Linear Least Squares'\n resids = array([],t)\n if one_eq:\n x = ravel(bstar)[:n].copy()\n if (results['rank']==n) and (m>n):\n resids = array([sum((ravel(bstar)[n:])**2)])\n else:\n x = transpose(bstar)[:n,:].copy()\n if (results['rank']==n) and (m>n):\n resids = sum((transpose(bstar)[n:,:])**2).copy()\n return x,resids,results['rank'],s[:min(n,m)].copy()\n\ndef singular_value_decomposition(A, full_matrices=0):\n return svd(A, 0)\n\ndef eigenvectors(A):\n w, v = eig(A)\n return w, transpose(v)\n\ndef Heigenvectors(A):\n w, v = eigh(A)\n return w, transpose(v)\n\ninv = inverse\nsolve = solve_linear_equations\ncholesky = cholesky_decomposition\neigvals = eigenvalues\neigvalsh = Heigenvalues\npinv = generalized_inverse\ndet = determinant\nlstsq = linear_least_squares\n\nif __name__ == '__main__':\n def test(a, b):\n\n print \"All numbers printed should be (almost) zero:\"\n\n x = solve_linear_equations(a, b)\n check = b - matrixmultiply(a, x)\n print check\n\n\n a_inv = inverse(a)\n check = matrixmultiply(a, a_inv)-identity(a.shape[0])\n print check\n\n\n ev = eigenvalues(a)\n\n evalues, evectors = eig(a)\n check = ev-evalues\n print check\n\n evectors = transpose(evectors)\n check = matrixmultiply(a, evectors)-evectors*evalues\n print check\n\n\n u, s, vt = svd(a,0)\n check = a - matrixmultiply(u*s, vt)\n print check\n\n\n a_ginv = generalized_inverse(a)\n check = matrixmultiply(a, a_ginv)-identity(a.shape[0])\n print check\n\n\n det = determinant(a)\n check = det-multiply.reduce(evalues)\n print check\n\n x, residuals, rank, sv = linear_least_squares(a, b)\n check = b - matrixmultiply(a, x)\n print check\n print rank-a.shape[0]\n print sv-s\n\n a = array([[1.,2.], [3.,4.]])\n b = array([2., 1.])\n test(a, b)\n\n a = a+0j\n b = b+0j\n test(a, b)\n\n\n", + "methods": [ + { + "name": "_commonType", + "long_name": "_commonType( * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 30, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_castCopyAndTranspose", + "long_name": "_castCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "type", + "arrays" + ], + "start_line": 41, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_fastCopyAndTranspose", + "long_name": "_fastCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 11, + "complexity": 4, + "token_count": 72, + "parameters": [ + "type", + "arrays" + ], + "start_line": 55, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_assertRank2", + "long_name": "_assertRank2( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 25, + "parameters": [ + "arrays" + ], + "start_line": 67, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_assertSquareness", + "long_name": "_assertSquareness( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 30, + "parameters": [ + "arrays" + ], + "start_line": 72, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "solve_linear_equations", + "long_name": "solve_linear_equations( a , b )", + "filename": "linalg.py", + "nloc": 24, + "complexity": 6, + "token_count": 163, + "parameters": [ + "a", + "b" + ], + "start_line": 80, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "inverse", + "long_name": "inverse( a )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 109, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "cholesky_decomposition", + "long_name": "cholesky_decomposition( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 3, + "token_count": 105, + "parameters": [ + "a" + ], + "start_line": 115, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "eigenvalues", + "long_name": "eigenvalues( a )", + "filename": "linalg.py", + "nloc": 39, + "complexity": 4, + "token_count": 363, + "parameters": [ + "a" + ], + "start_line": 134, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Heigenvalues", + "long_name": "Heigenvalues( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 34, + "complexity": 3, + "token_count": 345, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 175, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convertarray", + "long_name": "_convertarray( a )", + "filename": "linalg.py", + "nloc": 12, + "complexity": 4, + "token_count": 83, + "parameters": [ + "a" + ], + "start_line": 210, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "eig", + "long_name": "eig( a )", + "filename": "linalg.py", + "nloc": 52, + "complexity": 5, + "token_count": 502, + "parameters": [ + "a" + ], + "start_line": 225, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 56, + "top_nesting_level": 0 + }, + { + "name": "eigh", + "long_name": "eigh( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 35, + "complexity": 3, + "token_count": 359, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 283, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "svd", + "long_name": "svd( a , full_matrices = 1 )", + "filename": "linalg.py", + "nloc": 45, + "complexity": 4, + "token_count": 441, + "parameters": [ + "a", + "full_matrices" + ], + "start_line": 322, + "end_line": 366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "generalized_inverse", + "long_name": "generalized_inverse( a , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 16, + "complexity": 4, + "token_count": 153, + "parameters": [ + "a", + "rcond" + ], + "start_line": 371, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "determinant", + "long_name": "determinant( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 2, + "token_count": 129, + "parameters": [ + "a" + ], + "start_line": 390, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "linear_least_squares", + "long_name": "linear_least_squares( a , b , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 61, + "complexity": 10, + "token_count": 722, + "parameters": [ + "a", + "b", + "rcond" + ], + "start_line": 408, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "singular_value_decomposition", + "long_name": "singular_value_decomposition( A , full_matrices = 0 )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "A", + "full_matrices" + ], + "start_line": 482, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "eigenvectors", + "long_name": "eigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 485, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "Heigenvectors", + "long_name": "Heigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 489, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( a , b )", + "filename": "linalg.py", + "nloc": 29, + "complexity": 1, + "token_count": 205, + "parameters": [ + "a", + "b" + ], + "start_line": 503, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "_commonType", + "long_name": "_commonType( * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 30, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_castCopyAndTranspose", + "long_name": "_castCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "type", + "arrays" + ], + "start_line": 41, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_fastCopyAndTranspose", + "long_name": "_fastCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 11, + "complexity": 4, + "token_count": 72, + "parameters": [ + "type", + "arrays" + ], + "start_line": 55, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_assertRank2", + "long_name": "_assertRank2( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 25, + "parameters": [ + "arrays" + ], + "start_line": 67, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_assertSquareness", + "long_name": "_assertSquareness( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 30, + "parameters": [ + "arrays" + ], + "start_line": 72, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "solve_linear_equations", + "long_name": "solve_linear_equations( a , b )", + "filename": "linalg.py", + "nloc": 24, + "complexity": 6, + "token_count": 163, + "parameters": [ + "a", + "b" + ], + "start_line": 80, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "inverse", + "long_name": "inverse( a )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 109, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "cholesky_decomposition", + "long_name": "cholesky_decomposition( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 3, + "token_count": 105, + "parameters": [ + "a" + ], + "start_line": 115, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "eigenvalues", + "long_name": "eigenvalues( a )", + "filename": "linalg.py", + "nloc": 39, + "complexity": 4, + "token_count": 363, + "parameters": [ + "a" + ], + "start_line": 134, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Heigenvalues", + "long_name": "Heigenvalues( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 34, + "complexity": 3, + "token_count": 345, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 175, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convertarray", + "long_name": "_convertarray( a )", + "filename": "linalg.py", + "nloc": 12, + "complexity": 4, + "token_count": 81, + "parameters": [ + "a" + ], + "start_line": 210, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "eig", + "long_name": "eig( a )", + "filename": "linalg.py", + "nloc": 52, + "complexity": 5, + "token_count": 502, + "parameters": [ + "a" + ], + "start_line": 225, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 56, + "top_nesting_level": 0 + }, + { + "name": "eigh", + "long_name": "eigh( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 35, + "complexity": 3, + "token_count": 359, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 283, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "svd", + "long_name": "svd( a , full_matrices = 1 )", + "filename": "linalg.py", + "nloc": 45, + "complexity": 4, + "token_count": 441, + "parameters": [ + "a", + "full_matrices" + ], + "start_line": 322, + "end_line": 366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "generalized_inverse", + "long_name": "generalized_inverse( a , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 16, + "complexity": 4, + "token_count": 153, + "parameters": [ + "a", + "rcond" + ], + "start_line": 371, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "determinant", + "long_name": "determinant( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 2, + "token_count": 129, + "parameters": [ + "a" + ], + "start_line": 390, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "linear_least_squares", + "long_name": "linear_least_squares( a , b , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 61, + "complexity": 10, + "token_count": 722, + "parameters": [ + "a", + "b", + "rcond" + ], + "start_line": 408, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "singular_value_decomposition", + "long_name": "singular_value_decomposition( A , full_matrices = 0 )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "A", + "full_matrices" + ], + "start_line": 482, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "eigenvectors", + "long_name": "eigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 485, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "Heigenvectors", + "long_name": "Heigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 489, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( a , b )", + "filename": "linalg.py", + "nloc": 29, + "complexity": 1, + "token_count": 205, + "parameters": [ + "a", + "b" + ], + "start_line": 503, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "_convertarray", + "long_name": "_convertarray( a )", + "filename": "linalg.py", + "nloc": 12, + "complexity": 4, + "token_count": 83, + "parameters": [ + "a" + ], + "start_line": 210, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + } + ], + "nloc": 456, + "complexity": 68, + "token_count": 4150, + "diff_parsed": { + "added": [ + " if issubclass(a.dtype.type, complexfloating):" + ], + "deleted": [ + " if issubclass(a.dtype, complexfloating):" + ] + } + } + ] + }, + { + "hash": "f18a0fab69c9da73e3f30231403abede272de1c4", + "msg": "Fix uninitialized variable.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T19:39:54+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T19:39:54+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "4072234146d63644ed0e658f685a5575ca051d9d" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/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/core/src/multiarraymodule.c", + "new_path": "numpy/core/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -4402,7 +4402,7 @@ PyArray_FromString(char *data, intp slen, PyArray_Descr *dtype,\n \t\tchar *ptr;\t\t\n \t\tPyArray_FromStrFunc *fromstr;\n \t\tchar *dptr;\n-\t\tintp nread;\n+\t\tintp nread=0;\n \t\tintp index;\n \n \t\tfromstr = dtype->f->fromstr;\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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) 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.\";\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "source_code_before": "\n/*\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 for numpy_core 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 */\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 char *\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 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, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = 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);\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 PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \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) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\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\tret = mps[i];\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; 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\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum, nd;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS];\n\tPyArray_DotFunc *dot;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\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\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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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\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\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 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\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 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\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\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; i 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\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_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 values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\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 if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\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\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\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\treturn NULL;\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\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\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 anew 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 && 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\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;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\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\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\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ialignment;\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\tPyList_SET_ITEM(nameslist, i, key);\n\t\tif (ret == PY_FAIL) goto fail;\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\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\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\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\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\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\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\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\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\", \"fortran\", \"subok\", /* XXX ? */\n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\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 && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\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\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_CheckFromAny(op, type, 0, 0, flags, NULL)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\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,fortran=0) 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\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\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_BoolConverter, &fortran)) \n\t\tgoto fail;\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,fortran=0) 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\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_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\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;\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) 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.\";\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_DATA(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_DATA(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[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\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/*MULTIARRAY_API\n GetNDArrayCVersion\n*/\nstatic uint\nPyArray_GetNDArrayCVersion(void)\n{\n\treturn (uint)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\t\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\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\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\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(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\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\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\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\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "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": 4331, + "end_line": 4342, + "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": 4347, + "end_line": 4489, + "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": 4494, + "end_line": 4511, + "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": 4525, + "end_line": 4653, + "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": 4671, + "end_line": 4709, + "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": 4713, + "end_line": 4806, + "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": 4822, + "end_line": 4839, + "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": 4845, + "end_line": 4856, + "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": 4863, + "end_line": 4869, + "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": 4876, + "end_line": 4882, + "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": 4886, + "end_line": 4892, + "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": 4896, + "end_line": 4905, + "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": 4912, + "end_line": 4963, + "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": 4969, + "end_line": 5001, + "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": 5008, + "end_line": 5092, + "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": 5098, + "end_line": 5110, + "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": 12, + "parameters": [], + "start_line": 5116, + "end_line": 5119, + "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": 5125, + "end_line": 5131, + "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": 5137, + "end_line": 5153, + "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": 5159, + "end_line": 5176, + "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": 5183, + "end_line": 5223, + "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": 5231, + "end_line": 5239, + "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": 5251, + "end_line": 5261, + "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": 5270, + "end_line": 5281, + "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": 5288, + "end_line": 5311, + "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": 5318, + "end_line": 5326, + "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": 5335, + "end_line": 5353, + "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": 5419, + "end_line": 5532, + "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": 5537, + "end_line": 5561, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5566, + "end_line": 5659, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "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": 61, + "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 , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "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": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 202, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 248, + "end_line": 257, + "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": 260, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 409, + "parameters": [ + "self", + "newdims" + ], + "start_line": 297, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "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": 393, + "end_line": 428, + "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": 435, + "end_line": 456, + "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": 463, + "end_line": 522, + "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": 529, + "end_line": 539, + "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": 545, + "end_line": 555, + "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": 561, + "end_line": 571, + "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": 577, + "end_line": 588, + "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": 594, + "end_line": 605, + "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": 611, + "end_line": 622, + "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": 629, + "end_line": 649, + "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": 655, + "end_line": 714, + "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": 720, + "end_line": 750, + "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": 756, + "end_line": 792, + "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": 798, + "end_line": 808, + "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": 814, + "end_line": 933, + "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": 949, + "end_line": 1000, + "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": 1008, + "end_line": 1018, + "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": 1024, + "end_line": 1036, + "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": 1044, + "end_line": 1055, + "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": 1059, + "end_line": 1087, + "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": 94, + "complexity": 21, + "token_count": 630, + "parameters": [ + "op", + "axis" + ], + "start_line": 1099, + "end_line": 1205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 107, + "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": 1211, + "end_line": 1252, + "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": 1258, + "end_line": 1311, + "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": 1317, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 13, + "token_count": 439, + "parameters": [ + "op", + "retn" + ], + "start_line": 1416, + "end_line": 1487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "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": 1494, + "end_line": 1575, + "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": 1578, + "end_line": 1585, + "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": 1596, + "end_line": 1650, + "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": 1653, + "end_line": 1731, + "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": 1739, + "end_line": 1742, + "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": 1797, + "end_line": 1863, + "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": 1869, + "end_line": 1877, + "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": 1883, + "end_line": 1963, + "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": 1975, + "end_line": 2119, + "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": 2123, + "end_line": 2158, + "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": 2164, + "end_line": 2209, + "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": 2216, + "end_line": 2240, + "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": 74, + "complexity": 15, + "token_count": 584, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2249, + "end_line": 2342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 94, + "complexity": 18, + "token_count": 733, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2350, + "end_line": 2467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "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": 2473, + "end_line": 2527, + "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": 2533, + "end_line": 2630, + "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": 2637, + "end_line": 2661, + "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": 2667, + "end_line": 2678, + "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": 2684, + "end_line": 2695, + "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": 2701, + "end_line": 2724, + "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": 2731, + "end_line": 2788, + "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": 2795, + "end_line": 2870, + "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": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "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": 2951, + "end_line": 3022, + "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": 3038, + "end_line": 3050, + "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": 3056, + "end_line": 3064, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 3071, + "end_line": 3186, + "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": 3204, + "end_line": 3229, + "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": 3244, + "end_line": 3280, + "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": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 3298, + "end_line": 3331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 61, + "complexity": 14, + "token_count": 369, + "parameters": [ + "obj" + ], + "start_line": 3334, + "end_line": 3407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3415, + "end_line": 3477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3488, + "end_line": 3551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "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": 3564, + "end_line": 3580, + "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": 3617, + "end_line": 3622, + "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": 93, + "complexity": 25, + "token_count": 641, + "parameters": [ + "obj", + "align" + ], + "start_line": 3625, + "end_line": 3727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "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": 3745, + "end_line": 3752, + "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": 146, + "complexity": 57, + "token_count": 916, + "parameters": [ + "obj", + "at" + ], + "start_line": 3769, + "end_line": 3949, + "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": 3955, + "end_line": 3987, + "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": 3993, + "end_line": 4019, + "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": 4028, + "end_line": 4047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 327, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4068, + "end_line": 4133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "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": 4141, + "end_line": 4156, + "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": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4162, + "end_line": 4186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4191, + "end_line": 4249, + "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": 4258, + "end_line": 4282, + "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": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 4288, + "end_line": 4312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "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": 4319, + "end_line": 4328, + "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": 4331, + "end_line": 4342, + "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": 709, + "parameters": [ + "data", + "slen", + "dtype", + "n", + "sep" + ], + "start_line": 4347, + "end_line": 4489, + "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": 4494, + "end_line": 4511, + "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": 4525, + "end_line": 4653, + "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": 4671, + "end_line": 4709, + "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": 4713, + "end_line": 4806, + "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": 4822, + "end_line": 4839, + "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": 4845, + "end_line": 4856, + "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": 4863, + "end_line": 4869, + "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": 4876, + "end_line": 4882, + "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": 4886, + "end_line": 4892, + "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": 4896, + "end_line": 4905, + "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": 4912, + "end_line": 4963, + "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": 4969, + "end_line": 5001, + "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": 5008, + "end_line": 5092, + "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": 5098, + "end_line": 5110, + "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": 12, + "parameters": [], + "start_line": 5116, + "end_line": 5119, + "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": 5125, + "end_line": 5131, + "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": 5137, + "end_line": 5153, + "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": 5159, + "end_line": 5176, + "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": 5183, + "end_line": 5223, + "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": 5231, + "end_line": 5239, + "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": 5251, + "end_line": 5261, + "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": 5270, + "end_line": 5281, + "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": 5288, + "end_line": 5311, + "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": 5318, + "end_line": 5326, + "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": 5335, + "end_line": 5353, + "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": 5419, + "end_line": 5532, + "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": 5537, + "end_line": 5561, + "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": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 5566, + "end_line": 5659, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "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": 4347, + "end_line": 4489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 143, + "top_nesting_level": 0 + } + ], + "nloc": 4275, + "complexity": 932, + "token_count": 27838, + "diff_parsed": { + "added": [ + "\t\tintp nread=0;" + ], + "deleted": [ + "\t\tintp nread;" + ] + } + } + ] + }, + { + "hash": "beb7e7c80b325df0c16419ce63d87cc2c6ea5ada", + "msg": "Added tests for fromstring.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-21T20:15:14+00:00", + "author_timezone": 0, + "committer_date": "2006-01-21T20:15:14+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f18a0fab69c9da73e3f30231403abede272de1c4" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 0, + "insertions": 10, + "lines": 10, + "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": "@@ -68,6 +68,16 @@ def check_construction(self):\n assert_equal(d1, dtype(int32))\n d2 = dtype('f8')\n assert_equal(d2, dtype(float64))\n+\n+class 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\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\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_zero_rank(ScipyTestCase):\n def setUp(self):\n self.d = array(0), array('x', object)\n \n def check_ellipsis_subscript(self):\n a,b = self.d\n self.failUnlessEqual(a[...], 0)\n self.failUnlessEqual(b[...], 'x')\n self.failUnless(type(a[...]) is a.dtype.type)\n self.failUnless(type(b[...]) is str)\n \n def check_empty_subscript(self):\n a,b = self.d\n self.failUnlessEqual(a[()], 0)\n self.failUnlessEqual(b[()], 'x')\n self.failUnless(type(a[()]) is a.dtype.type)\n\tself.failUnless(type(b[()]) is str)\n\n def check_invalid_subscript(self):\n a,b = self.d\n self.failUnlessRaises(IndexError, lambda x: x[0], a)\n self.failUnlessRaises(IndexError, lambda x: x[0], b)\n self.failUnlessRaises(IndexError, lambda x: x[array([], int)], a)\n self.failUnlessRaises(IndexError, lambda x: x[array([], int)], b)\n\n def check_ellipsis_subscript_assignment(self):\n a,b = self.d\n a[...] = 42\n self.failUnlessEqual(a, 42)\n b[...] = ''\n self.failUnlessEqual(b.item(), '')\n \n def check_empty_subscript_assignment(self):\n a,b = self.d\n a[()] = 42\n self.failUnlessEqual(a, 42)\n b[()] = ''\n self.failUnlessEqual(b.item(), '')\n\n def check_invalid_subscript_assignment(self):\n a,b = self.d\n def assign(x, i, v):\n x[i] = v\n self.failUnlessRaises(IndexError, assign, a, 0, 42)\n self.failUnlessRaises(IndexError, assign, b, 0, '')\n self.failUnlessRaises(TypeError, assign, a, (), '')\n\n def check_newaxis(self):\n a,b = self.d\n self.failUnlessEqual(a[newaxis].shape, (1,))\n self.failUnlessEqual(a[..., newaxis].shape, (1,))\n self.failUnlessEqual(a[newaxis, ...].shape, (1,))\n self.failUnlessEqual(a[..., newaxis].shape, (1,))\n self.failUnlessEqual(a[newaxis, ..., newaxis].shape, (1,1))\n self.failUnlessEqual(a[..., newaxis, newaxis].shape, (1,1))\n self.failUnlessEqual(a[newaxis, newaxis, ...].shape, (1,1))\n self.failUnlessEqual(a[(newaxis,)*10].shape, (1,)*10)\n\n def check_invalid_newaxis(self):\n a,b = self.d\n def subscript(x, i): x[i]\n self.failUnlessRaises(IndexError, subscript, a, (newaxis, 0))\n self.failUnlessRaises(IndexError, subscript, a, (newaxis,)*50)\n\nclass test_creation(ScipyTestCase):\n def check_from_attribute(self):\n class x(object):\n def __array__(self, dtype=None):\n pass\n self.failUnlessRaises(ValueError, array, x())\n\nclass test_bool(ScipyTestCase):\n def check_test_interning(self):\n a0 = bool_(0)\n b0 = bool_(False)\n self.failUnless(a0 is b0)\n a1 = bool_(1)\n b1 = bool_(True)\n self.failUnless(a1 is b1)\n self.failUnless(array([True])[0] is a1)\n self.failUnless(array(True)[...] is a1)\n\n \nif __name__ == \"__main__\":\n ScipyTest('numpy.core.multiarray').run()\n", + "methods": [ + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 6, + "end_line": 7, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_writeable", + "long_name": "check_writeable( self )", + "filename": "test_multiarray.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_otherflags", + "long_name": "check_otherflags( self )", + "filename": "test_multiarray.py", + "nloc": 10, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 17, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_attributes", + "long_name": "check_attributes( self )", + "filename": "test_multiarray.py", + "nloc": 20, + "complexity": 1, + "token_count": 245, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_dtypeattr", + "long_name": "check_dtypeattr( self )", + "filename": "test_multiarray.py", + "nloc": 8, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 56, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_construction", + "long_name": "check_construction( self )", + "filename": "test_multiarray.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_binary", + "long_name": "check_binary( self )", + "filename": "test_multiarray.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_ascii", + "long_name": "check_ascii( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ellipsis_subscript", + "long_name": "check_ellipsis_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 86, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_subscript", + "long_name": "check_empty_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_subscript", + "long_name": "check_invalid_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 88, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_ellipsis_subscript_assignment", + "long_name": "check_ellipsis_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_subscript_assignment", + "long_name": "check_empty_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 114, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_subscript_assignment.assign", + "long_name": "check_invalid_subscript_assignment.assign( x , i , v )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "x", + "i", + "v" + ], + "start_line": 123, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_invalid_subscript_assignment", + "long_name": "check_invalid_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 121, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_newaxis", + "long_name": "check_newaxis( self )", + "filename": "test_multiarray.py", + "nloc": 10, + "complexity": 1, + "token_count": 168, + "parameters": [ + "self" + ], + "start_line": 129, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_newaxis.subscript", + "long_name": "check_invalid_newaxis.subscript( x , i )", + "filename": "test_multiarray.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "x", + "i" + ], + "start_line": 142, + "end_line": 144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "check_from_attribute.__array__", + "long_name": "check_from_attribute.__array__( self , dtype = None )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "dtype" + ], + "start_line": 149, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_from_attribute", + "long_name": "check_from_attribute( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 147, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_test_interning", + "long_name": "check_test_interning( self )", + "filename": "test_multiarray.py", + "nloc": 9, + "complexity": 1, + "token_count": 75, + "parameters": [ + "self" + ], + "start_line": 154, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 6, + "end_line": 7, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_writeable", + "long_name": "check_writeable( self )", + "filename": "test_multiarray.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_otherflags", + "long_name": "check_otherflags( self )", + "filename": "test_multiarray.py", + "nloc": 10, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 17, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_attributes", + "long_name": "check_attributes( self )", + "filename": "test_multiarray.py", + "nloc": 20, + "complexity": 1, + "token_count": 245, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_dtypeattr", + "long_name": "check_dtypeattr( self )", + "filename": "test_multiarray.py", + "nloc": 8, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 56, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_construction", + "long_name": "check_construction( self )", + "filename": "test_multiarray.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ellipsis_subscript", + "long_name": "check_ellipsis_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_subscript", + "long_name": "check_empty_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_subscript", + "long_name": "check_invalid_subscript( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 88, + "parameters": [ + "self" + ], + "start_line": 90, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_ellipsis_subscript_assignment", + "long_name": "check_ellipsis_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_subscript_assignment", + "long_name": "check_empty_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_subscript_assignment.assign", + "long_name": "check_invalid_subscript_assignment.assign( x , i , v )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "x", + "i", + "v" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_invalid_subscript_assignment", + "long_name": "check_invalid_subscript_assignment( self )", + "filename": "test_multiarray.py", + "nloc": 6, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_newaxis", + "long_name": "check_newaxis( self )", + "filename": "test_multiarray.py", + "nloc": 10, + "complexity": 1, + "token_count": 168, + "parameters": [ + "self" + ], + "start_line": 119, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_invalid_newaxis.subscript", + "long_name": "check_invalid_newaxis.subscript( x , i )", + "filename": "test_multiarray.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "x", + "i" + ], + "start_line": 132, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 2 + }, + { + "name": "check_from_attribute.__array__", + "long_name": "check_from_attribute.__array__( self , dtype = None )", + "filename": "test_multiarray.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "dtype" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_from_attribute", + "long_name": "check_from_attribute( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_test_interning", + "long_name": "check_test_interning( self )", + "filename": "test_multiarray.py", + "nloc": 9, + "complexity": 1, + "token_count": 75, + "parameters": [ + "self" + ], + "start_line": 144, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_ascii", + "long_name": "check_ascii( self )", + "filename": "test_multiarray.py", + "nloc": 4, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_binary", + "long_name": "check_binary( self )", + "filename": "test_multiarray.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": 142, + "complexity": 22, + "token_count": 1506, + "diff_parsed": { + "added": [ + "", + "class test_fromstring(ScipyTestCase):", + " def check_binary(self):", + " a = fromstring('\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@',dtype='nd,effrank,rank);\n \treturn 1;\n }\n+ /*\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n@@ -718,6 +719,19 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims)\n } else\n \tdims[i] = d;\n }\n+ */\n+ for (i=0; idimensions[i];\n+ if (dims[i]>=0) {\n+\tif (d > 1 && d!=dims[i]) {\n+\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n+\t\t \" but got %\" INTP_FMT \"\\n\",\n+\t\t i,dims[i],d);\n+\t return 1;\t \n+\t}\n+\tif (!dims[i]) dims[i] = 1;\n+ } else dims[i] = d;\n+ }\n for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */\n while (jnd && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n", + "added_lines": 14, + "deleted_lines": 0, + "source_code": "#define FORTRANOBJECT_C\n#include \"fortranobject.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/*\n This file implements: FortranObject, array_from_pyobj, copy_ND_array\n\n Author: Pearu Peterson \n $Revision: 1.52 $\n $Date: 2005/07/11 07:44:20 $\n*/\n\n/************************* FortranObject *******************************/\n\ntypedef PyObject *(*fortranfunc)(PyObject *,PyObject *,PyObject *,void *);\n\nPyObject *\nPyFortranObject_New(FortranDataDef* defs, f2py_void_func init) {\n int i;\n PyFortranObject *fp = NULL;\n PyObject *v = NULL;\n if (init!=NULL) /* Initialize F90 module objects */\n (*(init))();\n if ((fp = PyObject_New(PyFortranObject, &PyFortran_Type))==NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 0;\n while (defs[fp->len].name != NULL) fp->len++;\n if (fp->len == 0) goto fail;\n fp->defs = defs;\n for (i=0;ilen;i++)\n if (fp->defs[i].rank == -1) { /* Is Fortran routine */\n v = PyFortranObject_NewAsAttr(&(fp->defs[i]));\n if (v==NULL) return NULL;\n PyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n } else\n if ((fp->defs[i].data)!=NULL) { /* Is Fortran variable or array (not allocatable) */\n\tv = PyArray_New(&PyArray_Type, fp->defs[i].rank, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\tPyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n }\n Py_XDECREF(v);\n return (PyObject *)fp;\n fail:\n Py_XDECREF(v);\n return NULL;\n}\n\nPyObject *\nPyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module routines */\n PyFortranObject *fp = NULL;\n fp = PyObject_New(PyFortranObject, &PyFortran_Type);\n if (fp == NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 1;\n fp->defs = defs;\n return (PyObject *)fp;\n}\n\n/* Fortran methods */\n\nstatic void\nfortran_dealloc(PyFortranObject *fp) {\n Py_XDECREF(fp->dict);\n PyMem_Del(fp);\n}\n\n\nstatic PyMethodDef fortran_methods[] = {\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyObject *\nfortran_doc (FortranDataDef def) {\n char *p;\n PyObject *s = NULL;\n int i;\n unsigned size=100;\n if (def.doc!=NULL)\n size += strlen(def.doc);\n p = (char*)malloc (size);\n if (sprintf(p,\"%s - \",def.name)==0) goto fail;\n if (def.rank==-1) {\n if (def.doc==NULL) {\n if (sprintf(p,\"%sno docs available\",p)==0)\n\tgoto fail;\n } else {\n if (sprintf(p,\"%s%s\",p,def.doc)==0)\n\tgoto fail;\n }\n } else {\n PyArray_Descr *d = PyArray_DescrFromType(def.type);\n if (sprintf(p,\"%s'%c'-\",p,d->type)==0) goto fail;\n if (def.data==NULL) {\n if (sprintf(p,\"%sarray(%\" INTP_FMT,p,def.dims.d[0])==0) goto fail;\n for(i=1;i0) {\n\tif (sprintf(p,\"%sarray(%\"INTP_FMT,p,def.dims.d[0])==0) goto fail;\n\tfor(i=1;isize) {\n fprintf(stderr,\"fortranobject.c:fortran_doc:len(p)=%zd>%d(size): too long doc string required, increase size\\n\",strlen(p),size);\n goto fail;\n }\n s = PyString_FromString(p);\n fail:\n free(p);\n return s;\n}\n\nstatic FortranDataDef *save_def; /* save pointer of an allocatable array */\nstatic void set_data(char *d,intp *f) { /* callback from Fortran */\n if (*f) /* In fortran f=allocated(d) */\n save_def->data = d;\n else\n save_def->data = NULL;\n /* printf(\"set_data: d=%p,f=%d\\n\",d,*f); */\n}\n\nstatic PyObject *\nfortran_getattr(PyFortranObject *fp, char *name) {\n int i,j,k,flag;\n if (fp->dict != NULL) {\n PyObject *v = PyDict_GetItemString(fp->dict, name);\n if (v != NULL) {\n Py_INCREF(v);\n return v;\n }\n }\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0)\n if (fp->defs[i].rank!=-1) { /* F90 allocatable array */ \n if (fp->defs[i].func==NULL) return NULL;\n for(k=0;kdefs[i].rank;++k) \n\tfp->defs[i].dims.d[k]=-1;\n save_def = &fp->defs[i];\n (*(fp->defs[i].func))(&fp->defs[i].rank,fp->defs[i].dims.d,set_data,&flag);\n if (flag==2)\n\tk = fp->defs[i].rank + 1;\n else\n\tk = fp->defs[i].rank;\n if (fp->defs[i].data !=NULL) { /* array is allocated */\n\tPyObject *v = PyArray_New(&PyArray_Type, k, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\t/* Py_INCREF(v); */\n\treturn v;\n } else { /* array is not allocated */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n }\n }\n if (strcmp(name,\"__dict__\")==0) {\n Py_INCREF(fp->dict);\n return fp->dict;\n }\n if (strcmp(name,\"__doc__\")==0) {\n PyObject *s = PyString_FromString(\"\");\n for (i=0;ilen;i++)\n PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i]));\n if (PyDict_SetItemString(fp->dict, name, s))\n return NULL;\n return s;\n }\n if ((strcmp(name,\"_cpointer\")==0) && (fp->len==1)) {\n PyObject *cobj = PyCObject_FromVoidPtr((void *)(fp->defs[0].data),NULL);\n if (PyDict_SetItemString(fp->dict, name, cobj))\n return NULL;\n return cobj;\n }\n return Py_FindMethod(fortran_methods, (PyObject *)fp, name);\n}\n\nstatic int\nfortran_setattr(PyFortranObject *fp, char *name, PyObject *v) {\n int i,j,flag;\n PyArrayObject *arr = NULL;\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0) {\n if (fp->defs[i].rank==-1) {\n PyErr_SetString(PyExc_AttributeError,\"over-writing fortran routine\");\n return -1;\n }\n if (fp->defs[i].func!=NULL) { /* is allocatable array */\n intp dims[F2PY_MAX_DIMS];\n int k;\n save_def = &fp->defs[i];\n if (v!=Py_None) { /* set new value (reallocate if needed --\n\t\t\t see f2py generated code for more\n\t\t\t details ) */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n\tif ((arr = array_from_pyobj(fp->defs[i].type,dims,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\t return -1;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,arr->dimensions,set_data,&flag);\n } else { /* deallocate */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=0;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n }\n memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(intp));\n } else { /* not allocatable array */\n if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\treturn -1; \n }\n if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */\n intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);\n if (s==-1)\n\ts = PyArray_MultiplyList(arr->dimensions,arr->nd);\n if (s<0 ||\n\t (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) {\n\tif ((PyObject*)arr!=v) {\n\t Py_DECREF(arr);\n\t}\n\treturn -1;\n }\n if ((PyObject*)arr!=v) {\n Py_DECREF(arr);\n }\n } else return (fp->defs[i].func==NULL?-1:0);\n return 0; /* succesful */\n }\n if (fp->dict == NULL) {\n fp->dict = PyDict_New();\n if (fp->dict == NULL)\n return -1;\n }\n if (v == NULL) {\n int rv = PyDict_DelItemString(fp->dict, name);\n if (rv < 0)\n PyErr_SetString(PyExc_AttributeError,\"delete non-existing fortran attribute\");\n return rv;\n }\n else\n return PyDict_SetItemString(fp->dict, name, v);\n}\n\nstatic PyObject*\nfortran_call(PyFortranObject *fp, PyObject *arg, PyObject *kw) {\n int i = 0;\n /* printf(\"fortran call\n name=%s,func=%p,data=%p,%p\\n\",fp->defs[i].name,\n fp->defs[i].func,fp->defs[i].data,&fp->defs[i].data); */\n if (fp->defs[i].rank==-1) {/* is Fortran routine */\n if ((fp->defs[i].func==NULL)) {\n PyErr_Format(PyExc_RuntimeError, \"no function to call\");\n return NULL;\n }\n else if (fp->defs[i].data==NULL)\n /* dummy routine */\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,NULL);\n else\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,\n\t\t\t\t\t\t (void *)fp->defs[i].data);\n }\n PyErr_Format(PyExc_TypeError, \"this fortran object is not callable\");\n return NULL;\n}\n\n\nPyTypeObject PyFortran_Type = {\n PyObject_HEAD_INIT(0)\n 0,\t\t\t/*ob_size*/\n \"fortran\",\t\t\t/*tp_name*/\n sizeof(PyFortranObject),\t/*tp_basicsize*/\n 0,\t\t\t/*tp_itemsize*/\n /* methods */\n (destructor)fortran_dealloc, /*tp_dealloc*/\n 0,\t\t\t/*tp_print*/\n (getattrfunc)fortran_getattr, /*tp_getattr*/\n (setattrfunc)fortran_setattr, /*tp_setattr*/\n 0,\t\t\t/*tp_compare*/\n 0,\t\t\t/*tp_repr*/\n 0,\t\t\t/*tp_as_number*/\n 0,\t\t\t/*tp_as_sequence*/\n 0,\t\t\t/*tp_as_mapping*/\n 0,\t\t\t/*tp_hash*/\n (ternaryfunc)fortran_call, /*tp_call*/\n};\n\n/************************* f2py_report_atexit *******************************/\n\n#ifdef F2PY_REPORT_ATEXIT\nstatic int passed_time = 0;\nstatic int passed_counter = 0;\nstatic int passed_call_time = 0;\nstatic struct timeb start_time;\nstatic struct timeb stop_time;\nstatic struct timeb start_call_time;\nstatic struct timeb stop_call_time;\nstatic int cb_passed_time = 0;\nstatic int cb_passed_counter = 0;\nstatic int cb_passed_call_time = 0;\nstatic struct timeb cb_start_time;\nstatic struct timeb cb_stop_time;\nstatic struct timeb cb_start_call_time;\nstatic struct timeb cb_stop_call_time;\n\nextern void f2py_start_clock(void) { ftime(&start_time); }\nextern\nvoid f2py_start_call_clock(void) {\n f2py_stop_clock();\n ftime(&start_call_time);\n}\nextern\nvoid f2py_stop_clock(void) {\n ftime(&stop_time);\n passed_time += 1000*(stop_time.time - start_time.time);\n passed_time += stop_time.millitm - start_time.millitm;\n}\nextern\nvoid f2py_stop_call_clock(void) {\n ftime(&stop_call_time);\n passed_call_time += 1000*(stop_call_time.time - start_call_time.time);\n passed_call_time += stop_call_time.millitm - start_call_time.millitm;\n passed_counter += 1;\n f2py_start_clock();\n}\n\nextern void f2py_cb_start_clock(void) { ftime(&cb_start_time); }\nextern\nvoid f2py_cb_start_call_clock(void) {\n f2py_cb_stop_clock();\n ftime(&cb_start_call_time);\n}\nextern\nvoid f2py_cb_stop_clock(void) {\n ftime(&cb_stop_time);\n cb_passed_time += 1000*(cb_stop_time.time - cb_start_time.time);\n cb_passed_time += cb_stop_time.millitm - cb_start_time.millitm;\n}\nextern\nvoid f2py_cb_stop_call_clock(void) {\n ftime(&cb_stop_call_time);\n cb_passed_call_time += 1000*(cb_stop_call_time.time - cb_start_call_time.time);\n cb_passed_call_time += cb_stop_call_time.millitm - cb_start_call_time.millitm;\n cb_passed_counter += 1;\n f2py_cb_start_clock();\n}\n\nstatic int f2py_report_on_exit_been_here = 0;\nextern\nvoid f2py_report_on_exit(int exit_flag,void *name) {\n if (f2py_report_on_exit_been_here) {\n fprintf(stderr,\" %s\\n\",(char*)name);\n return;\n }\n f2py_report_on_exit_been_here = 1;\n fprintf(stderr,\" /-----------------------\\\\\\n\");\n fprintf(stderr,\" < F2PY performance report >\\n\");\n fprintf(stderr,\" \\\\-----------------------/\\n\");\n fprintf(stderr,\"Overall time spent in ...\\n\");\n fprintf(stderr,\"(a) wrapped (Fortran/C) functions : %8d msec\\n\",\n\t passed_call_time);\n fprintf(stderr,\"(b) f2py interface, %6d calls : %8d msec\\n\",\n\t passed_counter,passed_time);\n fprintf(stderr,\"(c) call-back (Python) functions : %8d msec\\n\",\n\t cb_passed_call_time);\n fprintf(stderr,\"(d) f2py call-back interface, %6d calls : %8d msec\\n\",\n\t cb_passed_counter,cb_passed_time);\n \n fprintf(stderr,\"(e) wrapped (Fortran/C) functions (acctual) : %8d msec\\n\\n\",\n\t passed_call_time-cb_passed_call_time-cb_passed_time);\n fprintf(stderr,\"Use -DF2PY_REPORT_ATEXIT_DISABLE to disable this message.\\n\");\n fprintf(stderr,\"Exit status: %d\\n\",exit_flag);\n fprintf(stderr,\"Modules : %s\\n\",(char*)name);\n}\n#endif\n\n/********************** report on array copy ****************************/\n\n#ifdef F2PY_REPORT_ON_ARRAY_COPY\nstatic void f2py_report_on_array_copy(PyArrayObject* arr) {\n const long arr_size = PyArray_Size((PyObject *)arr);\n if (arr_size>F2PY_REPORT_ON_ARRAY_COPY) {\n fprintf(stderr,\"copied an array: size=%ld, elsize=%d\\n\", \n\t arr_size, PyArray_ITEMSIZE(arr));\n }\n}\nstatic void f2py_report_on_array_copy_fromany(void) {\n fprintf(stderr,\"created an array from object\\n\");\n}\n\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR f2py_report_on_array_copy((PyArrayObject *)arr)\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY f2py_report_on_array_copy_fromany()\n#else\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY\n#endif\n\n\n/************************* array_from_obj *******************************/\n\n/* \n * File: array_from_pyobj.c \n *\n * Description:\n * ------------ \n * Provides array_from_pyobj function that returns a contigious array\n * object with the given dimensions and required storage order, either\n * in row-major (C) or column-major (Fortran) order. The function\n * array_from_pyobj is very flexible about its Python object argument\n * that can be any number, list, tuple, or array.\n * \n * array_from_pyobj is used in f2py generated Python extension\n * modules.\n *\n * Author: Pearu Peterson \n * Created: 13-16 January 2002\n * $Id: fortranobject.c,v 1.52 2005/07/11 07:44:20 pearu Exp $\n */\n\nstatic int \ncount_nonpos(const int rank,\n\t const intp *dims) {\n int i=0,r=0;\n while (ind;\n intp size = PyArray_Size((PyObject *)arr);\n int i;\n printf(\"\\trank = %d, flags = %d, size = %\" INTP_FMT \"\\n\",\n\t rank,arr->flags,size);\n printf(\"\\tstrides = [\");\n for(i=0;istrides[i]);\n }\n printf(\"]\\n\\t dimensions = [\");\n for(i=0;idimensions[i]);\n }\n printf(\"]\\n\");\n}\n#endif\n\n#define SWAPTYPE(a,b,t) {t c; c = (a); (a) = (b); (b) = c; }\n\nstatic int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) {\n SWAPTYPE(arr1->data,arr2->data,char*);\n SWAPTYPE(arr1->nd,arr2->nd,int);\n SWAPTYPE(arr1->dimensions,arr2->dimensions,intp*);\n SWAPTYPE(arr1->strides,arr2->strides,intp*);\n SWAPTYPE(arr1->base,arr2->base,PyObject*);\n SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*);\n SWAPTYPE(arr1->flags,arr2->flags,int);\n /* SWAPTYPE(arr1->weakreflist,arr2->weakreflist,PyObject*); */\n return 0;\n}\n\n#define ARRAY_ISCOMPATIBLE(arr,type_num) \\\n( (PyArray_ISINTEGER(arr) && PyTypeNum_ISINTEGER(type_num)) \\\n ||(PyArray_ISFLOAT(arr) && PyTypeNum_ISFLOAT(type_num)) \\\n ||(PyArray_ISCOMPLEX(arr) && PyTypeNum_ISCOMPLEX(type_num)) \\\n)\n\nextern\nPyArrayObject* array_from_pyobj(const int type_num,\n\t\t\t\tintp *dims,\n\t\t\t\tconst int rank,\n\t\t\t\tconst int intent,\n\t\t\t\tPyObject *obj) {\n /* Note about reference counting\n -----------------------------\n If the caller returns the array to Python, it must be done with\n Py_BuildValue(\"N\",arr).\n Otherwise, if obj!=arr then the caller must call Py_DECREF(arr).\n\n Note on intent(cache,out,..)\n ---------------------\n Don't expect correct data when returning intent(cache) array.\n\n */\n char mess[200];\n PyArrayObject *arr = NULL;\n PyArray_Descr *descr = PyArray_DescrFromType(type_num);\n\n if ((intent & F2PY_INTENT_HIDE)\n || ((intent & F2PY_INTENT_CACHE) && (obj==Py_None))\n || ((intent & F2PY_OPTIONAL) && (obj==Py_None))\n ) {\n /* intent(cache), optional, intent(hide) */\n if (count_nonpos(rank,dims)) {\n int i;\n sprintf(mess,\"failed to create intent(cache|hide)|optional array\"\n\t \"-- must have defined dimensions but got (\");\n for(i=0;i=descr->elsize) {\n\tif (check_and_fix_dimensions((PyArrayObject *)obj,rank,dims))\n\t return NULL; /*XXX: set exception */\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(obj);\n\treturn (PyArrayObject *)obj;\n }\n sprintf(mess,\"failed to initialize intent(cache) array\");\n if (!PyArray_ISONESEGMENT(obj))\n\tsprintf(mess+strlen(mess),\" -- input must be in one segment\");\n if (PyArray_ITEMSIZE(arr)elsize)\n\tsprintf(mess+strlen(mess),\" -- expected at least elsize=%d but got %d\",\n\t\tdescr->elsize,PyArray_ITEMSIZE(arr)\n\t\t);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inout) or intent(inplace) */\n\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n\n if ((! (intent & F2PY_INTENT_COPY))\n\t&& PyArray_ITEMSIZE(arr)==descr->elsize\n\t&& ARRAY_ISCOMPATIBLE(arr,type_num)\n\t) {\n if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) {\n\tif ((intent & F2PY_INTENT_OUT)) {\n\t Py_INCREF(arr);\n\t}\n\t/* Returning input array */\n\treturn arr;\n }\n }\n\n if (intent & F2PY_INTENT_INOUT) {\n sprintf(mess,\"failed to initialize intent(inout) array\");\n if ((intent & F2PY_INTENT_C) && !PyArray_ISCARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not contiguous\");\n if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not fortran contiguous\");\n if (PyArray_ITEMSIZE(arr)!=descr->elsize)\n\tsprintf(mess+strlen(mess),\" -- expected elsize=%d but got %d\",\n\t\tdescr->elsize,\n\t\tPyArray_ITEMSIZE(arr)\n\t\t);\n if (!(ARRAY_ISCOMPATIBLE(arr,type_num)))\n\tsprintf(mess+strlen(mess),\" -- input '%c' not compatible to '%c'\",\n\t\tarr->descr->type,descr->type);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inplace) */\n\n {\n PyArrayObject *retarr = (PyArrayObject *) \\\n\tPyArray_New(&PyArray_Type, arr->nd, arr->dimensions, type_num,\n\t\t NULL,NULL,0,\n\t\t !(intent&F2PY_INTENT_C),\n\t\t NULL);\n if (retarr==NULL)\n\treturn NULL;\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n if (PyArray_CopyInto(retarr, arr)) {\n\tPy_DECREF(retarr);\n\treturn NULL;\n }\n if (intent & F2PY_INTENT_INPLACE) {\n\tif (swap_arrays(arr,retarr))\n\t return NULL; /* XXX: set exception */\n\tPy_XDECREF(retarr);\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(arr);\n } else {\n\tarr = retarr;\n }\n }\n return arr;\n }\n\n if ((intent & F2PY_INTENT_INOUT) \n || (intent & F2PY_INTENT_INPLACE)\n || (intent & F2PY_INTENT_CACHE)) {\n sprintf(mess,\"failed to initialize intent(inout|inplace|cache) array\"\n\t \" -- input must be array but got %s\",\n\t PyString_AsString(PyObject_Str(PyObject_Type(obj)))\n\t );\n PyErr_SetString(PyExc_TypeError,mess);\n return NULL;\n }\n\n {\n F2PY_REPORT_ON_ARRAY_COPY_FROMANY;\n arr = (PyArrayObject *) \\\n PyArray_FromAny(obj,PyArray_DescrFromType(type_num), 0,0,\n\t\t ((intent & F2PY_INTENT_C)?CARRAY_FLAGS:FARRAY_FLAGS) \\\n | FORCECAST, NULL);\n if (arr==NULL)\n return NULL;\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n return arr;\n }\n\n}\n\n /*****************************************/\n /* Helper functions for array_from_pyobj */\n /*****************************************/\n\nstatic\nint check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims) {\n /*\n This function fills in blanks (that are -1\\'s) in dims list using\n the dimensions from arr. It also checks that non-blank dims will\n match with the corresponding values in arr dimensions.\n */\n const intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;\n\n if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */\n intp new_size = 1;\n int free_axe = -1;\n int i;\n /* Fill dims where -1 or 0; check dimensions; calc new_size; */\n for(i=0;ind;++i) { \n if (dims[i] >= 0) {\n\tif (dims[i]!=arr->dimensions[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT\n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i], arr->dimensions[i]);\n\t return 1;\n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else {\n\tdims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1;\n }\n new_size *= dims[i];\n }\n for(i=arr->nd;i1) {\n\tfprintf(stderr,\"%d-th dimension must be %\" INTP_FMT\n\t\t\" but got 0 (not defined).\\n\",\n\t\ti,dims[i]);\n\treturn 1;\n } else if (free_axe<0)\n\tfree_axe = i;\n else\n\tdims[i] = 1;\n if (free_axe>=0) {\n dims[free_axe] = arr_size/new_size;\n new_size *= dims[free_axe];\n }\n if (new_size != arr_size) {\n fprintf(stderr,\"confused: new_size=%\" INTP_FMT\n\t \", arr_size=%\" INTP_FMT \" (maybe too many free\"\n\t \" indices)\\n\", new_size,arr_size);\n return 1;\n }\n } else { /* [[1,2]] -> [[1],[2]] */\n int i,j;\n intp d;\n int effrank;\n intp size;\n for (i=0,effrank=0;ind;++i)\n if (arr->dimensions[i]>1) ++effrank;\n if (dims[rank-1]>=0)\n if (effrank>rank) {\n\tfprintf(stderr,\"too many axes: %d (effrank=%d), expected rank=%d\\n\",\n\t\tarr->nd,effrank,rank);\n\treturn 1;\n }\n /*\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n if (dims[i]>=0) {\n\tif (d>1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \" (real index=%d)\\n\",\n\t\t i,dims[i],d,j-1);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else\n\tdims[i] = d;\n }\n */\n for (i=0; idimensions[i];\n if (dims[i]>=0) {\n\tif (d > 1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i],d);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else dims[i] = d;\n }\n for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */\n while (jnd && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n dims[rank-1] *= d;\n }\n for (i=0,size=1;ind);\n for (i=0;ind;++i) fprintf(stderr,\" %\" INTP_FMT,arr->dimensions[i]);\n fprintf(stderr,\" ]\\n\");\n return 1;\n }\n }\n return 0;\n}\n\n/* End of file: array_from_pyobj.c */\n\n/************************* copy_ND_array *******************************/\n\nextern\nint copy_ND_array(const PyArrayObject *arr, PyArrayObject *out)\n{\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n return PyArray_CopyInto(out, (PyArrayObject *)arr);\n}\n\n#ifdef __cplusplus\n}\n#endif\n/************************* EOF fortranobject.c *******************************/\n", + "source_code_before": "#define FORTRANOBJECT_C\n#include \"fortranobject.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/*\n This file implements: FortranObject, array_from_pyobj, copy_ND_array\n\n Author: Pearu Peterson \n $Revision: 1.52 $\n $Date: 2005/07/11 07:44:20 $\n*/\n\n/************************* FortranObject *******************************/\n\ntypedef PyObject *(*fortranfunc)(PyObject *,PyObject *,PyObject *,void *);\n\nPyObject *\nPyFortranObject_New(FortranDataDef* defs, f2py_void_func init) {\n int i;\n PyFortranObject *fp = NULL;\n PyObject *v = NULL;\n if (init!=NULL) /* Initialize F90 module objects */\n (*(init))();\n if ((fp = PyObject_New(PyFortranObject, &PyFortran_Type))==NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 0;\n while (defs[fp->len].name != NULL) fp->len++;\n if (fp->len == 0) goto fail;\n fp->defs = defs;\n for (i=0;ilen;i++)\n if (fp->defs[i].rank == -1) { /* Is Fortran routine */\n v = PyFortranObject_NewAsAttr(&(fp->defs[i]));\n if (v==NULL) return NULL;\n PyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n } else\n if ((fp->defs[i].data)!=NULL) { /* Is Fortran variable or array (not allocatable) */\n\tv = PyArray_New(&PyArray_Type, fp->defs[i].rank, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\tPyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n }\n Py_XDECREF(v);\n return (PyObject *)fp;\n fail:\n Py_XDECREF(v);\n return NULL;\n}\n\nPyObject *\nPyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module routines */\n PyFortranObject *fp = NULL;\n fp = PyObject_New(PyFortranObject, &PyFortran_Type);\n if (fp == NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 1;\n fp->defs = defs;\n return (PyObject *)fp;\n}\n\n/* Fortran methods */\n\nstatic void\nfortran_dealloc(PyFortranObject *fp) {\n Py_XDECREF(fp->dict);\n PyMem_Del(fp);\n}\n\n\nstatic PyMethodDef fortran_methods[] = {\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyObject *\nfortran_doc (FortranDataDef def) {\n char *p;\n PyObject *s = NULL;\n int i;\n unsigned size=100;\n if (def.doc!=NULL)\n size += strlen(def.doc);\n p = (char*)malloc (size);\n if (sprintf(p,\"%s - \",def.name)==0) goto fail;\n if (def.rank==-1) {\n if (def.doc==NULL) {\n if (sprintf(p,\"%sno docs available\",p)==0)\n\tgoto fail;\n } else {\n if (sprintf(p,\"%s%s\",p,def.doc)==0)\n\tgoto fail;\n }\n } else {\n PyArray_Descr *d = PyArray_DescrFromType(def.type);\n if (sprintf(p,\"%s'%c'-\",p,d->type)==0) goto fail;\n if (def.data==NULL) {\n if (sprintf(p,\"%sarray(%\" INTP_FMT,p,def.dims.d[0])==0) goto fail;\n for(i=1;i0) {\n\tif (sprintf(p,\"%sarray(%\"INTP_FMT,p,def.dims.d[0])==0) goto fail;\n\tfor(i=1;isize) {\n fprintf(stderr,\"fortranobject.c:fortran_doc:len(p)=%zd>%d(size): too long doc string required, increase size\\n\",strlen(p),size);\n goto fail;\n }\n s = PyString_FromString(p);\n fail:\n free(p);\n return s;\n}\n\nstatic FortranDataDef *save_def; /* save pointer of an allocatable array */\nstatic void set_data(char *d,intp *f) { /* callback from Fortran */\n if (*f) /* In fortran f=allocated(d) */\n save_def->data = d;\n else\n save_def->data = NULL;\n /* printf(\"set_data: d=%p,f=%d\\n\",d,*f); */\n}\n\nstatic PyObject *\nfortran_getattr(PyFortranObject *fp, char *name) {\n int i,j,k,flag;\n if (fp->dict != NULL) {\n PyObject *v = PyDict_GetItemString(fp->dict, name);\n if (v != NULL) {\n Py_INCREF(v);\n return v;\n }\n }\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0)\n if (fp->defs[i].rank!=-1) { /* F90 allocatable array */ \n if (fp->defs[i].func==NULL) return NULL;\n for(k=0;kdefs[i].rank;++k) \n\tfp->defs[i].dims.d[k]=-1;\n save_def = &fp->defs[i];\n (*(fp->defs[i].func))(&fp->defs[i].rank,fp->defs[i].dims.d,set_data,&flag);\n if (flag==2)\n\tk = fp->defs[i].rank + 1;\n else\n\tk = fp->defs[i].rank;\n if (fp->defs[i].data !=NULL) { /* array is allocated */\n\tPyObject *v = PyArray_New(&PyArray_Type, k, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\t/* Py_INCREF(v); */\n\treturn v;\n } else { /* array is not allocated */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n }\n }\n if (strcmp(name,\"__dict__\")==0) {\n Py_INCREF(fp->dict);\n return fp->dict;\n }\n if (strcmp(name,\"__doc__\")==0) {\n PyObject *s = PyString_FromString(\"\");\n for (i=0;ilen;i++)\n PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i]));\n if (PyDict_SetItemString(fp->dict, name, s))\n return NULL;\n return s;\n }\n if ((strcmp(name,\"_cpointer\")==0) && (fp->len==1)) {\n PyObject *cobj = PyCObject_FromVoidPtr((void *)(fp->defs[0].data),NULL);\n if (PyDict_SetItemString(fp->dict, name, cobj))\n return NULL;\n return cobj;\n }\n return Py_FindMethod(fortran_methods, (PyObject *)fp, name);\n}\n\nstatic int\nfortran_setattr(PyFortranObject *fp, char *name, PyObject *v) {\n int i,j,flag;\n PyArrayObject *arr = NULL;\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0) {\n if (fp->defs[i].rank==-1) {\n PyErr_SetString(PyExc_AttributeError,\"over-writing fortran routine\");\n return -1;\n }\n if (fp->defs[i].func!=NULL) { /* is allocatable array */\n intp dims[F2PY_MAX_DIMS];\n int k;\n save_def = &fp->defs[i];\n if (v!=Py_None) { /* set new value (reallocate if needed --\n\t\t\t see f2py generated code for more\n\t\t\t details ) */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n\tif ((arr = array_from_pyobj(fp->defs[i].type,dims,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\t return -1;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,arr->dimensions,set_data,&flag);\n } else { /* deallocate */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=0;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n }\n memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(intp));\n } else { /* not allocatable array */\n if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\treturn -1; \n }\n if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */\n intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);\n if (s==-1)\n\ts = PyArray_MultiplyList(arr->dimensions,arr->nd);\n if (s<0 ||\n\t (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) {\n\tif ((PyObject*)arr!=v) {\n\t Py_DECREF(arr);\n\t}\n\treturn -1;\n }\n if ((PyObject*)arr!=v) {\n Py_DECREF(arr);\n }\n } else return (fp->defs[i].func==NULL?-1:0);\n return 0; /* succesful */\n }\n if (fp->dict == NULL) {\n fp->dict = PyDict_New();\n if (fp->dict == NULL)\n return -1;\n }\n if (v == NULL) {\n int rv = PyDict_DelItemString(fp->dict, name);\n if (rv < 0)\n PyErr_SetString(PyExc_AttributeError,\"delete non-existing fortran attribute\");\n return rv;\n }\n else\n return PyDict_SetItemString(fp->dict, name, v);\n}\n\nstatic PyObject*\nfortran_call(PyFortranObject *fp, PyObject *arg, PyObject *kw) {\n int i = 0;\n /* printf(\"fortran call\n name=%s,func=%p,data=%p,%p\\n\",fp->defs[i].name,\n fp->defs[i].func,fp->defs[i].data,&fp->defs[i].data); */\n if (fp->defs[i].rank==-1) {/* is Fortran routine */\n if ((fp->defs[i].func==NULL)) {\n PyErr_Format(PyExc_RuntimeError, \"no function to call\");\n return NULL;\n }\n else if (fp->defs[i].data==NULL)\n /* dummy routine */\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,NULL);\n else\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,\n\t\t\t\t\t\t (void *)fp->defs[i].data);\n }\n PyErr_Format(PyExc_TypeError, \"this fortran object is not callable\");\n return NULL;\n}\n\n\nPyTypeObject PyFortran_Type = {\n PyObject_HEAD_INIT(0)\n 0,\t\t\t/*ob_size*/\n \"fortran\",\t\t\t/*tp_name*/\n sizeof(PyFortranObject),\t/*tp_basicsize*/\n 0,\t\t\t/*tp_itemsize*/\n /* methods */\n (destructor)fortran_dealloc, /*tp_dealloc*/\n 0,\t\t\t/*tp_print*/\n (getattrfunc)fortran_getattr, /*tp_getattr*/\n (setattrfunc)fortran_setattr, /*tp_setattr*/\n 0,\t\t\t/*tp_compare*/\n 0,\t\t\t/*tp_repr*/\n 0,\t\t\t/*tp_as_number*/\n 0,\t\t\t/*tp_as_sequence*/\n 0,\t\t\t/*tp_as_mapping*/\n 0,\t\t\t/*tp_hash*/\n (ternaryfunc)fortran_call, /*tp_call*/\n};\n\n/************************* f2py_report_atexit *******************************/\n\n#ifdef F2PY_REPORT_ATEXIT\nstatic int passed_time = 0;\nstatic int passed_counter = 0;\nstatic int passed_call_time = 0;\nstatic struct timeb start_time;\nstatic struct timeb stop_time;\nstatic struct timeb start_call_time;\nstatic struct timeb stop_call_time;\nstatic int cb_passed_time = 0;\nstatic int cb_passed_counter = 0;\nstatic int cb_passed_call_time = 0;\nstatic struct timeb cb_start_time;\nstatic struct timeb cb_stop_time;\nstatic struct timeb cb_start_call_time;\nstatic struct timeb cb_stop_call_time;\n\nextern void f2py_start_clock(void) { ftime(&start_time); }\nextern\nvoid f2py_start_call_clock(void) {\n f2py_stop_clock();\n ftime(&start_call_time);\n}\nextern\nvoid f2py_stop_clock(void) {\n ftime(&stop_time);\n passed_time += 1000*(stop_time.time - start_time.time);\n passed_time += stop_time.millitm - start_time.millitm;\n}\nextern\nvoid f2py_stop_call_clock(void) {\n ftime(&stop_call_time);\n passed_call_time += 1000*(stop_call_time.time - start_call_time.time);\n passed_call_time += stop_call_time.millitm - start_call_time.millitm;\n passed_counter += 1;\n f2py_start_clock();\n}\n\nextern void f2py_cb_start_clock(void) { ftime(&cb_start_time); }\nextern\nvoid f2py_cb_start_call_clock(void) {\n f2py_cb_stop_clock();\n ftime(&cb_start_call_time);\n}\nextern\nvoid f2py_cb_stop_clock(void) {\n ftime(&cb_stop_time);\n cb_passed_time += 1000*(cb_stop_time.time - cb_start_time.time);\n cb_passed_time += cb_stop_time.millitm - cb_start_time.millitm;\n}\nextern\nvoid f2py_cb_stop_call_clock(void) {\n ftime(&cb_stop_call_time);\n cb_passed_call_time += 1000*(cb_stop_call_time.time - cb_start_call_time.time);\n cb_passed_call_time += cb_stop_call_time.millitm - cb_start_call_time.millitm;\n cb_passed_counter += 1;\n f2py_cb_start_clock();\n}\n\nstatic int f2py_report_on_exit_been_here = 0;\nextern\nvoid f2py_report_on_exit(int exit_flag,void *name) {\n if (f2py_report_on_exit_been_here) {\n fprintf(stderr,\" %s\\n\",(char*)name);\n return;\n }\n f2py_report_on_exit_been_here = 1;\n fprintf(stderr,\" /-----------------------\\\\\\n\");\n fprintf(stderr,\" < F2PY performance report >\\n\");\n fprintf(stderr,\" \\\\-----------------------/\\n\");\n fprintf(stderr,\"Overall time spent in ...\\n\");\n fprintf(stderr,\"(a) wrapped (Fortran/C) functions : %8d msec\\n\",\n\t passed_call_time);\n fprintf(stderr,\"(b) f2py interface, %6d calls : %8d msec\\n\",\n\t passed_counter,passed_time);\n fprintf(stderr,\"(c) call-back (Python) functions : %8d msec\\n\",\n\t cb_passed_call_time);\n fprintf(stderr,\"(d) f2py call-back interface, %6d calls : %8d msec\\n\",\n\t cb_passed_counter,cb_passed_time);\n \n fprintf(stderr,\"(e) wrapped (Fortran/C) functions (acctual) : %8d msec\\n\\n\",\n\t passed_call_time-cb_passed_call_time-cb_passed_time);\n fprintf(stderr,\"Use -DF2PY_REPORT_ATEXIT_DISABLE to disable this message.\\n\");\n fprintf(stderr,\"Exit status: %d\\n\",exit_flag);\n fprintf(stderr,\"Modules : %s\\n\",(char*)name);\n}\n#endif\n\n/********************** report on array copy ****************************/\n\n#ifdef F2PY_REPORT_ON_ARRAY_COPY\nstatic void f2py_report_on_array_copy(PyArrayObject* arr) {\n const long arr_size = PyArray_Size((PyObject *)arr);\n if (arr_size>F2PY_REPORT_ON_ARRAY_COPY) {\n fprintf(stderr,\"copied an array: size=%ld, elsize=%d\\n\", \n\t arr_size, PyArray_ITEMSIZE(arr));\n }\n}\nstatic void f2py_report_on_array_copy_fromany(void) {\n fprintf(stderr,\"created an array from object\\n\");\n}\n\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR f2py_report_on_array_copy((PyArrayObject *)arr)\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY f2py_report_on_array_copy_fromany()\n#else\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY\n#endif\n\n\n/************************* array_from_obj *******************************/\n\n/* \n * File: array_from_pyobj.c \n *\n * Description:\n * ------------ \n * Provides array_from_pyobj function that returns a contigious array\n * object with the given dimensions and required storage order, either\n * in row-major (C) or column-major (Fortran) order. The function\n * array_from_pyobj is very flexible about its Python object argument\n * that can be any number, list, tuple, or array.\n * \n * array_from_pyobj is used in f2py generated Python extension\n * modules.\n *\n * Author: Pearu Peterson \n * Created: 13-16 January 2002\n * $Id: fortranobject.c,v 1.52 2005/07/11 07:44:20 pearu Exp $\n */\n\nstatic int \ncount_nonpos(const int rank,\n\t const intp *dims) {\n int i=0,r=0;\n while (ind;\n intp size = PyArray_Size((PyObject *)arr);\n int i;\n printf(\"\\trank = %d, flags = %d, size = %\" INTP_FMT \"\\n\",\n\t rank,arr->flags,size);\n printf(\"\\tstrides = [\");\n for(i=0;istrides[i]);\n }\n printf(\"]\\n\\t dimensions = [\");\n for(i=0;idimensions[i]);\n }\n printf(\"]\\n\");\n}\n#endif\n\n#define SWAPTYPE(a,b,t) {t c; c = (a); (a) = (b); (b) = c; }\n\nstatic int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) {\n SWAPTYPE(arr1->data,arr2->data,char*);\n SWAPTYPE(arr1->nd,arr2->nd,int);\n SWAPTYPE(arr1->dimensions,arr2->dimensions,intp*);\n SWAPTYPE(arr1->strides,arr2->strides,intp*);\n SWAPTYPE(arr1->base,arr2->base,PyObject*);\n SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*);\n SWAPTYPE(arr1->flags,arr2->flags,int);\n /* SWAPTYPE(arr1->weakreflist,arr2->weakreflist,PyObject*); */\n return 0;\n}\n\n#define ARRAY_ISCOMPATIBLE(arr,type_num) \\\n( (PyArray_ISINTEGER(arr) && PyTypeNum_ISINTEGER(type_num)) \\\n ||(PyArray_ISFLOAT(arr) && PyTypeNum_ISFLOAT(type_num)) \\\n ||(PyArray_ISCOMPLEX(arr) && PyTypeNum_ISCOMPLEX(type_num)) \\\n)\n\nextern\nPyArrayObject* array_from_pyobj(const int type_num,\n\t\t\t\tintp *dims,\n\t\t\t\tconst int rank,\n\t\t\t\tconst int intent,\n\t\t\t\tPyObject *obj) {\n /* Note about reference counting\n -----------------------------\n If the caller returns the array to Python, it must be done with\n Py_BuildValue(\"N\",arr).\n Otherwise, if obj!=arr then the caller must call Py_DECREF(arr).\n\n Note on intent(cache,out,..)\n ---------------------\n Don't expect correct data when returning intent(cache) array.\n\n */\n char mess[200];\n PyArrayObject *arr = NULL;\n PyArray_Descr *descr = PyArray_DescrFromType(type_num);\n\n if ((intent & F2PY_INTENT_HIDE)\n || ((intent & F2PY_INTENT_CACHE) && (obj==Py_None))\n || ((intent & F2PY_OPTIONAL) && (obj==Py_None))\n ) {\n /* intent(cache), optional, intent(hide) */\n if (count_nonpos(rank,dims)) {\n int i;\n sprintf(mess,\"failed to create intent(cache|hide)|optional array\"\n\t \"-- must have defined dimensions but got (\");\n for(i=0;i=descr->elsize) {\n\tif (check_and_fix_dimensions((PyArrayObject *)obj,rank,dims))\n\t return NULL; /*XXX: set exception */\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(obj);\n\treturn (PyArrayObject *)obj;\n }\n sprintf(mess,\"failed to initialize intent(cache) array\");\n if (!PyArray_ISONESEGMENT(obj))\n\tsprintf(mess+strlen(mess),\" -- input must be in one segment\");\n if (PyArray_ITEMSIZE(arr)elsize)\n\tsprintf(mess+strlen(mess),\" -- expected at least elsize=%d but got %d\",\n\t\tdescr->elsize,PyArray_ITEMSIZE(arr)\n\t\t);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inout) or intent(inplace) */\n\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n\n if ((! (intent & F2PY_INTENT_COPY))\n\t&& PyArray_ITEMSIZE(arr)==descr->elsize\n\t&& ARRAY_ISCOMPATIBLE(arr,type_num)\n\t) {\n if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) {\n\tif ((intent & F2PY_INTENT_OUT)) {\n\t Py_INCREF(arr);\n\t}\n\t/* Returning input array */\n\treturn arr;\n }\n }\n\n if (intent & F2PY_INTENT_INOUT) {\n sprintf(mess,\"failed to initialize intent(inout) array\");\n if ((intent & F2PY_INTENT_C) && !PyArray_ISCARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not contiguous\");\n if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not fortran contiguous\");\n if (PyArray_ITEMSIZE(arr)!=descr->elsize)\n\tsprintf(mess+strlen(mess),\" -- expected elsize=%d but got %d\",\n\t\tdescr->elsize,\n\t\tPyArray_ITEMSIZE(arr)\n\t\t);\n if (!(ARRAY_ISCOMPATIBLE(arr,type_num)))\n\tsprintf(mess+strlen(mess),\" -- input '%c' not compatible to '%c'\",\n\t\tarr->descr->type,descr->type);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inplace) */\n\n {\n PyArrayObject *retarr = (PyArrayObject *) \\\n\tPyArray_New(&PyArray_Type, arr->nd, arr->dimensions, type_num,\n\t\t NULL,NULL,0,\n\t\t !(intent&F2PY_INTENT_C),\n\t\t NULL);\n if (retarr==NULL)\n\treturn NULL;\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n if (PyArray_CopyInto(retarr, arr)) {\n\tPy_DECREF(retarr);\n\treturn NULL;\n }\n if (intent & F2PY_INTENT_INPLACE) {\n\tif (swap_arrays(arr,retarr))\n\t return NULL; /* XXX: set exception */\n\tPy_XDECREF(retarr);\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(arr);\n } else {\n\tarr = retarr;\n }\n }\n return arr;\n }\n\n if ((intent & F2PY_INTENT_INOUT) \n || (intent & F2PY_INTENT_INPLACE)\n || (intent & F2PY_INTENT_CACHE)) {\n sprintf(mess,\"failed to initialize intent(inout|inplace|cache) array\"\n\t \" -- input must be array but got %s\",\n\t PyString_AsString(PyObject_Str(PyObject_Type(obj)))\n\t );\n PyErr_SetString(PyExc_TypeError,mess);\n return NULL;\n }\n\n {\n F2PY_REPORT_ON_ARRAY_COPY_FROMANY;\n arr = (PyArrayObject *) \\\n PyArray_FromAny(obj,PyArray_DescrFromType(type_num), 0,0,\n\t\t ((intent & F2PY_INTENT_C)?CARRAY_FLAGS:FARRAY_FLAGS) \\\n | FORCECAST, NULL);\n if (arr==NULL)\n return NULL;\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n return arr;\n }\n\n}\n\n /*****************************************/\n /* Helper functions for array_from_pyobj */\n /*****************************************/\n\nstatic\nint check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims) {\n /*\n This function fills in blanks (that are -1\\'s) in dims list using\n the dimensions from arr. It also checks that non-blank dims will\n match with the corresponding values in arr dimensions.\n */\n const intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;\n\n if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */\n intp new_size = 1;\n int free_axe = -1;\n int i;\n /* Fill dims where -1 or 0; check dimensions; calc new_size; */\n for(i=0;ind;++i) { \n if (dims[i] >= 0) {\n\tif (dims[i]!=arr->dimensions[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT\n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i], arr->dimensions[i]);\n\t return 1;\n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else {\n\tdims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1;\n }\n new_size *= dims[i];\n }\n for(i=arr->nd;i1) {\n\tfprintf(stderr,\"%d-th dimension must be %\" INTP_FMT\n\t\t\" but got 0 (not defined).\\n\",\n\t\ti,dims[i]);\n\treturn 1;\n } else if (free_axe<0)\n\tfree_axe = i;\n else\n\tdims[i] = 1;\n if (free_axe>=0) {\n dims[free_axe] = arr_size/new_size;\n new_size *= dims[free_axe];\n }\n if (new_size != arr_size) {\n fprintf(stderr,\"confused: new_size=%\" INTP_FMT\n\t \", arr_size=%\" INTP_FMT \" (maybe too many free\"\n\t \" indices)\\n\", new_size,arr_size);\n return 1;\n }\n } else { /* [[1,2]] -> [[1],[2]] */\n int i,j;\n intp d;\n int effrank;\n intp size;\n for (i=0,effrank=0;ind;++i)\n if (arr->dimensions[i]>1) ++effrank;\n if (dims[rank-1]>=0)\n if (effrank>rank) {\n\tfprintf(stderr,\"too many axes: %d (effrank=%d), expected rank=%d\\n\",\n\t\tarr->nd,effrank,rank);\n\treturn 1;\n }\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n if (dims[i]>=0) {\n\tif (d>1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \" (real index=%d)\\n\",\n\t\t i,dims[i],d,j-1);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else\n\tdims[i] = d;\n }\n for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */\n while (jnd && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n dims[rank-1] *= d;\n }\n for (i=0,size=1;ind);\n for (i=0;ind;++i) fprintf(stderr,\" %\" INTP_FMT,arr->dimensions[i]);\n fprintf(stderr,\" ]\\n\");\n return 1;\n }\n }\n return 0;\n}\n\n/* End of file: array_from_pyobj.c */\n\n/************************* copy_ND_array *******************************/\n\nextern\nint copy_ND_array(const PyArrayObject *arr, PyArrayObject *out)\n{\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n return PyArray_CopyInto(out, (PyArrayObject *)arr);\n}\n\n#ifdef __cplusplus\n}\n#endif\n/************************* EOF fortranobject.c *******************************/\n", + "methods": [ + { + "name": "PyFortranObject_New", + "long_name": "PyFortranObject_New( FortranDataDef * defs , f2py_void_func init)", + "filename": "fortranobject.c", + "nloc": 31, + "complexity": 11, + "token_count": 312, + "parameters": [ + "defs", + "init" + ], + "start_line": 20, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "PyFortranObject_NewAsAttr", + "long_name": "PyFortranObject_NewAsAttr( FortranDataDef * defs)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 69, + "parameters": [ + "defs" + ], + "start_line": 53, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "fortran_dealloc", + "long_name": "fortran_dealloc( PyFortranObject * fp)", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "fp" + ], + "start_line": 66, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "fortran_doc", + "long_name": "fortran_doc( FortranDataDef def)", + "filename": "fortranobject.c", + "nloc": 46, + "complexity": 21, + "token_count": 434, + "parameters": [ + "def" + ], + "start_line": 78, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "set_data", + "long_name": "set_data( char * d , intp * f)", + "filename": "fortranobject.c", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "d", + "f" + ], + "start_line": 126, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "fortran_getattr", + "long_name": "fortran_getattr( PyFortranObject * fp , char * name)", + "filename": "fortranobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 519, + "parameters": [ + "fp", + "name" + ], + "start_line": 135, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "fortran_setattr", + "long_name": "fortran_setattr( PyFortranObject * fp , char * name , PyObject * v)", + "filename": "fortranobject.c", + "nloc": 59, + "complexity": 22, + "token_count": 647, + "parameters": [ + "fp", + "name", + "v" + ], + "start_line": 190, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 1 + }, + { + "name": "fortran_call", + "long_name": "fortran_call( PyFortranObject * fp , PyObject * arg , PyObject * kw)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 166, + "parameters": [ + "fp", + "arg", + "kw" + ], + "start_line": 253, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_clock", + "long_name": "f2py_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 313, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_call_clock", + "long_name": "f2py_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 315, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_clock", + "long_name": "f2py_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 320, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_call_clock", + "long_name": "f2py_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 326, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_clock", + "long_name": "f2py_cb_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 334, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_call_clock", + "long_name": "f2py_cb_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_clock", + "long_name": "f2py_cb_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_call_clock", + "long_name": "f2py_cb_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 347, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_exit", + "long_name": "f2py_report_on_exit( int exit_flag , * name)", + "filename": "fortranobject.c", + "nloc": 24, + "complexity": 2, + "token_count": 146, + "parameters": [ + "exit_flag", + "name" + ], + "start_line": 357, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy", + "long_name": "f2py_report_on_array_copy( PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "arr" + ], + "start_line": 387, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy_fromany", + "long_name": "f2py_report_on_array_copy_fromany()", + "filename": "fortranobject.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 394, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "count_nonpos", + "long_name": "count_nonpos( const int rank , const intp * dims)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 48, + "parameters": [ + "rank", + "dims" + ], + "start_line": 428, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "dump_attrs", + "long_name": "dump_attrs( const PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 3, + "token_count": 117, + "parameters": [ + "arr" + ], + "start_line": 443, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "swap_arrays", + "long_name": "swap_arrays( PyArrayObject * arr1 , PyArrayObject * arr2)", + "filename": "fortranobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 111, + "parameters": [ + "arr1", + "arr2" + ], + "start_line": 463, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "array_from_pyobj", + "long_name": "array_from_pyobj( const int type_num , intp * dims , const int rank , const int intent , PyObject * obj)", + "filename": "fortranobject.c", + "nloc": 130, + "complexity": 42, + "token_count": 825, + "parameters": [ + "type_num", + "dims", + "rank", + "intent", + "obj" + ], + "start_line": 482, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 158, + "top_nesting_level": 1 + }, + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 85, + "complexity": 30, + "token_count": 682, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 754, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 1 + }, + { + "name": "copy_ND_array", + "long_name": "copy_ND_array( const PyArrayObject * arr , PyArrayObject * out)", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "arr", + "out" + ], + "start_line": 761, + "end_line": 765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "PyFortranObject_New", + "long_name": "PyFortranObject_New( FortranDataDef * defs , f2py_void_func init)", + "filename": "fortranobject.c", + "nloc": 31, + "complexity": 11, + "token_count": 312, + "parameters": [ + "defs", + "init" + ], + "start_line": 20, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "PyFortranObject_NewAsAttr", + "long_name": "PyFortranObject_NewAsAttr( FortranDataDef * defs)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 69, + "parameters": [ + "defs" + ], + "start_line": 53, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "fortran_dealloc", + "long_name": "fortran_dealloc( PyFortranObject * fp)", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "fp" + ], + "start_line": 66, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "fortran_doc", + "long_name": "fortran_doc( FortranDataDef def)", + "filename": "fortranobject.c", + "nloc": 46, + "complexity": 21, + "token_count": 434, + "parameters": [ + "def" + ], + "start_line": 78, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "set_data", + "long_name": "set_data( char * d , intp * f)", + "filename": "fortranobject.c", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "d", + "f" + ], + "start_line": 126, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "fortran_getattr", + "long_name": "fortran_getattr( PyFortranObject * fp , char * name)", + "filename": "fortranobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 519, + "parameters": [ + "fp", + "name" + ], + "start_line": 135, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "fortran_setattr", + "long_name": "fortran_setattr( PyFortranObject * fp , char * name , PyObject * v)", + "filename": "fortranobject.c", + "nloc": 59, + "complexity": 22, + "token_count": 647, + "parameters": [ + "fp", + "name", + "v" + ], + "start_line": 190, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 1 + }, + { + "name": "fortran_call", + "long_name": "fortran_call( PyFortranObject * fp , PyObject * arg , PyObject * kw)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 166, + "parameters": [ + "fp", + "arg", + "kw" + ], + "start_line": 253, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_clock", + "long_name": "f2py_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 313, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_call_clock", + "long_name": "f2py_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 315, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_clock", + "long_name": "f2py_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 320, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_call_clock", + "long_name": "f2py_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 326, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_clock", + "long_name": "f2py_cb_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 334, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_call_clock", + "long_name": "f2py_cb_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_clock", + "long_name": "f2py_cb_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_call_clock", + "long_name": "f2py_cb_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 347, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_exit", + "long_name": "f2py_report_on_exit( int exit_flag , * name)", + "filename": "fortranobject.c", + "nloc": 24, + "complexity": 2, + "token_count": 146, + "parameters": [ + "exit_flag", + "name" + ], + "start_line": 357, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy", + "long_name": "f2py_report_on_array_copy( PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "arr" + ], + "start_line": 387, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy_fromany", + "long_name": "f2py_report_on_array_copy_fromany()", + "filename": "fortranobject.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 394, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "count_nonpos", + "long_name": "count_nonpos( const int rank , const intp * dims)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 48, + "parameters": [ + "rank", + "dims" + ], + "start_line": 428, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "dump_attrs", + "long_name": "dump_attrs( const PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 3, + "token_count": 117, + "parameters": [ + "arr" + ], + "start_line": 443, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "swap_arrays", + "long_name": "swap_arrays( PyArrayObject * arr1 , PyArrayObject * arr2)", + "filename": "fortranobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 111, + "parameters": [ + "arr1", + "arr2" + ], + "start_line": 463, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "array_from_pyobj", + "long_name": "array_from_pyobj( const int type_num , intp * dims , const int rank , const int intent , PyObject * obj)", + "filename": "fortranobject.c", + "nloc": 130, + "complexity": 42, + "token_count": 825, + "parameters": [ + "type_num", + "dims", + "rank", + "intent", + "obj" + ], + "start_line": 482, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 158, + "top_nesting_level": 1 + }, + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 88, + "complexity": 33, + "token_count": 724, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 1 + }, + { + "name": "copy_ND_array", + "long_name": "copy_ND_array( const PyArrayObject * arr , PyArrayObject * out)", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "arr", + "out" + ], + "start_line": 747, + "end_line": 751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 85, + "complexity": 30, + "token_count": 682, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 754, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 1 + } + ], + "nloc": 608, + "complexity": 175, + "token_count": 4679, + "diff_parsed": { + "added": [ + " /*", + " */", + " for (i=0; idimensions[i];", + " if (dims[i]>=0) {", + "\tif (d > 1 && d!=dims[i]) {", + "\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT", + "\t\t \" but got %\" INTP_FMT \"\\n\",", + "\t\t i,dims[i],d);", + "\t return 1;", + "\t}", + "\tif (!dims[i]) dims[i] = 1;", + " } else dims[i] = d;", + " }" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "f32a4e4d4836da7cf9e43f7b14e31a3922713b35", + "msg": "Comment change in fortranobject.c better.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2006-01-22T05:38:18+00:00", + "author_timezone": 0, + "committer_date": "2006-01-22T05:38:18+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "34b8ce671b12e9ee6740dc4df32fafc2eae44f64" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp_9ms3j_2/repo_copy", + "deletions": 0, + "insertions": 4, + "lines": 4, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "numpy/f2py/src/fortranobject.c", + "new_path": "numpy/f2py/src/fortranobject.c", + "filename": "fortranobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -703,6 +703,10 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims)\n \t\tarr->nd,effrank,rank);\n \treturn 1;\n }\n+ /* old f2py used to swap the dimensions so that dims had \n+ reversed dimensions from arr->dimensions -- don't do that \n+ anymore...\n+ */ \n /*\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n", + "added_lines": 4, + "deleted_lines": 0, + "source_code": "#define FORTRANOBJECT_C\n#include \"fortranobject.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/*\n This file implements: FortranObject, array_from_pyobj, copy_ND_array\n\n Author: Pearu Peterson \n $Revision: 1.52 $\n $Date: 2005/07/11 07:44:20 $\n*/\n\n/************************* FortranObject *******************************/\n\ntypedef PyObject *(*fortranfunc)(PyObject *,PyObject *,PyObject *,void *);\n\nPyObject *\nPyFortranObject_New(FortranDataDef* defs, f2py_void_func init) {\n int i;\n PyFortranObject *fp = NULL;\n PyObject *v = NULL;\n if (init!=NULL) /* Initialize F90 module objects */\n (*(init))();\n if ((fp = PyObject_New(PyFortranObject, &PyFortran_Type))==NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 0;\n while (defs[fp->len].name != NULL) fp->len++;\n if (fp->len == 0) goto fail;\n fp->defs = defs;\n for (i=0;ilen;i++)\n if (fp->defs[i].rank == -1) { /* Is Fortran routine */\n v = PyFortranObject_NewAsAttr(&(fp->defs[i]));\n if (v==NULL) return NULL;\n PyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n } else\n if ((fp->defs[i].data)!=NULL) { /* Is Fortran variable or array (not allocatable) */\n\tv = PyArray_New(&PyArray_Type, fp->defs[i].rank, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\tPyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n }\n Py_XDECREF(v);\n return (PyObject *)fp;\n fail:\n Py_XDECREF(v);\n return NULL;\n}\n\nPyObject *\nPyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module routines */\n PyFortranObject *fp = NULL;\n fp = PyObject_New(PyFortranObject, &PyFortran_Type);\n if (fp == NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 1;\n fp->defs = defs;\n return (PyObject *)fp;\n}\n\n/* Fortran methods */\n\nstatic void\nfortran_dealloc(PyFortranObject *fp) {\n Py_XDECREF(fp->dict);\n PyMem_Del(fp);\n}\n\n\nstatic PyMethodDef fortran_methods[] = {\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyObject *\nfortran_doc (FortranDataDef def) {\n char *p;\n PyObject *s = NULL;\n int i;\n unsigned size=100;\n if (def.doc!=NULL)\n size += strlen(def.doc);\n p = (char*)malloc (size);\n if (sprintf(p,\"%s - \",def.name)==0) goto fail;\n if (def.rank==-1) {\n if (def.doc==NULL) {\n if (sprintf(p,\"%sno docs available\",p)==0)\n\tgoto fail;\n } else {\n if (sprintf(p,\"%s%s\",p,def.doc)==0)\n\tgoto fail;\n }\n } else {\n PyArray_Descr *d = PyArray_DescrFromType(def.type);\n if (sprintf(p,\"%s'%c'-\",p,d->type)==0) goto fail;\n if (def.data==NULL) {\n if (sprintf(p,\"%sarray(%\" INTP_FMT,p,def.dims.d[0])==0) goto fail;\n for(i=1;i0) {\n\tif (sprintf(p,\"%sarray(%\"INTP_FMT,p,def.dims.d[0])==0) goto fail;\n\tfor(i=1;isize) {\n fprintf(stderr,\"fortranobject.c:fortran_doc:len(p)=%zd>%d(size): too long doc string required, increase size\\n\",strlen(p),size);\n goto fail;\n }\n s = PyString_FromString(p);\n fail:\n free(p);\n return s;\n}\n\nstatic FortranDataDef *save_def; /* save pointer of an allocatable array */\nstatic void set_data(char *d,intp *f) { /* callback from Fortran */\n if (*f) /* In fortran f=allocated(d) */\n save_def->data = d;\n else\n save_def->data = NULL;\n /* printf(\"set_data: d=%p,f=%d\\n\",d,*f); */\n}\n\nstatic PyObject *\nfortran_getattr(PyFortranObject *fp, char *name) {\n int i,j,k,flag;\n if (fp->dict != NULL) {\n PyObject *v = PyDict_GetItemString(fp->dict, name);\n if (v != NULL) {\n Py_INCREF(v);\n return v;\n }\n }\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0)\n if (fp->defs[i].rank!=-1) { /* F90 allocatable array */ \n if (fp->defs[i].func==NULL) return NULL;\n for(k=0;kdefs[i].rank;++k) \n\tfp->defs[i].dims.d[k]=-1;\n save_def = &fp->defs[i];\n (*(fp->defs[i].func))(&fp->defs[i].rank,fp->defs[i].dims.d,set_data,&flag);\n if (flag==2)\n\tk = fp->defs[i].rank + 1;\n else\n\tk = fp->defs[i].rank;\n if (fp->defs[i].data !=NULL) { /* array is allocated */\n\tPyObject *v = PyArray_New(&PyArray_Type, k, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\t/* Py_INCREF(v); */\n\treturn v;\n } else { /* array is not allocated */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n }\n }\n if (strcmp(name,\"__dict__\")==0) {\n Py_INCREF(fp->dict);\n return fp->dict;\n }\n if (strcmp(name,\"__doc__\")==0) {\n PyObject *s = PyString_FromString(\"\");\n for (i=0;ilen;i++)\n PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i]));\n if (PyDict_SetItemString(fp->dict, name, s))\n return NULL;\n return s;\n }\n if ((strcmp(name,\"_cpointer\")==0) && (fp->len==1)) {\n PyObject *cobj = PyCObject_FromVoidPtr((void *)(fp->defs[0].data),NULL);\n if (PyDict_SetItemString(fp->dict, name, cobj))\n return NULL;\n return cobj;\n }\n return Py_FindMethod(fortran_methods, (PyObject *)fp, name);\n}\n\nstatic int\nfortran_setattr(PyFortranObject *fp, char *name, PyObject *v) {\n int i,j,flag;\n PyArrayObject *arr = NULL;\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0) {\n if (fp->defs[i].rank==-1) {\n PyErr_SetString(PyExc_AttributeError,\"over-writing fortran routine\");\n return -1;\n }\n if (fp->defs[i].func!=NULL) { /* is allocatable array */\n intp dims[F2PY_MAX_DIMS];\n int k;\n save_def = &fp->defs[i];\n if (v!=Py_None) { /* set new value (reallocate if needed --\n\t\t\t see f2py generated code for more\n\t\t\t details ) */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n\tif ((arr = array_from_pyobj(fp->defs[i].type,dims,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\t return -1;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,arr->dimensions,set_data,&flag);\n } else { /* deallocate */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=0;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n }\n memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(intp));\n } else { /* not allocatable array */\n if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\treturn -1; \n }\n if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */\n intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);\n if (s==-1)\n\ts = PyArray_MultiplyList(arr->dimensions,arr->nd);\n if (s<0 ||\n\t (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) {\n\tif ((PyObject*)arr!=v) {\n\t Py_DECREF(arr);\n\t}\n\treturn -1;\n }\n if ((PyObject*)arr!=v) {\n Py_DECREF(arr);\n }\n } else return (fp->defs[i].func==NULL?-1:0);\n return 0; /* succesful */\n }\n if (fp->dict == NULL) {\n fp->dict = PyDict_New();\n if (fp->dict == NULL)\n return -1;\n }\n if (v == NULL) {\n int rv = PyDict_DelItemString(fp->dict, name);\n if (rv < 0)\n PyErr_SetString(PyExc_AttributeError,\"delete non-existing fortran attribute\");\n return rv;\n }\n else\n return PyDict_SetItemString(fp->dict, name, v);\n}\n\nstatic PyObject*\nfortran_call(PyFortranObject *fp, PyObject *arg, PyObject *kw) {\n int i = 0;\n /* printf(\"fortran call\n name=%s,func=%p,data=%p,%p\\n\",fp->defs[i].name,\n fp->defs[i].func,fp->defs[i].data,&fp->defs[i].data); */\n if (fp->defs[i].rank==-1) {/* is Fortran routine */\n if ((fp->defs[i].func==NULL)) {\n PyErr_Format(PyExc_RuntimeError, \"no function to call\");\n return NULL;\n }\n else if (fp->defs[i].data==NULL)\n /* dummy routine */\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,NULL);\n else\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,\n\t\t\t\t\t\t (void *)fp->defs[i].data);\n }\n PyErr_Format(PyExc_TypeError, \"this fortran object is not callable\");\n return NULL;\n}\n\n\nPyTypeObject PyFortran_Type = {\n PyObject_HEAD_INIT(0)\n 0,\t\t\t/*ob_size*/\n \"fortran\",\t\t\t/*tp_name*/\n sizeof(PyFortranObject),\t/*tp_basicsize*/\n 0,\t\t\t/*tp_itemsize*/\n /* methods */\n (destructor)fortran_dealloc, /*tp_dealloc*/\n 0,\t\t\t/*tp_print*/\n (getattrfunc)fortran_getattr, /*tp_getattr*/\n (setattrfunc)fortran_setattr, /*tp_setattr*/\n 0,\t\t\t/*tp_compare*/\n 0,\t\t\t/*tp_repr*/\n 0,\t\t\t/*tp_as_number*/\n 0,\t\t\t/*tp_as_sequence*/\n 0,\t\t\t/*tp_as_mapping*/\n 0,\t\t\t/*tp_hash*/\n (ternaryfunc)fortran_call, /*tp_call*/\n};\n\n/************************* f2py_report_atexit *******************************/\n\n#ifdef F2PY_REPORT_ATEXIT\nstatic int passed_time = 0;\nstatic int passed_counter = 0;\nstatic int passed_call_time = 0;\nstatic struct timeb start_time;\nstatic struct timeb stop_time;\nstatic struct timeb start_call_time;\nstatic struct timeb stop_call_time;\nstatic int cb_passed_time = 0;\nstatic int cb_passed_counter = 0;\nstatic int cb_passed_call_time = 0;\nstatic struct timeb cb_start_time;\nstatic struct timeb cb_stop_time;\nstatic struct timeb cb_start_call_time;\nstatic struct timeb cb_stop_call_time;\n\nextern void f2py_start_clock(void) { ftime(&start_time); }\nextern\nvoid f2py_start_call_clock(void) {\n f2py_stop_clock();\n ftime(&start_call_time);\n}\nextern\nvoid f2py_stop_clock(void) {\n ftime(&stop_time);\n passed_time += 1000*(stop_time.time - start_time.time);\n passed_time += stop_time.millitm - start_time.millitm;\n}\nextern\nvoid f2py_stop_call_clock(void) {\n ftime(&stop_call_time);\n passed_call_time += 1000*(stop_call_time.time - start_call_time.time);\n passed_call_time += stop_call_time.millitm - start_call_time.millitm;\n passed_counter += 1;\n f2py_start_clock();\n}\n\nextern void f2py_cb_start_clock(void) { ftime(&cb_start_time); }\nextern\nvoid f2py_cb_start_call_clock(void) {\n f2py_cb_stop_clock();\n ftime(&cb_start_call_time);\n}\nextern\nvoid f2py_cb_stop_clock(void) {\n ftime(&cb_stop_time);\n cb_passed_time += 1000*(cb_stop_time.time - cb_start_time.time);\n cb_passed_time += cb_stop_time.millitm - cb_start_time.millitm;\n}\nextern\nvoid f2py_cb_stop_call_clock(void) {\n ftime(&cb_stop_call_time);\n cb_passed_call_time += 1000*(cb_stop_call_time.time - cb_start_call_time.time);\n cb_passed_call_time += cb_stop_call_time.millitm - cb_start_call_time.millitm;\n cb_passed_counter += 1;\n f2py_cb_start_clock();\n}\n\nstatic int f2py_report_on_exit_been_here = 0;\nextern\nvoid f2py_report_on_exit(int exit_flag,void *name) {\n if (f2py_report_on_exit_been_here) {\n fprintf(stderr,\" %s\\n\",(char*)name);\n return;\n }\n f2py_report_on_exit_been_here = 1;\n fprintf(stderr,\" /-----------------------\\\\\\n\");\n fprintf(stderr,\" < F2PY performance report >\\n\");\n fprintf(stderr,\" \\\\-----------------------/\\n\");\n fprintf(stderr,\"Overall time spent in ...\\n\");\n fprintf(stderr,\"(a) wrapped (Fortran/C) functions : %8d msec\\n\",\n\t passed_call_time);\n fprintf(stderr,\"(b) f2py interface, %6d calls : %8d msec\\n\",\n\t passed_counter,passed_time);\n fprintf(stderr,\"(c) call-back (Python) functions : %8d msec\\n\",\n\t cb_passed_call_time);\n fprintf(stderr,\"(d) f2py call-back interface, %6d calls : %8d msec\\n\",\n\t cb_passed_counter,cb_passed_time);\n \n fprintf(stderr,\"(e) wrapped (Fortran/C) functions (acctual) : %8d msec\\n\\n\",\n\t passed_call_time-cb_passed_call_time-cb_passed_time);\n fprintf(stderr,\"Use -DF2PY_REPORT_ATEXIT_DISABLE to disable this message.\\n\");\n fprintf(stderr,\"Exit status: %d\\n\",exit_flag);\n fprintf(stderr,\"Modules : %s\\n\",(char*)name);\n}\n#endif\n\n/********************** report on array copy ****************************/\n\n#ifdef F2PY_REPORT_ON_ARRAY_COPY\nstatic void f2py_report_on_array_copy(PyArrayObject* arr) {\n const long arr_size = PyArray_Size((PyObject *)arr);\n if (arr_size>F2PY_REPORT_ON_ARRAY_COPY) {\n fprintf(stderr,\"copied an array: size=%ld, elsize=%d\\n\", \n\t arr_size, PyArray_ITEMSIZE(arr));\n }\n}\nstatic void f2py_report_on_array_copy_fromany(void) {\n fprintf(stderr,\"created an array from object\\n\");\n}\n\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR f2py_report_on_array_copy((PyArrayObject *)arr)\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY f2py_report_on_array_copy_fromany()\n#else\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY\n#endif\n\n\n/************************* array_from_obj *******************************/\n\n/* \n * File: array_from_pyobj.c \n *\n * Description:\n * ------------ \n * Provides array_from_pyobj function that returns a contigious array\n * object with the given dimensions and required storage order, either\n * in row-major (C) or column-major (Fortran) order. The function\n * array_from_pyobj is very flexible about its Python object argument\n * that can be any number, list, tuple, or array.\n * \n * array_from_pyobj is used in f2py generated Python extension\n * modules.\n *\n * Author: Pearu Peterson \n * Created: 13-16 January 2002\n * $Id: fortranobject.c,v 1.52 2005/07/11 07:44:20 pearu Exp $\n */\n\nstatic int \ncount_nonpos(const int rank,\n\t const intp *dims) {\n int i=0,r=0;\n while (ind;\n intp size = PyArray_Size((PyObject *)arr);\n int i;\n printf(\"\\trank = %d, flags = %d, size = %\" INTP_FMT \"\\n\",\n\t rank,arr->flags,size);\n printf(\"\\tstrides = [\");\n for(i=0;istrides[i]);\n }\n printf(\"]\\n\\t dimensions = [\");\n for(i=0;idimensions[i]);\n }\n printf(\"]\\n\");\n}\n#endif\n\n#define SWAPTYPE(a,b,t) {t c; c = (a); (a) = (b); (b) = c; }\n\nstatic int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) {\n SWAPTYPE(arr1->data,arr2->data,char*);\n SWAPTYPE(arr1->nd,arr2->nd,int);\n SWAPTYPE(arr1->dimensions,arr2->dimensions,intp*);\n SWAPTYPE(arr1->strides,arr2->strides,intp*);\n SWAPTYPE(arr1->base,arr2->base,PyObject*);\n SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*);\n SWAPTYPE(arr1->flags,arr2->flags,int);\n /* SWAPTYPE(arr1->weakreflist,arr2->weakreflist,PyObject*); */\n return 0;\n}\n\n#define ARRAY_ISCOMPATIBLE(arr,type_num) \\\n( (PyArray_ISINTEGER(arr) && PyTypeNum_ISINTEGER(type_num)) \\\n ||(PyArray_ISFLOAT(arr) && PyTypeNum_ISFLOAT(type_num)) \\\n ||(PyArray_ISCOMPLEX(arr) && PyTypeNum_ISCOMPLEX(type_num)) \\\n)\n\nextern\nPyArrayObject* array_from_pyobj(const int type_num,\n\t\t\t\tintp *dims,\n\t\t\t\tconst int rank,\n\t\t\t\tconst int intent,\n\t\t\t\tPyObject *obj) {\n /* Note about reference counting\n -----------------------------\n If the caller returns the array to Python, it must be done with\n Py_BuildValue(\"N\",arr).\n Otherwise, if obj!=arr then the caller must call Py_DECREF(arr).\n\n Note on intent(cache,out,..)\n ---------------------\n Don't expect correct data when returning intent(cache) array.\n\n */\n char mess[200];\n PyArrayObject *arr = NULL;\n PyArray_Descr *descr = PyArray_DescrFromType(type_num);\n\n if ((intent & F2PY_INTENT_HIDE)\n || ((intent & F2PY_INTENT_CACHE) && (obj==Py_None))\n || ((intent & F2PY_OPTIONAL) && (obj==Py_None))\n ) {\n /* intent(cache), optional, intent(hide) */\n if (count_nonpos(rank,dims)) {\n int i;\n sprintf(mess,\"failed to create intent(cache|hide)|optional array\"\n\t \"-- must have defined dimensions but got (\");\n for(i=0;i=descr->elsize) {\n\tif (check_and_fix_dimensions((PyArrayObject *)obj,rank,dims))\n\t return NULL; /*XXX: set exception */\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(obj);\n\treturn (PyArrayObject *)obj;\n }\n sprintf(mess,\"failed to initialize intent(cache) array\");\n if (!PyArray_ISONESEGMENT(obj))\n\tsprintf(mess+strlen(mess),\" -- input must be in one segment\");\n if (PyArray_ITEMSIZE(arr)elsize)\n\tsprintf(mess+strlen(mess),\" -- expected at least elsize=%d but got %d\",\n\t\tdescr->elsize,PyArray_ITEMSIZE(arr)\n\t\t);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inout) or intent(inplace) */\n\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n\n if ((! (intent & F2PY_INTENT_COPY))\n\t&& PyArray_ITEMSIZE(arr)==descr->elsize\n\t&& ARRAY_ISCOMPATIBLE(arr,type_num)\n\t) {\n if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) {\n\tif ((intent & F2PY_INTENT_OUT)) {\n\t Py_INCREF(arr);\n\t}\n\t/* Returning input array */\n\treturn arr;\n }\n }\n\n if (intent & F2PY_INTENT_INOUT) {\n sprintf(mess,\"failed to initialize intent(inout) array\");\n if ((intent & F2PY_INTENT_C) && !PyArray_ISCARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not contiguous\");\n if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not fortran contiguous\");\n if (PyArray_ITEMSIZE(arr)!=descr->elsize)\n\tsprintf(mess+strlen(mess),\" -- expected elsize=%d but got %d\",\n\t\tdescr->elsize,\n\t\tPyArray_ITEMSIZE(arr)\n\t\t);\n if (!(ARRAY_ISCOMPATIBLE(arr,type_num)))\n\tsprintf(mess+strlen(mess),\" -- input '%c' not compatible to '%c'\",\n\t\tarr->descr->type,descr->type);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inplace) */\n\n {\n PyArrayObject *retarr = (PyArrayObject *) \\\n\tPyArray_New(&PyArray_Type, arr->nd, arr->dimensions, type_num,\n\t\t NULL,NULL,0,\n\t\t !(intent&F2PY_INTENT_C),\n\t\t NULL);\n if (retarr==NULL)\n\treturn NULL;\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n if (PyArray_CopyInto(retarr, arr)) {\n\tPy_DECREF(retarr);\n\treturn NULL;\n }\n if (intent & F2PY_INTENT_INPLACE) {\n\tif (swap_arrays(arr,retarr))\n\t return NULL; /* XXX: set exception */\n\tPy_XDECREF(retarr);\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(arr);\n } else {\n\tarr = retarr;\n }\n }\n return arr;\n }\n\n if ((intent & F2PY_INTENT_INOUT) \n || (intent & F2PY_INTENT_INPLACE)\n || (intent & F2PY_INTENT_CACHE)) {\n sprintf(mess,\"failed to initialize intent(inout|inplace|cache) array\"\n\t \" -- input must be array but got %s\",\n\t PyString_AsString(PyObject_Str(PyObject_Type(obj)))\n\t );\n PyErr_SetString(PyExc_TypeError,mess);\n return NULL;\n }\n\n {\n F2PY_REPORT_ON_ARRAY_COPY_FROMANY;\n arr = (PyArrayObject *) \\\n PyArray_FromAny(obj,PyArray_DescrFromType(type_num), 0,0,\n\t\t ((intent & F2PY_INTENT_C)?CARRAY_FLAGS:FARRAY_FLAGS) \\\n | FORCECAST, NULL);\n if (arr==NULL)\n return NULL;\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n return arr;\n }\n\n}\n\n /*****************************************/\n /* Helper functions for array_from_pyobj */\n /*****************************************/\n\nstatic\nint check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims) {\n /*\n This function fills in blanks (that are -1\\'s) in dims list using\n the dimensions from arr. It also checks that non-blank dims will\n match with the corresponding values in arr dimensions.\n */\n const intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;\n\n if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */\n intp new_size = 1;\n int free_axe = -1;\n int i;\n /* Fill dims where -1 or 0; check dimensions; calc new_size; */\n for(i=0;ind;++i) { \n if (dims[i] >= 0) {\n\tif (dims[i]!=arr->dimensions[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT\n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i], arr->dimensions[i]);\n\t return 1;\n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else {\n\tdims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1;\n }\n new_size *= dims[i];\n }\n for(i=arr->nd;i1) {\n\tfprintf(stderr,\"%d-th dimension must be %\" INTP_FMT\n\t\t\" but got 0 (not defined).\\n\",\n\t\ti,dims[i]);\n\treturn 1;\n } else if (free_axe<0)\n\tfree_axe = i;\n else\n\tdims[i] = 1;\n if (free_axe>=0) {\n dims[free_axe] = arr_size/new_size;\n new_size *= dims[free_axe];\n }\n if (new_size != arr_size) {\n fprintf(stderr,\"confused: new_size=%\" INTP_FMT\n\t \", arr_size=%\" INTP_FMT \" (maybe too many free\"\n\t \" indices)\\n\", new_size,arr_size);\n return 1;\n }\n } else { /* [[1,2]] -> [[1],[2]] */\n int i,j;\n intp d;\n int effrank;\n intp size;\n for (i=0,effrank=0;ind;++i)\n if (arr->dimensions[i]>1) ++effrank;\n if (dims[rank-1]>=0)\n if (effrank>rank) {\n\tfprintf(stderr,\"too many axes: %d (effrank=%d), expected rank=%d\\n\",\n\t\tarr->nd,effrank,rank);\n\treturn 1;\n }\n /* old f2py used to swap the dimensions so that dims had \n reversed dimensions from arr->dimensions -- don't do that \n anymore...\n */ \n /*\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n if (dims[i]>=0) {\n\tif (d>1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \" (real index=%d)\\n\",\n\t\t i,dims[i],d,j-1);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else\n\tdims[i] = d;\n }\n */\n for (i=0; idimensions[i];\n if (dims[i]>=0) {\n\tif (d > 1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i],d);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else dims[i] = d;\n }\n for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */\n while (jnd && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n dims[rank-1] *= d;\n }\n for (i=0,size=1;ind);\n for (i=0;ind;++i) fprintf(stderr,\" %\" INTP_FMT,arr->dimensions[i]);\n fprintf(stderr,\" ]\\n\");\n return 1;\n }\n }\n return 0;\n}\n\n/* End of file: array_from_pyobj.c */\n\n/************************* copy_ND_array *******************************/\n\nextern\nint copy_ND_array(const PyArrayObject *arr, PyArrayObject *out)\n{\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n return PyArray_CopyInto(out, (PyArrayObject *)arr);\n}\n\n#ifdef __cplusplus\n}\n#endif\n/************************* EOF fortranobject.c *******************************/\n", + "source_code_before": "#define FORTRANOBJECT_C\n#include \"fortranobject.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/*\n This file implements: FortranObject, array_from_pyobj, copy_ND_array\n\n Author: Pearu Peterson \n $Revision: 1.52 $\n $Date: 2005/07/11 07:44:20 $\n*/\n\n/************************* FortranObject *******************************/\n\ntypedef PyObject *(*fortranfunc)(PyObject *,PyObject *,PyObject *,void *);\n\nPyObject *\nPyFortranObject_New(FortranDataDef* defs, f2py_void_func init) {\n int i;\n PyFortranObject *fp = NULL;\n PyObject *v = NULL;\n if (init!=NULL) /* Initialize F90 module objects */\n (*(init))();\n if ((fp = PyObject_New(PyFortranObject, &PyFortran_Type))==NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 0;\n while (defs[fp->len].name != NULL) fp->len++;\n if (fp->len == 0) goto fail;\n fp->defs = defs;\n for (i=0;ilen;i++)\n if (fp->defs[i].rank == -1) { /* Is Fortran routine */\n v = PyFortranObject_NewAsAttr(&(fp->defs[i]));\n if (v==NULL) return NULL;\n PyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n } else\n if ((fp->defs[i].data)!=NULL) { /* Is Fortran variable or array (not allocatable) */\n\tv = PyArray_New(&PyArray_Type, fp->defs[i].rank, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\tPyDict_SetItemString(fp->dict,fp->defs[i].name,v);\n }\n Py_XDECREF(v);\n return (PyObject *)fp;\n fail:\n Py_XDECREF(v);\n return NULL;\n}\n\nPyObject *\nPyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module routines */\n PyFortranObject *fp = NULL;\n fp = PyObject_New(PyFortranObject, &PyFortran_Type);\n if (fp == NULL) return NULL;\n if ((fp->dict = PyDict_New())==NULL) return NULL;\n fp->len = 1;\n fp->defs = defs;\n return (PyObject *)fp;\n}\n\n/* Fortran methods */\n\nstatic void\nfortran_dealloc(PyFortranObject *fp) {\n Py_XDECREF(fp->dict);\n PyMem_Del(fp);\n}\n\n\nstatic PyMethodDef fortran_methods[] = {\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyObject *\nfortran_doc (FortranDataDef def) {\n char *p;\n PyObject *s = NULL;\n int i;\n unsigned size=100;\n if (def.doc!=NULL)\n size += strlen(def.doc);\n p = (char*)malloc (size);\n if (sprintf(p,\"%s - \",def.name)==0) goto fail;\n if (def.rank==-1) {\n if (def.doc==NULL) {\n if (sprintf(p,\"%sno docs available\",p)==0)\n\tgoto fail;\n } else {\n if (sprintf(p,\"%s%s\",p,def.doc)==0)\n\tgoto fail;\n }\n } else {\n PyArray_Descr *d = PyArray_DescrFromType(def.type);\n if (sprintf(p,\"%s'%c'-\",p,d->type)==0) goto fail;\n if (def.data==NULL) {\n if (sprintf(p,\"%sarray(%\" INTP_FMT,p,def.dims.d[0])==0) goto fail;\n for(i=1;i0) {\n\tif (sprintf(p,\"%sarray(%\"INTP_FMT,p,def.dims.d[0])==0) goto fail;\n\tfor(i=1;isize) {\n fprintf(stderr,\"fortranobject.c:fortran_doc:len(p)=%zd>%d(size): too long doc string required, increase size\\n\",strlen(p),size);\n goto fail;\n }\n s = PyString_FromString(p);\n fail:\n free(p);\n return s;\n}\n\nstatic FortranDataDef *save_def; /* save pointer of an allocatable array */\nstatic void set_data(char *d,intp *f) { /* callback from Fortran */\n if (*f) /* In fortran f=allocated(d) */\n save_def->data = d;\n else\n save_def->data = NULL;\n /* printf(\"set_data: d=%p,f=%d\\n\",d,*f); */\n}\n\nstatic PyObject *\nfortran_getattr(PyFortranObject *fp, char *name) {\n int i,j,k,flag;\n if (fp->dict != NULL) {\n PyObject *v = PyDict_GetItemString(fp->dict, name);\n if (v != NULL) {\n Py_INCREF(v);\n return v;\n }\n }\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0)\n if (fp->defs[i].rank!=-1) { /* F90 allocatable array */ \n if (fp->defs[i].func==NULL) return NULL;\n for(k=0;kdefs[i].rank;++k) \n\tfp->defs[i].dims.d[k]=-1;\n save_def = &fp->defs[i];\n (*(fp->defs[i].func))(&fp->defs[i].rank,fp->defs[i].dims.d,set_data,&flag);\n if (flag==2)\n\tk = fp->defs[i].rank + 1;\n else\n\tk = fp->defs[i].rank;\n if (fp->defs[i].data !=NULL) { /* array is allocated */\n\tPyObject *v = PyArray_New(&PyArray_Type, k, fp->defs[i].dims.d,\n\t\t\tfp->defs[i].type, NULL, fp->defs[i].data, 0, FARRAY_FLAGS,\n\t\t\tNULL);\n\tif (v==NULL) return NULL;\n\t/* Py_INCREF(v); */\n\treturn v;\n } else { /* array is not allocated */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n }\n }\n if (strcmp(name,\"__dict__\")==0) {\n Py_INCREF(fp->dict);\n return fp->dict;\n }\n if (strcmp(name,\"__doc__\")==0) {\n PyObject *s = PyString_FromString(\"\");\n for (i=0;ilen;i++)\n PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i]));\n if (PyDict_SetItemString(fp->dict, name, s))\n return NULL;\n return s;\n }\n if ((strcmp(name,\"_cpointer\")==0) && (fp->len==1)) {\n PyObject *cobj = PyCObject_FromVoidPtr((void *)(fp->defs[0].data),NULL);\n if (PyDict_SetItemString(fp->dict, name, cobj))\n return NULL;\n return cobj;\n }\n return Py_FindMethod(fortran_methods, (PyObject *)fp, name);\n}\n\nstatic int\nfortran_setattr(PyFortranObject *fp, char *name, PyObject *v) {\n int i,j,flag;\n PyArrayObject *arr = NULL;\n for (i=0,j=1;ilen && (j=strcmp(name,fp->defs[i].name));i++);\n if (j==0) {\n if (fp->defs[i].rank==-1) {\n PyErr_SetString(PyExc_AttributeError,\"over-writing fortran routine\");\n return -1;\n }\n if (fp->defs[i].func!=NULL) { /* is allocatable array */\n intp dims[F2PY_MAX_DIMS];\n int k;\n save_def = &fp->defs[i];\n if (v!=Py_None) { /* set new value (reallocate if needed --\n\t\t\t see f2py generated code for more\n\t\t\t details ) */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n\tif ((arr = array_from_pyobj(fp->defs[i].type,dims,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\t return -1;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,arr->dimensions,set_data,&flag);\n } else { /* deallocate */\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=0;\n\t(*(fp->defs[i].func))(&fp->defs[i].rank,dims,set_data,&flag);\n\tfor(k=0;kdefs[i].rank;k++) dims[k]=-1;\n }\n memcpy(fp->defs[i].dims.d,dims,fp->defs[i].rank*sizeof(intp));\n } else { /* not allocatable array */\n if ((arr = array_from_pyobj(fp->defs[i].type,fp->defs[i].dims.d,fp->defs[i].rank,F2PY_INTENT_IN,v))==NULL)\n\treturn -1; \n }\n if (fp->defs[i].data!=NULL) { /* copy Python object to Fortran array */\n intp s = PyArray_MultiplyList(fp->defs[i].dims.d,arr->nd);\n if (s==-1)\n\ts = PyArray_MultiplyList(arr->dimensions,arr->nd);\n if (s<0 ||\n\t (memcpy(fp->defs[i].data,arr->data,s*PyArray_ITEMSIZE(arr)))==NULL) {\n\tif ((PyObject*)arr!=v) {\n\t Py_DECREF(arr);\n\t}\n\treturn -1;\n }\n if ((PyObject*)arr!=v) {\n Py_DECREF(arr);\n }\n } else return (fp->defs[i].func==NULL?-1:0);\n return 0; /* succesful */\n }\n if (fp->dict == NULL) {\n fp->dict = PyDict_New();\n if (fp->dict == NULL)\n return -1;\n }\n if (v == NULL) {\n int rv = PyDict_DelItemString(fp->dict, name);\n if (rv < 0)\n PyErr_SetString(PyExc_AttributeError,\"delete non-existing fortran attribute\");\n return rv;\n }\n else\n return PyDict_SetItemString(fp->dict, name, v);\n}\n\nstatic PyObject*\nfortran_call(PyFortranObject *fp, PyObject *arg, PyObject *kw) {\n int i = 0;\n /* printf(\"fortran call\n name=%s,func=%p,data=%p,%p\\n\",fp->defs[i].name,\n fp->defs[i].func,fp->defs[i].data,&fp->defs[i].data); */\n if (fp->defs[i].rank==-1) {/* is Fortran routine */\n if ((fp->defs[i].func==NULL)) {\n PyErr_Format(PyExc_RuntimeError, \"no function to call\");\n return NULL;\n }\n else if (fp->defs[i].data==NULL)\n /* dummy routine */\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,NULL);\n else\n return (*((fortranfunc)(fp->defs[i].func)))((PyObject *)fp,arg,kw,\n\t\t\t\t\t\t (void *)fp->defs[i].data);\n }\n PyErr_Format(PyExc_TypeError, \"this fortran object is not callable\");\n return NULL;\n}\n\n\nPyTypeObject PyFortran_Type = {\n PyObject_HEAD_INIT(0)\n 0,\t\t\t/*ob_size*/\n \"fortran\",\t\t\t/*tp_name*/\n sizeof(PyFortranObject),\t/*tp_basicsize*/\n 0,\t\t\t/*tp_itemsize*/\n /* methods */\n (destructor)fortran_dealloc, /*tp_dealloc*/\n 0,\t\t\t/*tp_print*/\n (getattrfunc)fortran_getattr, /*tp_getattr*/\n (setattrfunc)fortran_setattr, /*tp_setattr*/\n 0,\t\t\t/*tp_compare*/\n 0,\t\t\t/*tp_repr*/\n 0,\t\t\t/*tp_as_number*/\n 0,\t\t\t/*tp_as_sequence*/\n 0,\t\t\t/*tp_as_mapping*/\n 0,\t\t\t/*tp_hash*/\n (ternaryfunc)fortran_call, /*tp_call*/\n};\n\n/************************* f2py_report_atexit *******************************/\n\n#ifdef F2PY_REPORT_ATEXIT\nstatic int passed_time = 0;\nstatic int passed_counter = 0;\nstatic int passed_call_time = 0;\nstatic struct timeb start_time;\nstatic struct timeb stop_time;\nstatic struct timeb start_call_time;\nstatic struct timeb stop_call_time;\nstatic int cb_passed_time = 0;\nstatic int cb_passed_counter = 0;\nstatic int cb_passed_call_time = 0;\nstatic struct timeb cb_start_time;\nstatic struct timeb cb_stop_time;\nstatic struct timeb cb_start_call_time;\nstatic struct timeb cb_stop_call_time;\n\nextern void f2py_start_clock(void) { ftime(&start_time); }\nextern\nvoid f2py_start_call_clock(void) {\n f2py_stop_clock();\n ftime(&start_call_time);\n}\nextern\nvoid f2py_stop_clock(void) {\n ftime(&stop_time);\n passed_time += 1000*(stop_time.time - start_time.time);\n passed_time += stop_time.millitm - start_time.millitm;\n}\nextern\nvoid f2py_stop_call_clock(void) {\n ftime(&stop_call_time);\n passed_call_time += 1000*(stop_call_time.time - start_call_time.time);\n passed_call_time += stop_call_time.millitm - start_call_time.millitm;\n passed_counter += 1;\n f2py_start_clock();\n}\n\nextern void f2py_cb_start_clock(void) { ftime(&cb_start_time); }\nextern\nvoid f2py_cb_start_call_clock(void) {\n f2py_cb_stop_clock();\n ftime(&cb_start_call_time);\n}\nextern\nvoid f2py_cb_stop_clock(void) {\n ftime(&cb_stop_time);\n cb_passed_time += 1000*(cb_stop_time.time - cb_start_time.time);\n cb_passed_time += cb_stop_time.millitm - cb_start_time.millitm;\n}\nextern\nvoid f2py_cb_stop_call_clock(void) {\n ftime(&cb_stop_call_time);\n cb_passed_call_time += 1000*(cb_stop_call_time.time - cb_start_call_time.time);\n cb_passed_call_time += cb_stop_call_time.millitm - cb_start_call_time.millitm;\n cb_passed_counter += 1;\n f2py_cb_start_clock();\n}\n\nstatic int f2py_report_on_exit_been_here = 0;\nextern\nvoid f2py_report_on_exit(int exit_flag,void *name) {\n if (f2py_report_on_exit_been_here) {\n fprintf(stderr,\" %s\\n\",(char*)name);\n return;\n }\n f2py_report_on_exit_been_here = 1;\n fprintf(stderr,\" /-----------------------\\\\\\n\");\n fprintf(stderr,\" < F2PY performance report >\\n\");\n fprintf(stderr,\" \\\\-----------------------/\\n\");\n fprintf(stderr,\"Overall time spent in ...\\n\");\n fprintf(stderr,\"(a) wrapped (Fortran/C) functions : %8d msec\\n\",\n\t passed_call_time);\n fprintf(stderr,\"(b) f2py interface, %6d calls : %8d msec\\n\",\n\t passed_counter,passed_time);\n fprintf(stderr,\"(c) call-back (Python) functions : %8d msec\\n\",\n\t cb_passed_call_time);\n fprintf(stderr,\"(d) f2py call-back interface, %6d calls : %8d msec\\n\",\n\t cb_passed_counter,cb_passed_time);\n \n fprintf(stderr,\"(e) wrapped (Fortran/C) functions (acctual) : %8d msec\\n\\n\",\n\t passed_call_time-cb_passed_call_time-cb_passed_time);\n fprintf(stderr,\"Use -DF2PY_REPORT_ATEXIT_DISABLE to disable this message.\\n\");\n fprintf(stderr,\"Exit status: %d\\n\",exit_flag);\n fprintf(stderr,\"Modules : %s\\n\",(char*)name);\n}\n#endif\n\n/********************** report on array copy ****************************/\n\n#ifdef F2PY_REPORT_ON_ARRAY_COPY\nstatic void f2py_report_on_array_copy(PyArrayObject* arr) {\n const long arr_size = PyArray_Size((PyObject *)arr);\n if (arr_size>F2PY_REPORT_ON_ARRAY_COPY) {\n fprintf(stderr,\"copied an array: size=%ld, elsize=%d\\n\", \n\t arr_size, PyArray_ITEMSIZE(arr));\n }\n}\nstatic void f2py_report_on_array_copy_fromany(void) {\n fprintf(stderr,\"created an array from object\\n\");\n}\n\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR f2py_report_on_array_copy((PyArrayObject *)arr)\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY f2py_report_on_array_copy_fromany()\n#else\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMARR\n#define F2PY_REPORT_ON_ARRAY_COPY_FROMANY\n#endif\n\n\n/************************* array_from_obj *******************************/\n\n/* \n * File: array_from_pyobj.c \n *\n * Description:\n * ------------ \n * Provides array_from_pyobj function that returns a contigious array\n * object with the given dimensions and required storage order, either\n * in row-major (C) or column-major (Fortran) order. The function\n * array_from_pyobj is very flexible about its Python object argument\n * that can be any number, list, tuple, or array.\n * \n * array_from_pyobj is used in f2py generated Python extension\n * modules.\n *\n * Author: Pearu Peterson \n * Created: 13-16 January 2002\n * $Id: fortranobject.c,v 1.52 2005/07/11 07:44:20 pearu Exp $\n */\n\nstatic int \ncount_nonpos(const int rank,\n\t const intp *dims) {\n int i=0,r=0;\n while (ind;\n intp size = PyArray_Size((PyObject *)arr);\n int i;\n printf(\"\\trank = %d, flags = %d, size = %\" INTP_FMT \"\\n\",\n\t rank,arr->flags,size);\n printf(\"\\tstrides = [\");\n for(i=0;istrides[i]);\n }\n printf(\"]\\n\\t dimensions = [\");\n for(i=0;idimensions[i]);\n }\n printf(\"]\\n\");\n}\n#endif\n\n#define SWAPTYPE(a,b,t) {t c; c = (a); (a) = (b); (b) = c; }\n\nstatic int swap_arrays(PyArrayObject* arr1, PyArrayObject* arr2) {\n SWAPTYPE(arr1->data,arr2->data,char*);\n SWAPTYPE(arr1->nd,arr2->nd,int);\n SWAPTYPE(arr1->dimensions,arr2->dimensions,intp*);\n SWAPTYPE(arr1->strides,arr2->strides,intp*);\n SWAPTYPE(arr1->base,arr2->base,PyObject*);\n SWAPTYPE(arr1->descr,arr2->descr,PyArray_Descr*);\n SWAPTYPE(arr1->flags,arr2->flags,int);\n /* SWAPTYPE(arr1->weakreflist,arr2->weakreflist,PyObject*); */\n return 0;\n}\n\n#define ARRAY_ISCOMPATIBLE(arr,type_num) \\\n( (PyArray_ISINTEGER(arr) && PyTypeNum_ISINTEGER(type_num)) \\\n ||(PyArray_ISFLOAT(arr) && PyTypeNum_ISFLOAT(type_num)) \\\n ||(PyArray_ISCOMPLEX(arr) && PyTypeNum_ISCOMPLEX(type_num)) \\\n)\n\nextern\nPyArrayObject* array_from_pyobj(const int type_num,\n\t\t\t\tintp *dims,\n\t\t\t\tconst int rank,\n\t\t\t\tconst int intent,\n\t\t\t\tPyObject *obj) {\n /* Note about reference counting\n -----------------------------\n If the caller returns the array to Python, it must be done with\n Py_BuildValue(\"N\",arr).\n Otherwise, if obj!=arr then the caller must call Py_DECREF(arr).\n\n Note on intent(cache,out,..)\n ---------------------\n Don't expect correct data when returning intent(cache) array.\n\n */\n char mess[200];\n PyArrayObject *arr = NULL;\n PyArray_Descr *descr = PyArray_DescrFromType(type_num);\n\n if ((intent & F2PY_INTENT_HIDE)\n || ((intent & F2PY_INTENT_CACHE) && (obj==Py_None))\n || ((intent & F2PY_OPTIONAL) && (obj==Py_None))\n ) {\n /* intent(cache), optional, intent(hide) */\n if (count_nonpos(rank,dims)) {\n int i;\n sprintf(mess,\"failed to create intent(cache|hide)|optional array\"\n\t \"-- must have defined dimensions but got (\");\n for(i=0;i=descr->elsize) {\n\tif (check_and_fix_dimensions((PyArrayObject *)obj,rank,dims))\n\t return NULL; /*XXX: set exception */\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(obj);\n\treturn (PyArrayObject *)obj;\n }\n sprintf(mess,\"failed to initialize intent(cache) array\");\n if (!PyArray_ISONESEGMENT(obj))\n\tsprintf(mess+strlen(mess),\" -- input must be in one segment\");\n if (PyArray_ITEMSIZE(arr)elsize)\n\tsprintf(mess+strlen(mess),\" -- expected at least elsize=%d but got %d\",\n\t\tdescr->elsize,PyArray_ITEMSIZE(arr)\n\t\t);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inout) or intent(inplace) */\n\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n\n if ((! (intent & F2PY_INTENT_COPY))\n\t&& PyArray_ITEMSIZE(arr)==descr->elsize\n\t&& ARRAY_ISCOMPATIBLE(arr,type_num)\n\t) {\n if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) {\n\tif ((intent & F2PY_INTENT_OUT)) {\n\t Py_INCREF(arr);\n\t}\n\t/* Returning input array */\n\treturn arr;\n }\n }\n\n if (intent & F2PY_INTENT_INOUT) {\n sprintf(mess,\"failed to initialize intent(inout) array\");\n if ((intent & F2PY_INTENT_C) && !PyArray_ISCARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not contiguous\");\n if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr))\n\tsprintf(mess+strlen(mess),\" -- input not fortran contiguous\");\n if (PyArray_ITEMSIZE(arr)!=descr->elsize)\n\tsprintf(mess+strlen(mess),\" -- expected elsize=%d but got %d\",\n\t\tdescr->elsize,\n\t\tPyArray_ITEMSIZE(arr)\n\t\t);\n if (!(ARRAY_ISCOMPATIBLE(arr,type_num)))\n\tsprintf(mess+strlen(mess),\" -- input '%c' not compatible to '%c'\",\n\t\tarr->descr->type,descr->type);\n PyErr_SetString(PyExc_ValueError,mess);\n return NULL;\n }\n\n /* here we have always intent(in) or intent(inplace) */\n\n {\n PyArrayObject *retarr = (PyArrayObject *) \\\n\tPyArray_New(&PyArray_Type, arr->nd, arr->dimensions, type_num,\n\t\t NULL,NULL,0,\n\t\t !(intent&F2PY_INTENT_C),\n\t\t NULL);\n if (retarr==NULL)\n\treturn NULL;\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n if (PyArray_CopyInto(retarr, arr)) {\n\tPy_DECREF(retarr);\n\treturn NULL;\n }\n if (intent & F2PY_INTENT_INPLACE) {\n\tif (swap_arrays(arr,retarr))\n\t return NULL; /* XXX: set exception */\n\tPy_XDECREF(retarr);\n\tif (intent & F2PY_INTENT_OUT)\n\t Py_INCREF(arr);\n } else {\n\tarr = retarr;\n }\n }\n return arr;\n }\n\n if ((intent & F2PY_INTENT_INOUT) \n || (intent & F2PY_INTENT_INPLACE)\n || (intent & F2PY_INTENT_CACHE)) {\n sprintf(mess,\"failed to initialize intent(inout|inplace|cache) array\"\n\t \" -- input must be array but got %s\",\n\t PyString_AsString(PyObject_Str(PyObject_Type(obj)))\n\t );\n PyErr_SetString(PyExc_TypeError,mess);\n return NULL;\n }\n\n {\n F2PY_REPORT_ON_ARRAY_COPY_FROMANY;\n arr = (PyArrayObject *) \\\n PyArray_FromAny(obj,PyArray_DescrFromType(type_num), 0,0,\n\t\t ((intent & F2PY_INTENT_C)?CARRAY_FLAGS:FARRAY_FLAGS) \\\n | FORCECAST, NULL);\n if (arr==NULL)\n return NULL;\n if (check_and_fix_dimensions(arr,rank,dims))\n return NULL; /*XXX: set exception */\n return arr;\n }\n\n}\n\n /*****************************************/\n /* Helper functions for array_from_pyobj */\n /*****************************************/\n\nstatic\nint check_and_fix_dimensions(const PyArrayObject* arr,const int rank,intp *dims) {\n /*\n This function fills in blanks (that are -1\\'s) in dims list using\n the dimensions from arr. It also checks that non-blank dims will\n match with the corresponding values in arr dimensions.\n */\n const intp arr_size = (arr->nd)?PyArray_Size((PyObject *)arr):1;\n\n if (rank > arr->nd) { /* [1,2] -> [[1],[2]]; 1 -> [[1]] */\n intp new_size = 1;\n int free_axe = -1;\n int i;\n /* Fill dims where -1 or 0; check dimensions; calc new_size; */\n for(i=0;ind;++i) { \n if (dims[i] >= 0) {\n\tif (dims[i]!=arr->dimensions[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT\n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i], arr->dimensions[i]);\n\t return 1;\n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else {\n\tdims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1;\n }\n new_size *= dims[i];\n }\n for(i=arr->nd;i1) {\n\tfprintf(stderr,\"%d-th dimension must be %\" INTP_FMT\n\t\t\" but got 0 (not defined).\\n\",\n\t\ti,dims[i]);\n\treturn 1;\n } else if (free_axe<0)\n\tfree_axe = i;\n else\n\tdims[i] = 1;\n if (free_axe>=0) {\n dims[free_axe] = arr_size/new_size;\n new_size *= dims[free_axe];\n }\n if (new_size != arr_size) {\n fprintf(stderr,\"confused: new_size=%\" INTP_FMT\n\t \", arr_size=%\" INTP_FMT \" (maybe too many free\"\n\t \" indices)\\n\", new_size,arr_size);\n return 1;\n }\n } else { /* [[1,2]] -> [[1],[2]] */\n int i,j;\n intp d;\n int effrank;\n intp size;\n for (i=0,effrank=0;ind;++i)\n if (arr->dimensions[i]>1) ++effrank;\n if (dims[rank-1]>=0)\n if (effrank>rank) {\n\tfprintf(stderr,\"too many axes: %d (effrank=%d), expected rank=%d\\n\",\n\t\tarr->nd,effrank,rank);\n\treturn 1;\n }\n /*\n for (i=0,j=0;ind && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n if (dims[i]>=0) {\n\tif (d>1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \" (real index=%d)\\n\",\n\t\t i,dims[i],d,j-1);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else\n\tdims[i] = d;\n }\n */\n for (i=0; idimensions[i];\n if (dims[i]>=0) {\n\tif (d > 1 && d!=dims[i]) {\n\t fprintf(stderr,\"%d-th dimension must be fixed to %\" INTP_FMT \n\t\t \" but got %\" INTP_FMT \"\\n\",\n\t\t i,dims[i],d);\n\t return 1;\t \n\t}\n\tif (!dims[i]) dims[i] = 1;\n } else dims[i] = d;\n }\n for (i=rank;ind;++i) { /* [[1,2],[3,4]] -> [1,2,3,4] */\n while (jnd && arr->dimensions[j]<2) ++j;\n if (j>=arr->nd) d = 1;\n else d = arr->dimensions[j++];\n dims[rank-1] *= d;\n }\n for (i=0,size=1;ind);\n for (i=0;ind;++i) fprintf(stderr,\" %\" INTP_FMT,arr->dimensions[i]);\n fprintf(stderr,\" ]\\n\");\n return 1;\n }\n }\n return 0;\n}\n\n/* End of file: array_from_pyobj.c */\n\n/************************* copy_ND_array *******************************/\n\nextern\nint copy_ND_array(const PyArrayObject *arr, PyArrayObject *out)\n{\n F2PY_REPORT_ON_ARRAY_COPY_FROMARR;\n return PyArray_CopyInto(out, (PyArrayObject *)arr);\n}\n\n#ifdef __cplusplus\n}\n#endif\n/************************* EOF fortranobject.c *******************************/\n", + "methods": [ + { + "name": "PyFortranObject_New", + "long_name": "PyFortranObject_New( FortranDataDef * defs , f2py_void_func init)", + "filename": "fortranobject.c", + "nloc": 31, + "complexity": 11, + "token_count": 312, + "parameters": [ + "defs", + "init" + ], + "start_line": 20, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "PyFortranObject_NewAsAttr", + "long_name": "PyFortranObject_NewAsAttr( FortranDataDef * defs)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 69, + "parameters": [ + "defs" + ], + "start_line": 53, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "fortran_dealloc", + "long_name": "fortran_dealloc( PyFortranObject * fp)", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "fp" + ], + "start_line": 66, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "fortran_doc", + "long_name": "fortran_doc( FortranDataDef def)", + "filename": "fortranobject.c", + "nloc": 46, + "complexity": 21, + "token_count": 434, + "parameters": [ + "def" + ], + "start_line": 78, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "set_data", + "long_name": "set_data( char * d , intp * f)", + "filename": "fortranobject.c", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "d", + "f" + ], + "start_line": 126, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "fortran_getattr", + "long_name": "fortran_getattr( PyFortranObject * fp , char * name)", + "filename": "fortranobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 519, + "parameters": [ + "fp", + "name" + ], + "start_line": 135, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "fortran_setattr", + "long_name": "fortran_setattr( PyFortranObject * fp , char * name , PyObject * v)", + "filename": "fortranobject.c", + "nloc": 59, + "complexity": 22, + "token_count": 647, + "parameters": [ + "fp", + "name", + "v" + ], + "start_line": 190, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 1 + }, + { + "name": "fortran_call", + "long_name": "fortran_call( PyFortranObject * fp , PyObject * arg , PyObject * kw)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 166, + "parameters": [ + "fp", + "arg", + "kw" + ], + "start_line": 253, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_clock", + "long_name": "f2py_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 313, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_call_clock", + "long_name": "f2py_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 315, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_clock", + "long_name": "f2py_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 320, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_call_clock", + "long_name": "f2py_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 326, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_clock", + "long_name": "f2py_cb_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 334, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_call_clock", + "long_name": "f2py_cb_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_clock", + "long_name": "f2py_cb_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_call_clock", + "long_name": "f2py_cb_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 347, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_exit", + "long_name": "f2py_report_on_exit( int exit_flag , * name)", + "filename": "fortranobject.c", + "nloc": 24, + "complexity": 2, + "token_count": 146, + "parameters": [ + "exit_flag", + "name" + ], + "start_line": 357, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy", + "long_name": "f2py_report_on_array_copy( PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "arr" + ], + "start_line": 387, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy_fromany", + "long_name": "f2py_report_on_array_copy_fromany()", + "filename": "fortranobject.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 394, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "count_nonpos", + "long_name": "count_nonpos( const int rank , const intp * dims)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 48, + "parameters": [ + "rank", + "dims" + ], + "start_line": 428, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "dump_attrs", + "long_name": "dump_attrs( const PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 3, + "token_count": 117, + "parameters": [ + "arr" + ], + "start_line": 443, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "swap_arrays", + "long_name": "swap_arrays( PyArrayObject * arr1 , PyArrayObject * arr2)", + "filename": "fortranobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 111, + "parameters": [ + "arr1", + "arr2" + ], + "start_line": 463, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "array_from_pyobj", + "long_name": "array_from_pyobj( const int type_num , intp * dims , const int rank , const int intent , PyObject * obj)", + "filename": "fortranobject.c", + "nloc": 130, + "complexity": 42, + "token_count": 825, + "parameters": [ + "type_num", + "dims", + "rank", + "intent", + "obj" + ], + "start_line": 482, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 158, + "top_nesting_level": 1 + }, + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 85, + "complexity": 30, + "token_count": 682, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 113, + "top_nesting_level": 1 + }, + { + "name": "copy_ND_array", + "long_name": "copy_ND_array( const PyArrayObject * arr , PyArrayObject * out)", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "arr", + "out" + ], + "start_line": 765, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "PyFortranObject_New", + "long_name": "PyFortranObject_New( FortranDataDef * defs , f2py_void_func init)", + "filename": "fortranobject.c", + "nloc": 31, + "complexity": 11, + "token_count": 312, + "parameters": [ + "defs", + "init" + ], + "start_line": 20, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "PyFortranObject_NewAsAttr", + "long_name": "PyFortranObject_NewAsAttr( FortranDataDef * defs)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 69, + "parameters": [ + "defs" + ], + "start_line": 53, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "fortran_dealloc", + "long_name": "fortran_dealloc( PyFortranObject * fp)", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "fp" + ], + "start_line": 66, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "fortran_doc", + "long_name": "fortran_doc( FortranDataDef def)", + "filename": "fortranobject.c", + "nloc": 46, + "complexity": 21, + "token_count": 434, + "parameters": [ + "def" + ], + "start_line": 78, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 1 + }, + { + "name": "set_data", + "long_name": "set_data( char * d , intp * f)", + "filename": "fortranobject.c", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "d", + "f" + ], + "start_line": 126, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "fortran_getattr", + "long_name": "fortran_getattr( PyFortranObject * fp , char * name)", + "filename": "fortranobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 519, + "parameters": [ + "fp", + "name" + ], + "start_line": 135, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "fortran_setattr", + "long_name": "fortran_setattr( PyFortranObject * fp , char * name , PyObject * v)", + "filename": "fortranobject.c", + "nloc": 59, + "complexity": 22, + "token_count": 647, + "parameters": [ + "fp", + "name", + "v" + ], + "start_line": 190, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 1 + }, + { + "name": "fortran_call", + "long_name": "fortran_call( PyFortranObject * fp , PyObject * arg , PyObject * kw)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 166, + "parameters": [ + "fp", + "arg", + "kw" + ], + "start_line": 253, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_clock", + "long_name": "f2py_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 313, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_start_call_clock", + "long_name": "f2py_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 315, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_clock", + "long_name": "f2py_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 320, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_stop_call_clock", + "long_name": "f2py_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 326, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_clock", + "long_name": "f2py_cb_start_clock()", + "filename": "fortranobject.c", + "nloc": 1, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 334, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 1, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_start_call_clock", + "long_name": "f2py_cb_start_call_clock()", + "filename": "fortranobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [], + "start_line": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_clock", + "long_name": "f2py_cb_stop_clock()", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "f2py_cb_stop_call_clock", + "long_name": "f2py_cb_stop_call_clock()", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [], + "start_line": 347, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_exit", + "long_name": "f2py_report_on_exit( int exit_flag , * name)", + "filename": "fortranobject.c", + "nloc": 24, + "complexity": 2, + "token_count": 146, + "parameters": [ + "exit_flag", + "name" + ], + "start_line": 357, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy", + "long_name": "f2py_report_on_array_copy( PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "arr" + ], + "start_line": 387, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "f2py_report_on_array_copy_fromany", + "long_name": "f2py_report_on_array_copy_fromany()", + "filename": "fortranobject.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 394, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "count_nonpos", + "long_name": "count_nonpos( const int rank , const intp * dims)", + "filename": "fortranobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 48, + "parameters": [ + "rank", + "dims" + ], + "start_line": 428, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "dump_attrs", + "long_name": "dump_attrs( const PyArrayObject * arr)", + "filename": "fortranobject.c", + "nloc": 16, + "complexity": 3, + "token_count": 117, + "parameters": [ + "arr" + ], + "start_line": 443, + "end_line": 458, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "swap_arrays", + "long_name": "swap_arrays( PyArrayObject * arr1 , PyArrayObject * arr2)", + "filename": "fortranobject.c", + "nloc": 10, + "complexity": 1, + "token_count": 111, + "parameters": [ + "arr1", + "arr2" + ], + "start_line": 463, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "array_from_pyobj", + "long_name": "array_from_pyobj( const int type_num , intp * dims , const int rank , const int intent , PyObject * obj)", + "filename": "fortranobject.c", + "nloc": 130, + "complexity": 42, + "token_count": 825, + "parameters": [ + "type_num", + "dims", + "rank", + "intent", + "obj" + ], + "start_line": 482, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 158, + "top_nesting_level": 1 + }, + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 85, + "complexity": 30, + "token_count": 682, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 754, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 1 + }, + { + "name": "copy_ND_array", + "long_name": "copy_ND_array( const PyArrayObject * arr , PyArrayObject * out)", + "filename": "fortranobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "arr", + "out" + ], + "start_line": 761, + "end_line": 765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_and_fix_dimensions", + "long_name": "check_and_fix_dimensions( const PyArrayObject * arr , const int rank , intp * dims)", + "filename": "fortranobject.c", + "nloc": 85, + "complexity": 30, + "token_count": 682, + "parameters": [ + "arr", + "rank", + "dims" + ], + "start_line": 646, + "end_line": 758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 113, + "top_nesting_level": 1 + } + ], + "nloc": 608, + "complexity": 175, + "token_count": 4679, + "diff_parsed": { + "added": [ + " /* old f2py used to swap the dimensions so that dims had", + " reversed dimensions from arr->dimensions -- don't do that", + " anymore...", + " */" + ], + "deleted": [] + } + } + ] + } +] \ No newline at end of file