v]c @`s$ddlmZmZmZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZddlmZmZmZddlZddlmZmZddd d d d d dddddg ZdZdZdefdYZdZdZdZddZ!dZ"da#da$ddZ%ej&dZ'edddej&dd Z(edej&d!Z)ia*ej+d"ej,Z-edde.e/dd#Z0d$Z1d%Z2d&efd'YZ3d(Z4d)Z5dS(*i(tdivisiontabsolute_importtprint_functionN(t issubclass_t issubsctypet issubdtype(t set_module(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_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs  *$cC`s ||_|S(N(t__name__(tfunctname((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt_set_function_name5s 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_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt__init__Fs  c `s,|j}|j}|j}|dkrTy j}WqTtk rPj}qTXn|dkrmd|nd||f|dk rd|7nfd}t||}j}|dkr}ndj|g}||_y j } Wntk rnX|j j | |S(s: Decorator call. Refer to ``decorate``. s`%s` is deprecated!s%`%s` is deprecated, use `%s` instead!s c`s#tjtdd||S(s1`arrayrange` is deprecated, use `arange` instead!t stackleveli(twarningstwarntDeprecationWarning(targstkwds(tdepdocR"(s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytnewfuncbss N( R&R'R(RR!tAttributeErrorR$t__doc__Rt__dict__tupdate( R)R"R/tkwargsR&R'R(R2tdocR ((R1R"s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt__call__Ks6                N(R!t __module__R4RR*R9(((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyR%:s cO`s>|r-|d}|d}t|||St||SdS(s Issues a DeprecationWarning, adds warning to `old_name`'s docstring, rebinds ``old_name.__name__`` and returns the new function object. This function may also be used as a decorator. Parameters ---------- func : function The function to be deprecated. old_name : str, optional The name of the function to be deprecated. Default is None, in which case the name of `func` is used. new_name : str, optional The new name for the function. Default is None, in which case the deprecation message is that `old_name` is deprecated. If given, the deprecation message is that `old_name` is deprecated and `new_name` should be used instead. message : str, optional Additional explanation of the deprecation. Displayed in the docstring after the warning. Returns ------- old_func : function The deprecated function. Examples -------- Note that ``olduint`` returns a value after printing Deprecation Warning: >>> 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 iiN(R%(R/R7tfn((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyR vs .  cC`s td|S(NR((R%(tmsg((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyttc 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__R tdtypetitemsizeRtsizetzip( tataita_datatastridestashapetbytes_ata_lowta_highRAtstride((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-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((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs^,        ' &  c C`st|}|}|}d}|j|}x|D]}||krOd} n|} |t|t| }||kr|dt|}|dd|d|}q4|| |}q4W|S(Ns, R>is, RPi(R^tsplit( R#t argumentstwidtht firstwidthRptnewstrtsepstrtarglisttargumenttaddstr((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt _split_lineUs     RcC`st|ttg}i|j|j6}|jg}|jg}xtrt|dkrePn|jd}xz|jD]l}t ||t j r||j}||kr||j}|j ||j ||||cS`s|S(N((R((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyR=R>t __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((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/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. ***RPs s()R*s, t(s Methods: t_Rs %s -- %sisInstance of class: R9R#s%ssR4(*tpydoctinspectthasattrRRRRRWRRRZt _namedictRt _dictlistRXRaR\tKeyErrort isfunctionR!R R R^RtgetdoctisclassR*t__func__RvRt Exceptiont allmethodsRtsplitdocRRt version_infoRt InstanceTypeRR9R#tismethod(tobjecttmaxwidthRttoplevelRRtnumfoundtobjlistRhRR#RwtargstrR|tdoc1tmethodstmethtthisobjtmethstrtotherR8((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs4                   "   !$     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.(RRat getsourcefilet getsourceR(RRR((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-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 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( RtlowertstripRvtsumR^tgettcountR`(R#tdocstrtkindtindextrt first_doctw(tkind_relevancetwhats(s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt relevance s(//c`s||S(N((RG(ReR(s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytrelevance_valuestkeysSearch results for '%s'RPRis iR>s %s %ssNothing found.i (RR(Rt_lookfor_generate_cacheRZRRvtitemsRRR\tsortRR^Rt_function_signature_retsearcht IndexErrorRtwritetgetpagerRa(twhatRtimport_modulest regenerateRRtfoundR#t docstringRRtokR8RRtst help_texttixtlinetdoclinesRtpager((ReRRRs_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-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|s                     '$$    cC`stddl}y|j|}WnNtk rogt|D]*}t||r<|t||f^q<}nX|S(Ni(Rt getmembersRtdirRR(R RtmembersR((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs  .tSafeEvalcB`seZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(s Object to evaluate constant string expressions. This includes strings with lists, dicts and tuples using the abstract syntax tree created by ``compiler.parse``. .. deprecated:: 1.10.0 See Also -------- safe_eval cC`stjdtdddS(Ns3SafeEval is deprecated in 1.10 and will be removed.R+i(R,R-R.(R)((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyR*s cC`s/|j}t|d|j|j}||S(Ntvisit(RRR!tdefault(R)tnodeRR((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs cC`std|jdS(Ns Unsupported source construct: %s(t SyntaxErrorR(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRscC`s|j|jS(N(Rtbody(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytvisitExpressionscC`s|jS(N(R(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytvisitNumscC`s|jS(N(R(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytvisitStrscC`s|jS(N(R(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitBytesscK`sJtgt|j|jD]*\}}|j||j|f^qS(N(tdictRFRVtvaluesR(R)R tkwRpR((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitDict scC`s)tg|jD]}|j|^q S(N(RteltsR(R)R ti((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitTuplescC`s#g|jD]}|j|^q S(N(R+R(R)R R,((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitListscC`soddl}t|j|jr2|j|j St|j|jrX|j|j Std|jdS(NisUnknown unary op: %r(tastRWtoptUAddRtoperandtUSubR!(R)R R/((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitUnaryOps  cC`sP|jdkrtS|jdkr&tS|jdkr9dStd|jdS(NRRRsUnknown name: %s(RXRRRR!(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyt visitNamescC`s|jS(N(R(R)R ((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pytvisitNameConstant's(R!R:R4R*RRR#R$R%R&R*R-R.R4R5R6(((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/utils.pyRs            cC`sddl}|j|S(s Protected string evaluation. Evaluate a string containing a Python literal expression without allowing the execution of arbitrary non-literal code. Parameters ---------- source : str The string to evaluate. Returns ------- obj : object The result of evaluating `source`. Raises ------ SyntaxError If the code has invalid Python syntax, or if it contains non-literal code. Examples -------- >>> 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(R/t literal_eval(RR/((s_/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/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||sN         < 6  9 i  3  3   I 1