Kc@sB dZddlZddlZddljjZddljjZddlm Z m Z m Z ddlm Z m Z ddlmZmZddljjZddlZiZiZeZedZdZdefd YZd fd YZed Zd Zd dZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dddZ(dZ)dZ*e+dZ,dZ-dZ.dfd YZ/d!fd"YZ0d#fd$YZ1d%fd&YZ2d'fd(YZ3d)fd*YZ4d+fd,YZ5d-fd.YZ6e3ej7d/e2d/Z7e3ej8d0e1d/Z8e3ej9d0e1d/Z9e3ej:Z:e3ej;Z;e3ej<Z<e3ej=Z=e3ej>d/e0dZ>e3ej?d/e/d1d0Z?e3ej@d/e/d1d0Z@e3ejAZAe3ejBZBe3ejCd0e2d0ZCe3ejDd/e/d1d2d0d2ZDe3ejEZEe3ejFZFe3ejGZGe3ejHZHe3ejIZIe3ejJZJd3ZKe3ejLZMe3ejNZNe3ejOZOe3ejPZPe6ejQZQe6ejRZRe+eR_Se6ejTd4d4ZTe5ejUe4dd4ZUe5ejVe4dd4ZVe5ejWe4dd4ZWe5ejXe4dd4ZXe5ejYe4dd4ZYe6ejZZZe6ej[d/d0Z[e+e[_Se6ej\Z\e+e\_Se6ej]Z]e+e]_Se6ej^Z^e+e^_Se6ej_Z_e+e__Se6ej`Z`e+e`_Se6ejaZae+ea_Se6ejbZbe6ejbd4d4jSZce6ejdZdedjSZee6ejfZfe6ejgZge6ejhZhe6ejiZid5Zjd6Zke+d7Zld8emfd9YZnenZod:ZpepZqepZrd4d;d<d=Zsd4d>Ztd;d<d4d?Zud4d@Zve+d4e+dAZwewZxdBZydCZzdDZ{dEZ|e+dFZ}dGZ~e+dHZedIZedJZe+dKZe+dLZee+dMZe+e+dNZe+e+dOZe+e+ddPZdQZe+dRdSZd4dTZd4dUZd4dVZd4dWZd4dXZd4dYZd4dZZd4d[Zd4d\Zd]Zd^Zdd_Zd`Ze+e+dRdaZe+dbZdRdcZddZdeZeZdfZeZdgZde+dhZdifdjYZeZdkfdlYZeZde+dmZddd4dnZddd4e+e+doZde+e+dpZde+e+dqZde+e+drZdsZe+dtZddulmZdvZdwZeeceo_eeeeo_eeeo_eeeo_eeeo_eeeeo_eeeo_dxZeeeo_[e+dyZeeeo_e+e+dzZeeeo_[ee;eo_eo_;eeeo_e+e+e+d{Zeeeo_e+e+e+d|Zeeeo_eeeo_eeeo_eeeo_eeeo_eeeeo_eeeo_eeeo_e+e+d}Zeeeo_[e+e+d~Zeeeo_[eeeo_eeeeo_eeeo_eeKeo_Keeeo_e+e+dZeeeo_ee}eo_ee|eo_|eeeo_eeeo_eeeo_eeeo_dZeeeo_eeeeo_eeeo_dZeeeo_eeeo_eeeo_eeeo_eeeo_e+e+e+dZe+e+e+dZeeeo_eeeo_eeeo_eeMeo_[[[endedd4ZddZde+ddZddZdS(s0MA: a facility for dealing with missing observations MA is generally used as a numpy.array look-alike. by Paul F. Dubois. Copyright 1999, 2000, 2001 Regents of the University of California. Released for unlimited redistribution. Adapted for numpy_core 2005 by Travis Oliphant and (mainly) Paul Dubois. iN(tnewaxistndarraytinf(tamaxtamin(tbool_t typecodesigz8tMAErrorcBs#eZddZdZeZRS(cCs(t|ts|f}n||_dS(sCreate an exceptionN(t isinstancettupletargs(tselfR ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt__init__s cCst|jdS(s#Calculate the string representationi(tstrR (R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt__str__&sN(t__name__t __module__tNoneR Rt__repr__(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs  t_MaskedPrintOptioncBsMeZdZdZdZdZdZddZdZeZ RS(s<One instance of this class, masked_print_option, is created.cCs|j|d|_dS(s&Create the masked print option object.iN(t set_displayt_enabled(R tdisplay((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR -s cCs|jS(s#Show what prints for masked values.(t_display(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR2scCs ||_dS(s2set_display(s) sets what prints for masked values.N(R(R ts((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR6scCs|jS(s(Is the use of the display value enabled?(R(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytenabled:sicCs ||_dS(sSet the enabling flag to flag.N(R(R tflag((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytenable>scCs t|jS(N(R R(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRBs( RRt__doc__R RRRRRR(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR+s      s--g@xDyt-i?Bt?cCs t|tjrtSt|tjs:t|tjr>tSt|tjrTtSt|tj rjt St|t st|t r|j j}|tdkrtS|tdkrtS|tdkrt S|tdkrtS|tdkrtjtStStSdS(s7Function to calculate default fill value for an object.tFloattIntegertComplext CharactertUnsignedIntegerN(Rttypest FloatTypetdefault_real_fill_valuetIntTypetLongTypetdefault_integer_fill_valuet StringTypetdefault_character_fill_valuet ComplexTypetdefault_complex_fill_valuet MaskedArrayRtdtypetcharRtumathtabsolutetdefault_object_fill_value(tobjtx((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytdefault_fill_valueQs,$  cCst|tjrtjSt|tjs=t|tjrDtjSt|t sbt|t r|j j }|t dkrtjS|t dkrtjS|t dkrtjSn tddS(sDFunction to calculate default fill value suitable for taking minima.RR R#s(Unsuitable type for calculating minimum.N(RR$R%tnumericRR'R(tsystmaxintR.RR/R0Rt TypeError(R4R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytminimum_fill_valueks$  cCst|tjrt St|tjs;t|tjrCtj St|tsat|t r|j j }|t dkrt S|t dkrtj S|t dkrdSn t ddS(sDFunction to calculate default fill value suitable for taking maxima.RR R#is(Unsuitable type for calculating maximum.N(RR$R%RR'R(R8R9R.RR/R0RR:(R4R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmaximum_fill_value|s$ cCs t|r|j|ndS(s,Set fill value of a if it is a masked array.N(t isMaskedArraytset_fill_value(tat fill_value((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR>s cCs!t|tr|jStSdS(sMask of values in a; could be nomask. Returns nomask if a is not a masked array. To get an array for sure use getmaskarray.N(RR.traw_masktnomask(R?((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytgetmasks cCs0t|}|tkr(tt|S|SdS(sMask of values in a; an array of zeros if mask is nomask or not a masked array, and is a byte-sized integer. Do not try to add up entries, for example. N(RCRBtmake_mask_nonetshape(R?tm((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt getmaskarrays  cCs-y|jjtkSWntk r(tSXdS(s;Is m a legal mask? Does not check contents, only type. N(R/ttypetMaskTypetAttributeErrortFalse(RF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytis_masks cCs|tkrtSt|trp|jjtkr^|rUtj|dtd|}qm|}q|jt}nt |t jt}|rt j t j | rtS|SdS(smake_mask(m, copy=0, flag=0) return m as a mask, creating a copy if necessary or requested. Can accept any sequence of integers or nomask. Does not check that contents must be 0s and 1s. if flag, return nomask if m contains no true elements. R/tcopyN(RBRRR/RHRIR7tarraytastypetfilledtTruet fromnumerictsometruetravel(RFRMRtresult((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt make_masks  cCs"tj|dt}||_|S(s&Return a mask of all zeros of shape s.R/(R7tzerosRIRE(RRU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRDs cCs^|tkrt|S|tkr,t|S||krHt|rH|Sttj||S(sLogical or of the mask candidates m1 and m2, treating nomask as false. Result may equal m1 or m2 if the other is nomask. (RBRVRLR1t logical_or(tm1tm2((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmask_ors  cCsot|tr|j|St|tr<|jdr<|St|tjr^tj|dStj|SdS(sa as a contiguous numeric array with any masked areas replaced by value if value is None or the special element "masked", get_fill_value(a) is used instead. If a is already a contiguous numeric array, a itself is returned. filled(a) can be used to be sure that the result is numeric when passing an object a to other software ignorant of MA, in particular to numeric itself. t CONTIGUOUStON( RR.RPRtflagsR$tDictTypeR7RN(R?tvalue((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRPs  cCs+t|r|j}n t|}|S(sb The fill value of a, if it has one; otherwise, the default fill value for that type. (R=R@R6(R?RU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytget_fill_values  cCs,t|}t|}||kr(|SdS(s:The common fill_value of a and b, if there is one, or NoneN(RaR(R?tbtt1tt2((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytcommon_fill_values    tdomain_check_intervalcBs eZdZdZdZRS(s9domain_check_interval(a,b)(x) = true where x < a or y > bcCs||_||_dS(s9domain_check_interval(a,b)(x) = true where x < a or y > bN(ty1ty2(R RgRh((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR s cCs.tjtj||jtj||jS(sExecute the call behavior.(R1RXtgreaterRhtlessRg(R R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt__call__s(RRRR Rk(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRfs t domain_tancBs eZdZdZdZRS(s/domain_tan(eps) = true where abs(cos(x)) < eps)cCs ||_dS(s/domain_tan(eps) = true where abs(cos(x)) < eps)N(teps(R Rm((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR scCs%tjtjtj||jS(sExecute the call behavior.(R1RjR2tcosRm(R R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRks(RRRR Rk(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRl s tdomain_greatercBs eZdZdZdZRS(s(domain_greater(v)(x) = true where x <= vcCs ||_dS(s(domain_greater(v)(x) = true where x <= vN(tcritical_value(R Rp((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR scCstj||jS(sExecute the call behavior.(R1t less_equalRp(R R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRks(RRRR Rk(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRos tdomain_greater_equalcBs eZdZdZdZRS(s-domain_greater_equal(v)(x) = true where x < vcCs ||_dS(s-domain_greater_equal(v)(x) = true where x < vN(Rp(R Rp((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR scCstj||jS(sExecute the call behavior.(R1RjRp(R R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRk$s(RRRR Rk(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRrs tmasked_unary_operationcBs)eZdddZdZdZRS(icCsl||_||_||_t|dt||_t|dt||_|t|<|ft|d4Z?d5Z@d6ZAd7ZBd^d8ZCd9ZDd:ZEd^d;ZFd<ZGd=ZHd>ZId?ZJd@ZKdAZLdBZMdCZNeOdDeNdEdFZPdGZQeOdDeQdEdHZRdIZSd^dJZTdKZUeOeUdEeVjWjXjZXdLZYeOdDeYdEdMZZdNZ[eOdDe[dEdOZ\dPZ]dQZ^d^dRZ_d^dSZ`dTZadUZbdVZcdWZdeOe e dEdXZeeOe edEdYZfeOeedEdZZgeOeedEd[ZhehZieOecd^dEd\ZjeOedd^dEd]ZkRS(_sArrays with possibly masked values. Masked values of 1 exclude the corresponding element from any computation. Construction: x = array(data, dtype=None, copy=True, order=False, mask = nomask, fill_value=None) If copy=False, every effort is made not to copy the data: If data is a MaskedArray, and argument mask=nomask, then the candidate data is data.data and the mask used is data.mask. If data is a numeric array, it is used as the candidate raw data. If dtype is not None and is != data.dtype.char then a data copy is required. Otherwise, the candidate is used. If a data copy is required, raw data stored is the result of: numeric.array(data, dtype=dtype.char, copy=copy) If mask is nomask there are no masked values. Otherwise mask must be convertible to an array of booleans with the same shape as x. fill_value is used to fill in masked values when necessary, such as when printing and in method/function filled(). The fill_value is not used for computation within this module. g333333$@c Cs|dkrd}ntj|}|}t|tr|j} |dkrZ| j}n|| jkrrt}n|tkr|j}q|tk rt}qnxt|t r|} |dkr| j}q|| jkrt}qn0t }tj |d|dtd|} | j}|rk|| jkrVtj | d|dtd||_ qt| j ||_ n | |_ |tkrt|_d|_n0t||_|jtkrd|_n|j|k|_t|j} t|j } | | kr|| dkr1tj|j|j j|_d|_q| dkrptj|j |jj|_ |jj|j _qtdnI| dkrt|jt|j kr|j|j j|j_n|j|dS(sarray(data, dtype=None, copy=True, order=False, mask=nomask, fill_value=None) If data already a numeric array, its dtype becomes the default value of dtype. R/RMtorderiisMask and data not compatible.N(RR7R/RR.tdataRQRBtmaskRRKRNt_dataROt_maskt _shared_maskRVRRRtresizeRERt unshare_maskR>( R RR/RMRRR@ttctneed_data_copiedtctnmtnd((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR sb             ! '          * cCs|jtk rtj|jjr|dkrGtjd|jS|\}}}t j |}|dkrt d|n|j ||Sqt|_d|_ n|r|jj|S|jSdS(s:Special hook for numeric. Converts to numeric if possible.siCannot automatically convert masked array to numeric because data is masked in one or more locations.s%s not known to maiN(RRBRRRTtanyRtwarningstwarnRRytgetRRPRRO(R RtcontexttfuncR titfills((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt __array__]s     c Cs'|dkr"t|dtdtS|d \}}t|}ttg|D]}t|^qI}|dk rt||g|D]}t|d|^q}n|tk ry |j }Wnt k rqX|j |krttg|D]}t |^q}qnt|dtd|S(spSpecial hook for ufuncs. Wraps the numpy array and sets the mask according to context. RMRiRN( RR.RKRBRxRR[RCRwRERJRG( R RNRRR RvR?RFRE((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt__array_wrap__ys   (  +   .cCs |jjS(sReturn the current shape.(RRE(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_shapescCs@||j_|jtk r<|jj|_||j_ndS(sSet the array's shape.N(RRERRBRM(R tnewshape((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _set_shapes cCsf|jtkr4t|jjdtd|jSt|jjd|jjd|jSdS(s"Calculate the flat value. RR@N(RRBR{RRTR@(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_flats  cCs|j}||(dS(sx.flat = valueN(RT(R R`ty((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _set_flats cCsZ|jtkr1t|jjdtd|jSt|jjd|jd|jSdS(s%Get the real part of a complex array.RR@N(RRBR{RtrealR@(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_reals  cCs|j}||dsN(RRRERRBRRtlisttonesRRRTRORRR1Rtsum( R RRFRtlsRRtwtn1tn2((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytcounts0             cCs t||S(s%s.dot(other) = innerproduct(s, other)(t innerproduct(R R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytdotscCs|jS(sGet the current fill value.(R(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR@scCs|j}|j}|tkr<|jdr/|S|jSn|dkrT|j}n|}|tkrxtj |}ny,tj |d|j dd}|||"s cCs |jjS(N(RR(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_ndim(scCs |jjS(N(RR(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_size,ss Number of elements in the array.cCs |jjS(N(RR/(R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _get_dtype1sstype of the array elements.cGs[|jtk rK|jj|}y|dr2tSWqKtk rGtSXn|jj|S(s Return Python scalar if possiblei(RRBRRt IndexErrorR(R R RF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR5s  cGs"|d}|d }|||R)R7RRR*RR+R/RR-R.R/RRR1R3REtflatRRRR0tT(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR.s A        /                            + + - '            "                              cCs t|tS(s9Is x a masked array, that is, an instance of MaskedArray?(RR.(R5((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR=zsgh㈵>g:0yE>c Cstt|t|}t|}t|}tt|ddd||jt}tt|ddd|djt} tjtj|| ||tj| } t j t j | S(s Returns true if all components of a and b are equal subject to given tolerances. If fill_value is 1, masked values considered equal. If fill_value is 0, masked values considered unequal. The relative error rtol should be positive and << 1.0 The absolute error atol comes into play for those elements of b that are very small or zero; it says how small a must be also. RMiRi( R[RCRPRNRORR1RqR2RRtalltrueRT( R?RbR@trtoltatolRFR}RR5RR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytallcloses   **0cCstt|t|}|tkrgt|}t|}tj||}tjtj|S|rt|}t|}tj||}t |d|dd}tjtjt|dSdSdS(s True if all entries of a and b are equal, using fill_value as a truth value where either or both are masked. RRMiiN( R[RCRBRPR1RRRR=RTRN(R?RbR@RFR5RRR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytallequals     cCstj}t||}t|jjtjrtj|||||||}t |dd}t |d|d|d|St ||d|SdS(s masked_values(data, value, rtol=1.e-5, atol=1.e-8) Create a masked array; mask is nomask if possible. If copy==0, and otherwise possible, result may share data values with original array. Let d = filled(data, value). Returns d masked where abs(data-value)<= atol + rtol * abs(value) if d is of a floating point type. Otherwise returns masked_object(d, value, copy) RiRRMR@N( R1R2RPt issubclassR/RHR7tfloatingRqRVRNt masked_object(RR`R>R?RMtabsRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt masked_valuess *cCsIt||}ttj||dd}t|d|d|d|S(s5Create array masked where exactly data equal to valueRiRRMR@(RPRVR1RRN(RR`RMRR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRDscCsttj||||S(soJust like range() except it returns a array whose type can be specified by the keyword argument dtype. (RNR7R(tstarttstoptstepR/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRscCsttj||S(sAConstruct a masked array from a string. Result will have no mask.(R{R7t fromstring(RR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRJscCsft|}|tkr:tjt||}t|Stjt|d|}t||SdS(sLeft shift n bitsiN(RCRBR1RRPR{(R?RRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    cCsft|}|tkr:tjt||}t|Stjt|d|}t||SdS(sRight shift n bitsiN(RCRBR1RRPR{(R?RRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    cCsht|}|tk r-tj||}nttjt||d|}|jt||S(swresize(a, new_shape) returns a new array with the specified shape. The original array's total size can be any size.R(RCRBRRRRNRPR>Ra(R?t new_shapeRFRU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs   $cCst|}t|tjrY|dkr6|j}n |j|}t|g|}nt|}|t k rt j |||}nt j |||}t ||}|j t||S(srepeat elements of a repeats times along axis repeats is a sequence of length a.shape[axis] telling how many times to repeat each element. N(RPRR$R'RRRER RCRBRRtrepeatR{R>Ra(R?trepeatsRtaftnumRFRRU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt new_repeats      cCsttj|S(s<identity(n) returns the identity matrix of shape n x n. (RNR7tidentity(R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRQscCsttj||S(sindices(dimensions,dtype=None) returns an array representing a grid of indices with row-only, and column-only variation. (RNR7tindices(t dimensionsR/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRRscCsttj||S(sPzeros(n, dtype=float) = an array of all zeros of the given length or shape.(RNR7RW(RER/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRW scCsttj||S(sNones(n, dtype=float) = an array of all ones of the given length or shape.(RNR7R(RER/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRscCst|}|j|S(s?Count of the non-masked elements in a, or along a certain axis.(R{R(R?R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs c Cs |dk rtdnt|}t|}t||}t|d}t|d}|jjtdkrtt j |||St t j |ddd}t||}|t krtt j ||Stj|d|}tt j |||SdS(sa**bs3-argument power not supported.iR iRN(RRRCR[RPR/R0RR{R1RRVRjRBR7R( R?RbRRRRFtfatfbtmd((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs     cCst|d|ddd|S(s]masked_array(a, mask=nomask) = array(a, mask=mask, copy=0, fill_value=fill_value) RRMiR@(RN(R?RR@((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR{/scCs4|dkr!t|}d}ntj|||S(Ni(RRTRR(RRR/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR5s   cCs4|dkr!t|}d}ntj|||S(Ni(RRTRR(RRR/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytproduct;s   c Cst|}|j}|j}|d kr3d}n|d kr||tkr|d krtj|jj}td|d}qyt |dj}t jj|jj|}t jj|}~q5|d kr*tj|j}t j |dj}t jj|}~q5t t |dtd|j}tj|j|}tj|}~n|tkr|d kr||d}t jj|j|}q5t |d}|j} | dkrd} n| |kr?tj |tdd}tj|||}tj||}~q5| ||fkrtgt|} td d d| | value(RoRi(R5R`RM((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmasked_greaterscCstt||||S(s:masked_greater_equal(x, value) = x masked where x >= value(RoR (R5R`RM((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmasked_greater_equalscCstt||||S(s0masked_less(x, value) = x masked where x < value(RoRj(R5R`RM((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt masked_lessscCstt||||S(s7masked_less_equal(x, value) = x masked where x <= value(RoRq(R5R`RM((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmasked_less_equalscCsLt|d}tj||}t|t|}t|d|d|S(s6masked_not_equal(x, value) = x masked where x != valueiRRM(RPR1RR[RCRN(R5R`RMRRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmasked_not_equalscCsLt|d}tj||}t|t|}t|d|d|S(s{masked_equal(x, value) = x masked where x == value For floating point consider masked_values(x, value) instead. iRRM(RPR1RR[RCRN(R5R`RMRRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt masked_equalscCs||kr!|}|}|}nt|d}tjtj||tj||}t|t|}t|d|d|S(sjx with mask of all values of x that are inside [v1,v2] v1 and v2 can be given in either order. iRRM(RPR1RRqR R[RCRN(R5tv1tv2RMRRRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt masked_insides  *cCs||kr!|}|}|}nt|d}tjtj||tj||}t|t|}t|d|d|S(skx with mask of all values of x that are outside [v1,v2] v1 and v2 can be given in either order. iRRM(RPR1RXRjRiR[RCRN(R5RvRwRMRRRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytmasked_outsides  *cGsWt|}t|j|}|tkr7t|St|dtj||SdS(sCopy of a with a new shape.RN(RCRPRRBR{R7(R?RRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    cCsTt|}tjt|}|tkr7t|St|dtj|SdS(s-a as one-dimensional, may share data and maskRN(RCRRRTRPRBR{R7(R?RFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRTs    cCsg}x!|D]}|jt|q Wtj||}x.|D]}t|tk rCPqCqCWt|Sg}x!|D]}|jt|qzWtj||}t|d|S(s+Concatenate the arrays along the given axisR(tappendRPR7t concatenateRCRBR{RG(tarraysRRR5R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR{$s    cCsxt|}t|j}|tkrCtdtj|||Stdtj|||dtj|||SdS(NRR(RCR{RRBR7tswapaxes(R?taxis1taxis2RFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR}4s   cCsrt|}t|j}|tkr@ttj|||Sttj|||dtj|||SdS(s"returns selection of items from a.RN(RCR{RRBR7ttake(R?RRRRkRlRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytnew_take>s   cCsft|}t|}|tkr:ttj||Sttj||dtj||SdS(s!reorder dimensions per tuple axesRN(RCRPRBR{R7R2(R?taxesRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR2Is    cCsy|j}t|}t|}tj|||t|}|tk ru|jtj|j|dndS(snsets storage-indexed locations to corresponding values. Values and indices are filled if necessary. iN(R%RPR7R#RCRBRRA(R?RRR RlRR"R(RF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR#Ts      cCsl|tkrdStj|j||t|}|tkrEdS|jtj|j|ddS(s3putmask(a, mask, values) sets a where mask is true.Ni(RBR7R$R%RCRRA(R?RR RF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR$cs    cCsvt|d}t|d}t|jdkr?d|_nt|jdkr`d|_nttj||S(sinner(a,b) returns the dot product of two arrays, which has shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the product of the elements from the last dimensions of a and b. Masked elements are replace by zeros. ii(i(i(RPRRER{R7tinner(R?RbRTRU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRms  cCst|dj}t|dj}tj||}t|}t|}|tkrv|tkrvt|St|}t|}tdtjd|d|dd}t||S(s3outer(a,b) = {a[i]*b[j]}, has shape (len(a),len(b))iiRM( RPRTR7RRCRBR{RGRV(R?RbRTRURRRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR{s     *cCs.tt|dtjt|dddS(sdot(a,b) returns matrix-multiplication between a and b. The product-sum is over the last dimension of a and the second-to-last dimension of b. Masked values are replaced by zeros. See also innerproduct. iii(RRPR7R}(R?Rb((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRscCsgt|d}t|}|tk r?tj|||}ntj|t||}t||S(sqSelect those parts of x for which condition is true. Masked values in condition are considered false. i(RPRCRBR7R R{(RbR5t dimensionRkRRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR s   t_minimum_operationcBs8eZdZdZddZddZdZRS(sObject to calculate minimacCsdS(s`minimum(a, b) or minimum(a) In one argument case returns the scalar minimum. N((R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR scCs|dkrut|}|tkr@tt|j}|S|j}t|dkrbtSt|j Snt t ||||SdS(sExecute the call behavior.iN( RRCRBRRPRTR RRR%RRj(R R?RbRFRtac((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRks    icCst|}|tkr=t|}ttjj||Stjjt|t||}tjj||}t||t |SdS(s#Reduce target along the given axis.N( RCRBRPR{R1tminimumRR;RRa(R RRRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs   $cCst|}t|}|tkr9|tkr9t}n*t|}t|}tj||}tjjt|t|}t||S(s<Return the function applied to the outer product of a and b.( RCRBRGRXRR1RRPR{(R R?RbRRRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs     !N(RRRR RRkRR(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    t_maximum_operationcBs8eZdZdZddZddZdZRS(sObject to calculate maximacCsdS(s`maximum(a, b) or maximum(a) In one argument case returns the scalar maximum. N((R ((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR scCs|dkrut|}|tkr@tt|j}|S|j}t|dkrbtSt|j Snt t ||||SdS(sExecute the call behavior.iN( RRCRBRRPRTR RRR%RRi(R R?RbRFRR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRks    icCst|}|tkr=t|}ttjj||Stjjt|t||}tjj||}t||t |SdS(s#Reduce target along the given axis.N( RCRBRPR{R1tmaximumRR<RRa(R RRRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs   $cCst|}t|}|tkr9|tkr9t}n*t|}t|}tj||}tjjt|t|}t||S(s<Return the function applied to the outer product of a and b.( RCRBRGRXRR1RRPR{(R R?RbRRRFR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs     !N(RRRR RRkRR(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    cCsk|dkrt|}nt||}tj||}t|tkrXt|St||ddS(sIf x does not have a mask, return a masked array formed from the result of numeric.sort(x, axis). Otherwise, fill x with fill_value. Sort it. Set a mask where the result is equal to fill_value. Note that this may have unintended consequences if the data contains the fill value at a non-masked site. If fill_value is not given the default fill value for x's type will be used. RMiN( RR6RPRRtsortRCRBR{RF(R5RR@RR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs  cCsftjt||||}t|}|tkrCt||St|tj||||SdS(s9diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of aN(RRtdiagonalRPRCRBR{(R?tkR~RRRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs    cCst||||jd|S(s~trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals (defined by the last two dimenions) of the array. R/(RR(R?toffsetR~RR/Rk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyttracescCst||}tj||S(sTreating masked values as if they have the value fill_value, return sort indices for sorting along given axis. if fill_value is None, use get_fill_value(x) Returns a numpy array. (RPRRtargsort(R5RRkR@R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR!scCst||}tj||S(sTreating masked values as if they have the value fill_value, return indices for minimum values along given axis. if fill_value is None, use get_fill_value(x). Returns a numpy array if x has more than one dimension. Otherwise, returns a scalar index. (RPRRtargmin(R5RRkR@R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR*scCsO|dkr0t|}y | }Wq0q0Xnt||}tj||S(s&Treating masked values as if they have the value fill_value, return sort indices for maximum along given axis. if fill_value is None, use -get_fill_value(x) if it exists. Returns a numpy array if x has more than one dimension. Otherwise, returns a scalar index. N(RR6RPRRtargmax(R5RRkR@R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyR4s   cCsttj||S(s)apply f to s to create array as in umath.(R{R7t fromfunction(RtR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRDscCsDt|tr.|dks*||jkr.|St|d|ddS(s6asarray(data, dtype) = array(data, dtype, copy=0) R/RMiN(RR.RR/RN(RR/((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRHs(t MethodTypecCst|dtS(N(RRRN(Rt((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_mTscOs tddS(Ns'not yet implemented for numpy.ma arrays(tNotImplementedError(R tkwds((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytnot_implementedVscOs t||S(N(R(R R R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_choose`sc CsUtd|jjt|jt|jdt|jtt|t|S(NRR(R.RtclipRR[RRC(R ta_minta_maxRk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_clipes cCst|||S(N(R (R tcondRRk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _compresslscCsX|j}|tk r0tjj|j|}ntd|jdj||d|S(NRiR(RRBR1RXRR.RPtcumprod(R RR/RkRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_cumprodts  cCsX|j}|tk r0tjj|j|}ntd|jdj||d|S(NRiR(RRBR1RXRR.RPtcumsum(R RR/RkRF((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_cumsum{s  cCsE|dk rtdn|dkr1t|Stj||SdS(Ns+Output arrays Unsupported for masked arrays(RR:RR(R?RRk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_maxs    cCsE|dk rtdn|dkr1t|Stj||SdS(Ns+Output arrays Unsupported for masked arrays(RR:RR(R?RRk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_mins    cCs|j|||j|S(N(tmaxtmin(R?RRk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_ptpscCsRy+td|jjd|jj}Wn tk rMt|d}nX|S(NRRtsqueeze(R.RRRRJt_wrapit(R RU((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_squeezes  cCs1td|jj||d|jj||S(NRR(R.RR}R(R R~R((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt _swapaxesscCs|dkr%tj|jjS|j|d}||jdd}||9}||jdd:}|jd|j|S(NiR( RR7RR tvarR}tmeanRR(R RR/RkR?((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_vars  cCs|j||dS(Ng?(R(R RR/Rk((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt_stdsRcCst|||S(N(RP(R?RMR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRLscCst||||S(N(Ra(R?RR\R]((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pytaveragescCst|||S(N(R(R?RRR((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyRs(RR$R8tnumpy.core.umathtcoreR1tnumpy.core.fromnumericRRtnumpy.core.numericRRRRRtnumpy.core.numerictypesRRR7RRxRyRIRBRt ExceptionRRRR&R-R+R)R3R6R;R<R>RCRGRLRVRDR[RRPRaReRfRlRoRrRsR~RRRtlogtlog10texpt conjugatetsinRnttantarcsintarccostarctantarcsinhtarccoshtarctanhtsinhtcoshttanhR2tfabsRRtround_taroundtfloortceilt logical_notRRRRRRRRtfmodthypottarctan2RRRqR RjRiRR=RXRSt logical_xorRRRRRERRR.RNR=tisarraytisMAR@RARFRDRt arrayrangeRJRRRRPRQRRRRWRRRR{RRWRaRRRoRpRqRrRsRtRuRxRyRRTR{R}RR2R#R$RRRRRR RRRRRRRRRRRRRRRtallRR:tbasetbyteswapRRRRtconjRMRRRRtdumptdumpsRuR^tflattentgetfieldRRRRRtnbytest newbyteordertprodRtptpRLt searchsortedtsetfieldtsetflagsRRtstridesRRttofileRRRtstdtviewtroundRRR(((s7/usr/lib/python2.7/site-packages/numpy/oldnumeric/ma.pyt s                 #E&             }           k              / /