ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ ]c @`sFdZddlmZmZmZddlZddlZddlZddl j Z ddlm Z m Z ddl m Z ddlmZddlmZddlmZejdd krdd lmZnej jjZd d d dddddddddg ZdZdZdZdZedZdddZ!dZ"dZ#de$dZ%e$ed Z&dd!Z'd"eeed#Z(e$ed$Z)e$ed%Z*d&Z+d'Z,dd"e$ed(Z-dd)Z.de$eed*Z/de$ed+Z0d,d-d.de$ed/Z1d,d-d.dd0Z2dS(1s Collection of utilities to manipulate structured arrays. Most of these functions were initially implemented by John Hunter for matplotlib. They have been rewritten and extended for convenience. i(tdivisiontabsolute_importtprint_functionN(tndarraytrecarray(t MaskedArray(t MaskedRecords(t_is_string_like(t basestringi(tzipt append_fieldst drop_fieldstfind_duplicatestget_fieldstructuretjoin_byt merge_arraystrec_append_fieldstrec_drop_fieldstrec_jointrecursive_fill_fieldst rename_fieldst stack_arrayscC`sz|j}xj|jD]_}y||}Wntk r=qnX|jjr^t|||q|||t|*qW|S(sl Fills fields from output with fields from input, with support for nested structures. Parameters ---------- input : ndarray Input array. output : ndarray Output array. Notes ----- * `output` should be at least the same size as `input` Examples -------- >>> from numpy.lib import recfunctions as rfn >>> a = np.array([(1, 10.), (2, 20.)], dtype=[('A', int), ('B', float)]) >>> b = np.zeros((3,), dtype=a.dtype) >>> rfn.recursive_fill_fields(a, b) array([(1, 10.0), (2, 20.0), (0, 0.0)], dtype=[('A', '>> from numpy.lib import recfunctions as rfn >>> rfn.get_names(np.empty((1,), dtype=int)) is None True >>> rfn.get_names(np.empty((1,), dtype=[('A',int), ('B', float)])) ('A', 'B') >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])]) >>> rfn.get_names(adtype) ('a', ('b', ('ba', 'bb'))) N(Rtappendttuplet get_namestNone(tadtypet listnamesRtnameR((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR!Is    "cC`sfg}|j}xD|D]<}|j|||}|jr|jt|qqWt|pedS(s2 Returns the field names of the input datatype as a tuple. Nested structure are flattend beforehand. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy.lib import recfunctions as rfn >>> rfn.get_names_flat(np.empty((1,), dtype=int)) is None True >>> rfn.get_names_flat(np.empty((1,), dtype=[('A',int), ('B', float)])) ('A', 'B') >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])]) >>> rfn.get_names_flat(adtype) ('a', 'b', 'ba', 'bb') N(RRtextendtget_names_flatR R"(R#R$RR%R((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR'hs     cC`s|j}|dkr|jSg}xS|D]K}|j|\}}|jra|jt|q)|j||fq)Wt|SdS(sD Flatten a structured data-type description. Examples -------- >>> from numpy.lib import recfunctions as rfn >>> ndtype = np.dtype([('a', '>> rfn.flatten_descr(ndtype) (('a', dtype('int32')), ('ba', dtype('float64')), ('bb', dtype('int32'))) N(RR"tdescrtfieldsR&t flatten_descrRR (tndtypeRR(Rttypt_((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR*s    cC`sg}|r6x|D]}|jt|jqWndxa|D]Y}|j}|jpXd}t|dkr|jd|jfq=|j|jq=Wtj|jS(s Combine the dtype description of a series of arrays. Parameters ---------- seqarrays : sequence of arrays Sequence of arrays flatten : {boolean}, optional Whether to collapse nested descriptions. it((R&R*RRRRR(tnp(t seqarraystflattenRtaRR((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyt zip_descrs    cC`s|dkri}n|j}x|D]}||}|jrz|rT|g||>> from numpy.lib import recfunctions as rfn >>> ndtype = np.dtype([('A', int), ... ('B', [('BA', int), ... ('BB', [('BBA', int), ('BBB', int)])])]) >>> rfn.get_fieldstructure(ndtype) ... # XXX: possible regression, order of BBA and BBB is swapped {'A': [], 'B': [], 'BA': ['B'], 'BB': ['B'], 'BBA': ['B', 'BB'], 'BBB': ['B', 'BB']} N(R"RtupdateR tgetR(R#tlastnametparentsRR%RR-t lastparent((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR s"       + cc`sQxJ|D]B}t|tjrDx'tt|D] }|Vq2Wq|VqWdS(su Returns an iterator of concatenated fields from a sequence of arrays, collapsing any nested structure. N(t isinstanceR/tvoidt_izip_fields_flatR (titerabletelementtf((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR;s   cc`sx|D]}t|drKt|t rKxjt|D] }|Vq9Wqt|tjrtt|dkrx!t|D] }|VqWq|VqWdS(sP Returns an iterator of concatenated fields from a sequence of arrays. t__iter__iN(thasattrR9Rt _izip_fieldsR/R:RR (R<R=R>((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyRAs  * cc`so|rt}nt}tjddkr4tj}n tj}x+|d||D]}t||VqPWdS(s* Returns an iterator of concatenated items from a sequence of arrays. Parameters ---------- seqarrays : sequence of arrays Sequence of arrays. fill_value : {None, integer} Value used to pad shorter iterables. flatten : {True, False}, Whether to iit fillvalueN(R;RAtsyst version_infot itertoolst zip_longestt izip_longestR (R0t fill_valueR1tzipfuncRFttup((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyt izip_records s   cC`sdt|tst}n|r9|r`|jt}q`n'tj|}|r`|jt}n|S(s Private function: return a recarray, a ndarray, a MaskedArray or a MaskedRecords depending on the input parameters (R9RtFalsetviewRtmatfilledR(Rtusemaskt asrecarray((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyt _fix_output&s cC`s{|jj}|j|j|j}}}xK|p5ijD]7\}}||kr<|||<|||||>> from numpy.lib import recfunctions as rfn >>> rfn.merge_arrays((np.array([1, 2]), np.array([10., 20., 30.]))) masked_array(data = [(1, 10.0) (2, 20.0) (--, 30.0)], mask = [(False, False) (False, False) (True, False)], fill_value = (999999, 1e+20), dtype = [('f0', '>> rfn.merge_arrays((np.array([1, 2]), np.array([10., 20., 30.])), ... usemask=False) array([(1, 10.0), (2, 20.0), (-1, 30.0)], dtype=[('f0', '>> rfn.merge_arrays((np.array([1, 2]).view([('a', int)]), ... np.array([10., 20., 30.])), ... usemask=False, asrecarray=True) rec.array([(1, 10.0), (2, 20.0), (-1, 30.0)], dtype=[('a', 'stndmintcountRT(iN(!RR/t asanyarrayR9RR:RR3tTrueR(travelRRRRRMR tmaxR t __array__RNt getmaskarrayt_check_fill_valuetitemtarraytonesR"RREtchainRKtfromitertlist(R0RHR1RPRQtseqdtypetseqtypet_mtsizest maxlengthRtseqdatatseqmaskR2tnt nbmissingRSRTtfvaltfmskR((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyREs|1       "    $! $$c`st|r|g}n t|}fd|j|}|sOdStj|jd|}t||}t|d|d|S(sv Return a new array with fields in `drop_names` dropped. Nested fields are supported. Parameters ---------- base : array Input array drop_names : string or sequence String or sequence of strings corresponding to the names of the fields to drop. usemask : {False, True}, optional Whether to return a masked array or not. asrecarray : string or sequence, optional Whether to return a recarray or a mrecarray (`asrecarray=True`) or a plain ndarray or masked array with flexible dtype. The default is False. Examples -------- >>> from numpy.lib import recfunctions as rfn >>> a = np.array([(1, (2, 3.0)), (4, (5, 6.0))], ... dtype=[('a', int), ('b', [('ba', float), ('bb', int)])]) >>> rfn.drop_fields(a, 'a') array([((2.0, 3),), ((5.0, 6),)], dtype=[('b', [('ba', '>> rfn.drop_fields(a, 'ba') array([(1, (3,)), (4, (6,))], dtype=[('a', '>> rfn.drop_fields(a, ['ba', 'bb']) array([(1,), (4,)], dtype=[('a', '>> from numpy.lib import recfunctions as rfn >>> a = np.array([(1, (2, [3.0, 30.])), (4, (5, [6.0, 60.]))], ... dtype=[('a', int),('b', [('ba', float), ('bb', (float, 2))])]) >>> rfn.rename_fields(a, {'a':'A', 'bb':'BB'}) array([(1, (2.0, [3.0, 30.0])), (4, (5.0, [6.0, 60.0]))], dtype=[('A', '>> from numpy.lib import recfunctions as rfn >>> x = np.array([1, 2,]) >>> rfn.stack_arrays(x) is x True >>> z = np.array([('A', 1), ('B', 2)], dtype=[('A', '|S3'), ('B', float)]) >>> zz = np.array([('a', 10., 100.), ('b', 20., 200.), ('c', 30., 300.)], ... dtype=[('A', '|S3'), ('B', float), ('C', float)]) >>> test = rfn.stack_arrays((z,zz)) >>> test masked_array(data = [('A', 1.0, --) ('B', 2.0, --) ('a', 10.0, 100.0) ('b', 20.0, 200.0) ('c', 30.0, 300.0)], mask = [(False, False, True) (False, False, True) (False, False, False) (False, False, False) (False, False, False)], fill_value = ('N/A', 1e+20, 1e+20), dtype = [('A', '|S3'), ('B', ' '%s'sf%iRPRQN(R9RRR/R_RaRRR(RtindexRkR t TypeErrortdictRNt concatenateRtsumtcumsumtr_R R"RRRY(tarraysRVRPRQt autoconvertR2R0tnrecordsR+Rtfldnamestdtype_ltnewdescrR-Rtdtype_nR(R%tnameidxt current_descrRtoffsettseenRstitj((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyRsT'(     & )0    c C`s tj|j}t|j}|}|r\x||D]}||}q;W||}n|j}||}|j} | d | dk} |r|j} t| | d>> from numpy.lib import recfunctions as rfn >>> ndtype = [('a', int)] >>> a = np.ma.array([1, 1, 1, 2, 2, 3, 3], ... mask=[0, 0, 1, 0, 0, 0, 1]).view(ndtype) >>> rfn.find_duplicates(a, ignoremask=True, return_index=True) ... # XXX: judging by the output, the ignoremask flag has no effect iiN( R/R_RaR RtargsortROt recordmaskRLR( R2tkeyt ignoremaskt return_indexR)R|R>tsortidxt sortedbaset sorteddatatflagt sortedmaskt duplicates((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyR s(     tinnert1t2c +`sN|dkrtd|nttr:fntttkrtfdtD} td| nxXD]P} | |jjkrtd| n| |jjkrtd| qqW|j }|j }t|} |jj|jj} } tj t| t| j rx|pU| rxd }|d 7}t|ng| D]}|kr|^q}t ||}t ||}t j||f}|jd }||}t jtg|d |d kf}|d |d |d *||}||| k}||| k| }t|t|}}|dkrd\}}n|dkr||}tj|||| kf}tj|||| k| f}t||t||}}nP|dkrW||}tj|||| kf}t||d}}n||||}}g|jjD]} t| ^qy}!|!jfd|jjDtd|!D}"x|jjD]}#t|#}#|#d} | |"kry|!j|#}$|!|$}%| krBt|#d |%d |%d ssduplicate join key %rsr1 does not have key field %rsr2 does not have key field %rs8r1 and r2 contain common names, r1postfix and r2postfix scan't be emptytorderiiic3`s+|]!}|dkrt|VqdS(iN(Rk(R\R-(R(sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pys scs`s|]}|dVqdS(iN((R\R-((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pys sRRPRQ(RRR(ii(RR(RR9RRRytnextt enumerateRRRat intersectiont differenceR~RNRRRLR/R(RkR&RRbtinsertRR RtsortRRRRY(+Rtr1tr2tjointypet r1postfixt r2postfixRVRPRQtdupR%tnb1tr1namestr2namesRRstkey1tr1ktr2ktauxtidx_sorttflag_intidx_intidx_1tidx_2tr1cmntr2cmntr1spctr2spctidx_outts1ts2R-R+RtdescRRtcmnRR>tselectedtkwargs((RsI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyRLs3   "    '  % &    #$  %#         +     +  c C`s@td|d|d|d|dtdt}t||||S(s Join arrays `r1` and `r2` on keys. Alternative to join_by, that always returns a np.recarray. See Also -------- join_by : equivalent function RRRRVRPRQ(RRLR`R(RRRRRRRVR((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pyRs (3t__doc__t __future__RRRRCREtnumpyR/tnumpy.maRNRRRtnumpy.ma.mrecordsRtnumpy.lib._iotoolsRt numpy.compatRRDtfuture_builtinsR tcoreRet__all__RR!R'R*RLR3R"R R;RAR`RKRRRYRR R~RRR RRR RR(((sI/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/recfunctions.pytsX       '    /   @  'D "  Y6