2[c @`sddlmZmZmZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZmZmZddlZddlmZmZdddd d d d d ddddg ZdZdZdefdYZdZdZdZddZdZ da!da"ddZ#ej$dZ%ddej$ddZ&ej$d Z'ia(ej)d!ej*Z+de,e-dd"Z.d#Z/d$Z0d%efd&YZ1d'Z2d(Z3dS()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((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyR s  *$cC`s ||_|S(N(t__name__(tfunctname((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyt_set_function_name4s 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'((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyt__init__Es  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`s#jtdd||S(s1`arrayrange` is deprecated, use `arange` instead!t stackleveli(twarntDeprecationWarning(targstkwds(tdepdocR!twarnings(s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pytnewfuncbss ( R%R&R'R0RR tAttributeErrorR#t__doc__Rt__dict__tupdate( R(R!R-tkwargsR%R&R'R1tdocR((R/R!R0s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyt__call__Js8                 N(R t __module__R3RR)R8(((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyR$9s 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, stacklevel=2) 6 iitnewnameR&toldnameR%N(tpopR$(R-R6tfn((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyR vs.    cC`s td|S(NR'(R$(tmsg((s./tmp/pip-build-fiC0ax/numpy/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_highRBtstride((s./tmp/pip-build-fiC0ax/numpy/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 isinstanceRtidRtmaptstrRBtnbytestappendRDR"trangetlentinttmaxtprint(tvardicttframetstatcacheR"tvartidvtnamestrtoriginaltshapestrtbytestrtmaxnametmaxshapetmaxbytet totalbytestktvaltsp1tsp2tsp3tprval((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyRs^,        ' &  c C`st|}|}|}d}|j|}x|D]}||krOd} n|} |t|t| }||kr|dt|}|dd|d|}q4|| |}q4W|S(Ns, tis, RQi(R_tsplit( R"t argumentstwidtht firstwidthRqtnewstrtsepstrtarglisttargumenttaddstr((s./tmp/pip-build-fiC0ax/numpy/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 ||||s%sbig%stbigs %slittle%stlittles byteswap: stype: %sN(RRR(tgetattrttypeRARDt byteorderRbRBREtflagstalignedt contiguoustfortranthextctypest_as_parameter_tvalueRStFalse( tobjtoutputtextrattictbptclstnmRAtendiantbyteswap((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyt_infos8       iLcC`sddl}ddl}t|ds6t|drB|j}nt|dr]|j}n|dkrvttnt|trt |d|nt|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|n]|j|rP|j} tt|} t| | |krt| | |} n | | } td| dd|t|j|d|n|j|rb|j} d} ywt|drtt|jj} | jd} t| d krd| d | d |j!|j|p/d\}}ntd||fd|qWqnt"j#ddkr t|t$j%r td|j&jd|td|t|drtt|j'j} | 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. ***RQs s()R)s, t(s Methods: t_Rs %s -- %sisInstance of class: R8R"s%ssR3(*tpydoctinspectthasattrRRRRRXRRR[t _namedictRt _dictlistRYRbR]tKeyErrort isfunctionR R R R_RtgetdoctisclassR)t__func__RxRt Exceptiont allmethodsRtsplitdocRSt version_infoRt InstanceTypeRR8R"tismethod(tobjecttmaxwidthRttoplevelRRtnumfoundtobjlistRiRR"RytargstrR~tdoc1tmethodstmethtthisobjtmethstrtotherR7((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyRs3                   "   !$     cC`snddl}y:td|j|d|t|j|d|Wn!tk ritdd|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.(RRbt getsourcefilet getsourceR(RRR((s./tmp/pip-build-fiC0ax/numpy/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 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( RtlowertstripRxtsumR_tgettcountRa(R"tdocstrtkindtindextrt first_doctw(tkind_relevancetwhats(s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyt relevances(//c`s||S(N((RH(RfR(s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pytrelevance_valuestkeysSearch results for '%s'RQRis iRws %s %ssNothing found.i (RR(Rt_lookfor_generate_cacheR[RRxtitemsRRR]tsortRR_Rt_function_signature_retsearcht IndexErrorRtwritetgetpagerRb(twhatRtimport_modulest regenerateRRtfoundR"t docstringRRtokR7RRtst help_texttixtlinetdoclinesRtpager((RfRRRs./tmp/pip-build-fiC0ax/numpy/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((s./tmp/pip-build-fiC0ax/numpy/numpy/lib/utils.pyR.s, cC`s5|jdkr|Stj||d}tj|d }tjj|r_|jt}n|jdkr|t kr1t j dt dd|d k r|jjtj|d<|}q|jjtj}q1nXtj|jdkr1t j ddtj|jt ddtj||sF         = =  9 i  33   I 1