2[c@`sdZddlmZmZmZddlZddlZddlmZm Z ddl m Z m Z m Z yddlZWnek rdZnXddlmZejdkrd Znd Zd Zd Zd ZdZejdZejdZejdZied6ZdZdefdYZ dZ!de!_"defdYZ#defdYZ$dZ%dZ&dZ'dZ(idd6d d!6d"d"6d#d#6d$d$6d%d%6d&d&6d'd'6d(d(6d)d)6d*d*6d+d+6d,d,6d-d-6d.d.6d/d/6d0d16d2d36d4d56d6d76d8d96d:d:6d;d<6Z)d=j*e)j+Z,idd6d d!6d"d"6d#d#6d>d$6d?d%6d@d&6dAd'6d@d(6dAd)6dBd*6dCd+6dDd,6d-d-6d.d.6d0d16d2d36d6d76d8d96d:d:6d;d<6Z-d=j*e-j+Z.dEZ/dFZ0dGZ1dHZ2dIZ3dJZ4dKZ5dLe6fdMYZ7dNe8e9fdOYZ:dPZ;dQZ<dRZ=dS(Ss_ A place for code to be called from core C-code. Some things are more easily handled Python. i(tdivisiontabsolute_importtprint_functionN(t basestringtunicodei(tdtypetarraytndarray(tobject_tlittletcC`sg}t|j}x|D]}||}t|}t|t sW|d krftdn|dkr|d|krqnt|d}|dkrtdnt|dd|}|dkr|d} nd} |j |||| fqW|j dd g|D]} | d^q} g|D]} | d^q<} g|D]} | d^qY} g|D]} | d^qv}| | | |fS( Niisentry not a 2- or 3- tupleiisinvalid offset.taligntkeycS`s|dS(Ni((tx((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt-s(ii( tlisttkeystlent isinstancettuplet ValueErrortintRtNonetappendtsort(tadictR t allfieldstfnamestfnametobjtntnumtformatttitleRtnamestformatstoffsetsttitles((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt_makenames_lists.      cC`sy|d}Wntk r'd}nX|dkrRt||\}}}}ng}g}g}xm|D]e}||}|j|d|j|dt|dkr|j|dqk|jdqkWti|d6|d6|d6|d6|S( NiiiiR#R$R%R&(tKeyErrorRR'RRR(RR R#R$R%R&tnametres((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _usefields8s(      c C`s|j}|dkr|j}|dkrl|jdkr@|jS|jj}|rb|j|fS|jSqt|d|dfSn|j}g|D]}|||f^q}g}d}x|D] } | d|kr| d|} |jdd| f|| 7}n| d|kr.t dnt | dkrW| d| df} n | d} | djr| t| djd| djdf} n| t| df} || dj 7}|j| qW|j |kr |j |} |jdd| fn|S(Niits|V%dsLdtype.descr is not defined for types with overlapping or out-of-order fieldsii( tfieldsRtsubdtypetmetadatatstrtcopyt _array_descrR#RRRtitemsize( t descriptorR-R.tnewR#Rtordered_fieldstresulttoffsettfieldR R)ttup((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyR2XsH       $      cC`stj|||S(N(Rt__new__(tsubtypetshapeR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _reconstructssx(?P[<>|=]?)(?P *[(]?[ ,0-9L]*[)]? *)(?P[<>|=]?)(?P[A-Za-z0-9.?]*(?:\[[a-zA-Z0-9,.]+\])?)s\s*,\s*s\s+$t=c C`sd}g}x|t|krtj|d|}y|j\}}}}Wn7ttfk rtdt|d|fnX|j}|t|krtj|d|rt|}qt j|d|}|s tdt|d|fn|j}n|dkr0|}nd|dkrE|}nOt j ||}t j ||}||krtd||fn|}|ddt gkrd}n||}|dkr|} n|t |f} |j| qW|S( Nitposs*format number %d of "%s" is not recognizediR,s/inconsistent byte-order specification %s and %st|R?(Rt format_retmatchtgroupst TypeErrortAttributeErrorRtendtspace_retsep_ret _convordertgett_nbotevalR( tastrt startindexR7tmotorder1trepeatstorder2Rtordertnewitem((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _commastringsL          t dummy_ctypecB`s5eZdZdZdZdZdZRS(cC`s ||_dS(N(t_cls(tselftcls((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__init__scC`s|S(N((RYtother((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__mul__scG`s |j|S(N(RX(RYR\((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__call__scC`s|j|jkS(N(RX(RYR\((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__eq__scC`s|j|jkS(N(RX(RYR\((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__ne__s(t__name__t __module__R[R]R^R_R`(((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyRWs     cC`stj}|dk r|StdkrCddl}t|j}n`tdj}|dkrjtj }n9|dkrtj }n!|dkrtj }n tj }|t_|S(Nitptitltq( t_getintp_ctypetcacheRtctypestnumpyRWtintpRtchartc_inttc_longt c_longlong(tvaltnpRl((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyRgs             t_missing_ctypescB`seZdZdZRS(cC`s|S(N((RYR R((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytcastscC`s|S(N((RYR ((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytc_void_ps(RaRbRsRt(((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyRrs t_ctypescB`seZd dZdZdZdZdZdZdZ dZ e ed dd Z e ed dd Z e e d dd Ze e d dd ZRS(cC`s[trt|_n t|_||_||_|jjdkrNt|_n t|_dS(Ni( RiRuRrt_arrt_datatndimtTruet_zerodtFalse(RYRtptr((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyR[s     cC`s|jj|j|S(N(RuRsRw(RYR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytdata_asscC`s'|jr dS||jj|jjS(N(RzRRvRxR=(RYR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytshape_ass cC`s'|jr dS||jj|jjS(N(RzRRvRxtstrides(RYR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt strides_as s cC`s|jS(N(Rw(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytget_datascC`s|jtS(N(R~Rg(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt get_shapescC`s|jtS(N(RRg(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt get_stridesscC`s|jj|jS(N(RuRtRw(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytget_as_parameterstdocs c-types datas c-types shapesc-types stridess_as parameter_N(RaRbRR[R}R~RRRRRtpropertytdataR=Rt_as_parameter_(((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyRus       cC`s|j}t|}t|ttfr6|g}nt}t|ttfrxu|D]m}y|j|WnFtk r||krtd|fqtd|fnX|j |q[Wtt||Std|fdS(sf Given a datatype and an order object, return a new names tuple, with the order indicated sduplicate field name: %ssunknown field name: %ssunsupported order value: %sN( R#RRR0RtsetRtremoveRtadd(tdatatypeRTtoldnamest nameslisttseenR)((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _newnames"s        cC`sW|j}i|jd6g|jD]}|j|d^q d6}t|d|dtS(sReturn copy of structured array with padding between fields removed. Parameters ---------- ary : ndarray Structured array from which to remove padding bytes Returns ------- ary_copy : ndarray Copy of ary with padding bytes removed R#iR$RR1(RR#R-RRy(tarytdtR)t copy_dtype((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _copy_fields9s  +cC`s|js|jr|dkr.||kr.dS|jrxF|jD]8}|j|d|krA|j|d|krAdSqAWntdndS(s Checks safety of getfield for object arrays. As in _view_is_safe, we need to check that memory containing objects is not reinterpreted as a non-object datatype and vice versa. Parameters ---------- oldtype : data-type Data type of the original ndarray. newtype : data-type Data type of the field being accessed by ndarray.getfield offset : int Offset of the field being accessed by ndarray.getfield Raises ------ TypeError If the field access is invalid iNis'Cannot get/set field of an object array(t hasobjectR#R-RE(toldtypetnewtypeR8R)((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt_getfield_is_safeKs  cC`s5||krdS|js"|jr1tdndS(sz Checks safety of a view involving object arrays, for example when doing:: np.zeros(10, dtype=oldtype).view(newtype) Parameters ---------- oldtype : data-type Data type of original ndarray newtype : data-type Data type of the view Raises ------ TypeError If the new type is incompatible with the old type. Ns)Cannot change data-type for object array.(RRE(RR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt _view_is_safeks  t?tS1tctbtBthtHRdtIRetLRftQtetftdtgtFtZftDtZdtGtZgtStstUtwtOtVRR,ti2tu2ti4tu4ti8tu8tf2cC`s>dtfdY}||}t|dt\}}|S(NtStreamcB`sJeZdZdZdZdZedZdZeZ RS(cS`s||_d|_dS(Nt@(Rt byteorder(RYR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyR[s cS`s!|j| }|j||_|S(N(R(RYRR*((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytadvances cS`s4|jt| |kr0|jt|tStS(N(RRRRyR{(RYR((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytconsumescS`st|rYd}x7|t|jkrK||j| rK|d}qW|j|S|jj|}|j|}|jt||SdS(Nii(tcallableRRRtindex(RYRRdR*((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt consume_untils , cS`s |jdS(Ni(R(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytnextscS`s t|jS(N(tboolR(RY((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt__bool__s( RaRbR[RRRRRRt __nonzero__(((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyRs     t is_subdtype(tobjectt__dtype_from_pep3118R{(tspecRtstreamRR ((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt_dtype_from_pep3118s$ c C`sutdgdgdgdd}d}d}t}x|rd}|jdrUPnd}|jdr|jd }ttt|jd }n|j dkr|j d}|dkrd}n||_ n|j dkrt } t } n t} t} |jd} | r*t| } nd} t}|jdr`t|dt\}} n|j | kr|j dkr|j d}n|j d}|dk}| |}|dkr|d| 7}d} nid d 6d d6j|j |j }t||}|j} ntd|jd}|j d kr| | }|j | }||7}|dkr| dks|dk rt|dkrt||}q||7}nt| |}n| dkrt|| ff}n|dk rt||f}n|jdr2|jd}nd}|oG|dks|dk ry||dkrytd|n|dj||dj||dj|n||j7}||7}||dW|||ssToperand type(s) all returned NotImplemented from __array_ufunc__({!r}, {!r}, {}): {}((tjoinR!titemsRK( tdummytufunctmethodtinputstkwargsRtktvt args_stringtargst types_string((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pytarray_ufunc_errmsg_formatters%2c C`s|jdkrd}n"djdt|jD}|jdkrRd}nY|jdkrjd}nAdjd djd t|jDd td|j}d }|jdkrd |}ndjd|jd|d|d|S(sz Builds a signature string which resembles PEP 457 This is used to construct the first line of the docstring iRs, cs`s"|]}dj|dVqdS(sx{}iN(R!(RRd((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pys sis , /, out=()s , /, out=Nones%[, {positional}], / [, out={default}]t positionalcs`s"|]}dj|dVqdS(sout{}iN(R!(RRd((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pys stdefaultsM, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]s , where=Trues&{name}({in_args}{out_args}, *{kwargs})R)tin_argstout_argsR N(N( tninRtrangetnoutR!RRt signatureRa(RRRR ((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt_ufunc_doc_signature_formatters& "      cC`s=y$t|jd}d|jkSWntk r8tSXdS(NiRi(Rt__mro__Rbt ExceptionR{(Rt ctype_base((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyt_is_from_ctypess  (>Rt __future__RRRtretsyst numpy.compatRRt multiarrayRRRRit ImportErrorRt numerictypesRRRLR'R+R2R>tcompileRBRIRHRJRVRRWRgRhRrRuRRRRRRRRRRRRRRRRRRRRt IndexErrorRRRR(((s3/tmp/pip-build-fiC0ax/numpy/numpy/core/_internal.pyts       4   /  ,      +      .