9Zc @`sddlmZmZmZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZmZmZddlmZmZdddd d d d d ddddg ZdZdZdefdYZdZdZdZddZdZdada ddZ!ej"dZ#ddej"ddZ$ej"d Z%ia&ej'd!ej(Z)de*e+dd"Z,d#Z-d$Z.d%efd&YZ/d'Z0dS((i(tdivisiontabsolute_importtprint_functionN(t issubclass_t issubsctypet issubdtype(tndarraytufunctasarray(t getargspect formatargspecRRRt deprecatetdeprecate_with_doct get_includetinfotsourcetwhotlookfort byte_boundst safe_evalcC`s|ddl}|jdkrEtjjtjj|jdd}n3ddlj }tjjtjj|jd}|S(s Return the directory that contains the NumPy \*.h header files. Extension modules that need to compile against NumPy should use this function to locate the appropriate include directory. Notes ----- When using ``distutils``, for example in ``setup.py``. :: import numpy as np ... Extension('extension_name', ... include_dirs=[np.get_include()]) ... iNtcoretinclude( tnumpyt show_configtNonetostpathtjointdirnamet__file__t numpy.coreR(RtdR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyR s  *$cC`s ||_|S(N(t__name__(tfunctname((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt_set_function_name3s t _DeprecatecB`s)eZdZddddZdZRS(s Decorator class to deprecate old functions. Refer to `deprecate` for details. See Also -------- deprecate cC`s||_||_||_dS(N(told_nametnew_nametmessage(tselfR%R&R'((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt__init__Ds  c `s;|j}|j}|j}ddl|dkr`y j}Wq`tk r\j}q`Xn|dkryd|nd||f|dk rd|7nfd}t||}j}|dkr}ndj |g}||_y j } Wntk r&nX|j j | |S(s: Decorator call. Refer to ``decorate``. iNs`%s` is deprecated!s%`%s` is deprecated, use `%s` instead!s c`sjt||S(s1`arrayrange` is deprecated, use `arange` instead!(twarntDeprecationWarning(targstkwds(tdepdocR!twarnings(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pytnewfuncass ( R%R&R'R/RR tAttributeErrorR#t__doc__Rt__dict__tupdate( R(R!R,tkwargsR%R&R'R0tdocR((R.R!R/sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt__call__Is8                 N(R t __module__R2RR)R7(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyR$8s cO`s|rq|d}|d}d|kr<|jd|d>> olduint = np.deprecate(np.uint) >>> olduint(6) /usr/lib/python2.5/site-packages/numpy/lib/utils.py:114: DeprecationWarning: uint32 is deprecated warnings.warn(str1, DeprecationWarning) 6 iitnewnameR&toldnameR%N(tpopR$(R,R5tfn((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyR us.    cC`s td|S(NR'(R$(tmsg((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pytsc C`s|j}|dd}|d}|d}t|jj}|}}|dkrg||j|7}n]xPt||D]?\}} | dkr||d| 7}qw||d| 7}qwW||7}||fS(s1 Returns pointers to the end-points of an array. Parameters ---------- a : ndarray Input array. It must conform to the Python-side of the array interface. Returns ------- (low, high) : tuple of 2 integers The first integer is the first byte of the array, the second integer is just past the last byte of the array. If `a` is not contiguous it will not use every byte between the (`low`, `high`) values. Examples -------- >>> I = np.eye(2, dtype='f'); I.dtype dtype('float32') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True >>> I = np.eye(2, dtype='G'); I.dtype dtype('complex192') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True tdataitstridestshapeiN(t__array_interface__RtdtypetitemsizeRtsizetzip( tataita_datatastridestashapetbytes_ata_lowta_highRAtstride((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyRs       c C`s|dkr'tjj}|j}ng}i}x|jD]}t||tr@||}t|}||jkr|d||}d}n|||<|}d}dj t t |j } t |j } |j|| | |jj|gq@q@Wd} d} d} d}xtt|D]}||}| t|dkrit|d} n| t|dkrt|d} n| t|dkrt|d} n|dr0|t|d7}q0q0Wt|dkretd| }td| }td| }d|d |d |d f}t|d d t|d d nxtt|D]}||}td |dd |t|dd|dd |t|dd |dd |t|dd |dfqxWtd|dS(s% Print the Numpy arrays in the given dictionary. If there is no dictionary passed in or `vardict` is None then returns Numpy arrays in the globals() dictionary (all Numpy arrays in the namespace). Parameters ---------- vardict : dict, optional A dictionary possibly containing ndarrays. Default is globals(). Returns ------- out : None Returns 'None'. Notes ----- Prints out the name, shape, bytes and type of all of the ndarrays present in `vardict`. Examples -------- >>> a = np.arange(10) >>> b = np.ones(20) >>> np.who() Name Shape Bytes Type =========================================================== a 10 40 int32 b 20 160 float64 Upper bound on total bytes = 200 >>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str', ... 'idx':5} >>> np.who(d) Name Shape Bytes Type =========================================================== y 3 24 float64 x 2 16 float64 Upper bound on total bytes = 40 s (%s)iis x iii sName %s Shape %s Bytes %s Typet s t=is%s %s %s %s %s %s %sis' Upper bound on total bytes = %dN(Rtsyst _getframetf_backt f_globalstkeyst isinstanceRtidRtmaptstrRAtnbytestappendRCR"trangetlentinttmaxtprint(tvardicttframetstatcacheR"tvartidvtnamestrtoriginaltshapestrtbytestrtmaxnametmaxshapetmaxbytet totalbytestktvaltsp1tsp2tsp3tprval((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyRs^,        ' &  c C`st|}|}|}d}|j|}x|D]}||krOd} n|} |t|t| }||kr|dt|}|dd|d|}q4|| |}q4W|S(Ns, tis, RPi(R^tsplit( R"t argumentstwidtht firstwidthRptnewstrtsepstrtarglisttargumenttaddstr((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt _split_line[s     RcC`st|ttg}i|j|j6}|jg}|jg}xtrt|dkrePn|jd}xz|jD]l}t ||t j r||j}||kr||j}|j ||j ||||st __class__R sclass: tfilesshape: s strides: s itemsize: s aligned: s contiguous: s fortran: sdata pointer: %s%ss byteorder: tendRPt|RQs%s%s%st>s%sbig%stbigs %slittle%stlittles byteswap: stype: %sN(RRQ(tgetattrttypeR@RCt byteorderRaRARDtflagstalignedt contiguoustfortranthextctypest_as_parameter_tvalueRRtFalse( tobjtoutputtextrattictbptclstnmR@tendiantbyteswap((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt_infos8       iLcC`sddl}ddl}t|ds6t|drB|j}nt|dr]|j}n|dkrvttnt|trt |d|nxt|t rt dkrt |\a a nd}g}xt D]}yt ||} t| |krtd|d|nE|jt| td |d|t| td |d||d 7}Wqtk r~qXqW|dkrtd |d|qtd |d|nS|j|rP|j} tt|} t| | |krt| | |} n | | } td| dd|t|j|d|n|j|rX|j} d} ywt|drtt|jj} | jd} t| d krd| d | d >> np.info(np.polyval) # doctest: +SKIP polyval(p, x) Evaluate the polynomial p at x. ... When using a string for `object` it is possible to get multiple results. >>> np.info('fft') # doctest: +SKIP *** Found in numpy *** Core FFT routines ... *** Found in numpy.fft *** fft(a, n=None, axis=-1) ... *** Repeat reference found in numpy.fft.fftpack *** *** Total of 3 references found. *** iNt_ppimport_importert_ppimport_modulet_ppimport_attrRs+ *** Repeat reference found in %s *** Rs *** Found in %s ***t-isHelp for %s not found.s+ *** Total of %d references found. ***RPs s()R)s, t(s Methods: t_Rs %s -- %sisInstance of class: R7R"s%ssR2()tpydoctinspectthasattrRRRRRWRRRZt _namedictRt _dictlistRXRaR\tKeyErrort isfunctionR R R R^RtgetdoctisclassR)t__func__RwRt allmethodsRtsplitdocRRt version_infoRt InstanceTypeRR7R"tismethod(tobjecttmaxwidthRttoplevelRRtnumfoundtobjlistRhRR"RxtargstrR}tdoc1tmethodstmethtthisobjtmethstrtotherR6((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyRs3                  "   !$     cC`sdddl}y:td|j|d|t|j|d|Wntdd|nXdS(s Print or write to a file the source code for a Numpy object. The source code is only returned for objects written in Python. Many functions and classes are defined in C and will therefore not return useful information. Parameters ---------- object : numpy object Input object. This can be any object (function, class, module, ...). output : file object, optional If `output` not supplied then source code is printed to screen (sys.stdout). File object must be created with either write 'w' or append 'a' modes. See Also -------- lookfor, info Examples -------- >>> np.source(np.interp) #doctest: +SKIP In file: /usr/lib/python2.6/dist-packages/numpy/lib/function_base.py def interp(x, xp, fp, left=None, right=None): """.... (full docstring printed)""" if isinstance(x, (float, int, number)): return compiled_interp([x], xp, fp, left, right).item() else: return compiled_interp(x, xp, fp, left, right) The source code is only returned for objects written in Python. >>> np.source(np.array) #doctest: +SKIP Not available for this object. iNs In file: %s RsNot available for this object.(RRat getsourcefilet getsource(RRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyRs ( s[a-z0-9_]+\(.*[,=].*\)c`sddl}t|||g}t|jjsFdSxjD]v\}\}} } | dkrzqSnt} |j} x$D]} | | krt} PqqW| rS|j|qSqSWidd6dd6dd6dd6fd fd }|j d |d d j }|dt |g}x|dddD]}|\} } }g| j jdD]}|j r|j ^q}y6|dj }t j|r|dj }nWntk rd}nX|jd||fq`W|s4|jdn|dk rY|jdj |nGt |dkr|j}|dj |ntdj |dS(s Do a keyword search on docstrings. A list of of objects that matched the search is displayed, sorted by relevance. All given keywords need to be found in the docstring for it to be returned as a result, but the order does not matter. Parameters ---------- what : str String containing words to look for. module : str or list, optional Name of module(s) whose docstrings to go through. import_modules : bool, optional Whether to import sub-modules in packages. Default is True. regenerate : bool, optional Whether to re-generate the docstring cache. Default is False. output : file-like, optional File-like object to write the output to. If omitted, use a pager. See Also -------- source, info Notes ----- Relevance is determined only roughly, by checking if the keywords occur in the function name, at the start of a docstring, etc. Examples -------- >>> np.lookfor('binary representation') Search results for 'binary representation' ------------------------------------------ numpy.binary_repr Return the binary representation of the input number as a string. numpy.core.setup_common.long_double_representation Given a binary dump as given by GNU od -b, look for long double numpy.base_repr Return a string representation of a number in the given base system. ... iNRRiR!tclassic`sd}dj|jjjdd }|tgD]}||kr;d^q;7}|tgD]}||krjd^qj7}|t| d7}|j|d7}||jd d 7}|t| d d 7}|S( Nis iiiiit.i idi( RtlowertstripRwtsumR^tgettcountR`(R"tdocstrtkindtindextrt first_doctw(tkind_relevancetwhats(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyt relevances(//c`s||S(N((RG(ReR(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pytrelevance_valuestkeysSearch results for '%s'RPRis iRvs %s %ssNothing found.i (RR(Rt_lookfor_generate_cacheRZRRwtitemsRRR\tsortRR^Rt_function_signature_retsearcht IndexErrorRtwritetgetpagerRa(twhatRtimport_modulest regenerateRRtfoundR"t docstringRRtokR6RRtst help_texttixtlinetdoclinesRtpager((ReRRRsB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyRsV. "        cC`sddl}tjddkr2ddlm}nddlm}|dkrWd}nt|tryt|Wnt k riSXtj |}nRt|t st|t ri}x'|D]}|j t|||qW|St|tkr| rtt|Si}|tt|>> np.safe_eval('1') 1 >>> np.safe_eval('[1, 2, 3]') [1, 2, 3] >>> np.safe_eval('{"foo": ("bar", 10.0)}') {'foo': ('bar', 10.0)} >>> np.safe_eval('import os') Traceback (most recent call last): ... SyntaxError: invalid syntax >>> np.safe_eval('open("/home/user/.ssh/id_dsa").read()') Traceback (most recent call last): ... SyntaxError: Unsupported source construct: compiler.ast.CallFunc iN(R0t literal_eval(RR0((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pyR3s, (1t __future__RRRRRRRtreR/tnumpy.core.numerictypesRRRRRRRt numpy.compatR R RR R#RR$R R RRRRRRRRRRRRtcompiletIRRRRRRRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/utils.pytsB        = =  9 i  33   I