ÿØÿà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@`sddlmZmZmZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddlZddlmZddlmZddlmZmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"dd l#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ej+dd kr^ddl,Z,nddl-Z,dd l.m/Z/e,j0Z0d d ddddddddddddddgZ1de2fdYZ3dZ4de2fd YZ5e6e7e7d!d"Z8e7e7d#Z9d$Z:d%Z;e7e6d&Z<d'Z=e>d(e6e6de6e?dd)Z@d*d+d,d-d-d.d/ZAd0ZBe>d(e6dde6e6e6e6e6e6e6d1e?e7d2e6e?e7e7e6d3ZCd4ZDd5ZEd6ZFd7ZGdS(8i(tdivisiontabsolute_importtprint_functionN(t itemgettertindexi(tformat(t DataSource(tpackbitst unpackbits( t LineSplittert NameValidatortStringConvertertConverterErrortConverterLockErrortConversionWarningt_is_string_likethas_nested_fieldst flatten_dtypet easy_dtypet_bytes_to_name(tasbytestasstrtasbytes_nestedtbytest basestringtunicodetis_pathlib_pathi(tmaptsavetxttloadtxtt genfromtxtt ndfromtxtt mafromtxtt recfromtxtt recfromcsvtloadtloadstsavetsaveztsavez_compressedRRt fromregexRtBagObjcB`s)eZdZdZdZdZRS(su BagObj(obj) Convert attribute look-ups to getitems on the object passed in. Parameters ---------- obj : class instance Object on which attribute look-up is performed. Examples -------- >>> from numpy.lib.npyio import BagObj as BO >>> class BagDemo(object): ... def __getitem__(self, key): # An instance of BagObj(BagDemo) ... # will call this method when any ... # attribute look-up is required ... result = "Doesn't matter what you want, " ... return result + "you're gonna get this" ... >>> demo_obj = BagDemo() >>> bagobj = BO(demo_obj) >>> bagobj.hello_there "Doesn't matter what you want, you're gonna get this" >>> bagobj.I_can_be_anything "Doesn't matter what you want, you're gonna get this" cC`stj||_dS(N(tweakreftproxyt_obj(tselftobj((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt__init__FscC`s<ytj|d|SWntk r7t|nXdS(NR,(tobjectt__getattribute__tKeyErrortAttributeError(R-tkey((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR1Js cC`stj|djS(s Enables dir(bagobj) to list the files in an NpzFile. This also enables tab-completion in an interpreter or IPython. R,(R0R1tkeys(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt__dir__Ps(t__name__t __module__t__doc__R/R1R6(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR)(s  cO`sDt|rt|}nddl}t|d<|j|||S(s Create a ZipFile. Allows for Zip64, and the `file` argument can accept file, str, or pathlib.Path objects. `args` and `kwargs` are passed to the zipfile.ZipFile constructor. iNt allowZip64(RtstrtzipfiletTruetZipFile(tfiletargstkwargsR<((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pytzipfile_factoryYs    tNpzFilecB`seZdZeed dZdZdZdZ dZ dZ dZ dZ d Zd Zd Zd ZRS(s NpzFile(fid) A dictionary-like object with lazy-loading of files in the zipped archive provided on construction. `NpzFile` is used to load files in the NumPy ``.npz`` data archive format. It assumes that files in the archive have a ``.npy`` extension, other files are ignored. The arrays and file strings are lazily loaded on either getitem access using ``obj['key']`` or attribute lookup using ``obj.f.key``. A list of all files (without ``.npy`` extensions) can be obtained with ``obj.files`` and the ZipFile object itself using ``obj.zip``. Attributes ---------- files : list of str List of all files in the archive with a ``.npy`` extension. zip : ZipFile instance The ZipFile object initialized with the zipped archive. f : BagObj instance An object on which attribute can be performed as an alternative to getitem access on the `NpzFile` instance itself. allow_pickle : bool, optional Allow loading pickled data. Default: True pickle_kwargs : dict, optional Additional keyword arguments to pass on to pickle.load. These are only useful when loading object arrays saved on Python 2 when using Python 3. Parameters ---------- fid : file or str The zipped archive to open. This is either a file-like object or a string containing the path to the archive. own_fid : bool, optional Whether NpzFile should close the file handle. Requires that `fid` is a file-like object. Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> y = np.sin(x) >>> np.savez(outfile, x=x, y=y) >>> outfile.seek(0) >>> npz = np.load(outfile) >>> isinstance(npz, np.lib.io.NpzFile) True >>> npz.files ['y', 'x'] >>> npz['x'] # getitem access array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> npz.f.x # attribute lookup array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) cC`st|}|j|_g|_||_||_xG|jD]<}|jdrl|jj|d q@|jj|q@W||_t ||_ |r||_ n d|_ dS(Ns.npyi( RBtnamelistt_filestfilest allow_picklet pickle_kwargstendswithtappendtzipR)tftfidtNone(R-RMtown_fidRGRHt_ziptx((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR/s      cC`s|S(N((R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt __enter__scC`s|jdS(N(tclose(R-texc_typet exc_valuet traceback((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt__exit__scC`s]|jdk r(|jjd|_n|jdk rP|jjd|_nd|_dS(s" Close the file. N(RKRNRSRMRL(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRSs    cC`s|jdS(N(RS(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt__del__scC`sd}||jkrd}n"||jkr@d}|d7}n|r|jj|}|jttj}|j|tjkr|jj|}tj |d|j d|j S|jj|Snt d|dS(Niis.npyRGRHs%s is not a file in the archive( RERFRKtopentreadtlenRt MAGIC_PREFIXRSt read_arrayRGRHR2(R-R4tmemberRtmagic((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt __getitem__s"       cC`s t|jS(N(titerRF(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt__iter__scC`s$g|jD]}|||f^q S(sV Return a list of tuples, with each tuple (filename, array in file). (RF(R-RL((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pytitemsscc`s'x |jD]}|||fVq WdS(s8Generator that returns tuples (filename, array in file).N(RF(R-RL((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt iteritemsscC`s|jS(s6Return files in the archive with a ``.npy`` extension.(RF(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR5scC`s |jS(s1Return an iterator over the files in the archive.(Rb(R-((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pytiterkeysscC`s|jj|S(N(RFt __contains__(R-R4((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRfsN(R7R8R9tFalseR=RNR/RRRWRSRXR`RbRcRdR5ReRf(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRChs=          tASCIIc C`st}t|tr-t|d}t}n*t|rQ|jd}t}n|}|dkrrtdntjddkrt d|d |}ni}z d }t t j } |j | } |jt| t |  d | j|r!|} t}t|d | d |d|S| t j kre|rIt j|d|St j|d |d|SnI|sztdnytj||SWntdt|nXWd|r|jnXdS(s Load arrays or pickled objects from ``.npy``, ``.npz`` or pickled files. Parameters ---------- file : file-like object, string, or pathlib.Path The file to read. File-like objects must support the ``seek()`` and ``read()`` methods. Pickled files require that the file-like object support the ``readline()`` method as well. mmap_mode : {None, 'r+', 'r', 'w+', 'c'}, optional If not None, then memory-map the file, using the given mode (see `numpy.memmap` for a detailed description of the modes). A memory-mapped array is kept on disk. However, it can be accessed and sliced like any ndarray. Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory. allow_pickle : bool, optional Allow loading pickled object arrays stored in npy files. Reasons for disallowing pickles include security, as loading pickled data can execute arbitrary code. If pickles are disallowed, loading object arrays will fail. Default: True fix_imports : bool, optional Only useful when loading Python 2 generated pickled files on Python 3, which includes npy/npz files containing object arrays. If `fix_imports` is True, pickle will try to map the old Python 2 names to the new names used in Python 3. encoding : str, optional What encoding to use when reading Python 2 strings. Only useful when loading Python 2 generated pickled files on Python 3, which includes npy/npz files containing object arrays. Values other than 'latin1', 'ASCII', and 'bytes' are not allowed, as they can corrupt numerical data. Default: 'ASCII' Returns ------- result : array, tuple, dict, etc. Data stored in the file. For ``.npz`` files, the returned instance of NpzFile class must be closed to avoid leaking file descriptors. Raises ------ IOError If the input file does not exist or cannot be read. ValueError The file contains an object array, but allow_pickle=False given. See Also -------- save, savez, savez_compressed, loadtxt memmap : Create a memory-map to an array stored in a file on disk. lib.format.open_memmap : Create or load a memory-mapped ``.npy`` file. Notes ----- - If the file contains pickle data, then whatever object is stored in the pickle is returned. - If the file is a ``.npy`` file, then a single array is returned. - If the file is a ``.npz`` file, then a dictionary-like object is returned, containing ``{filename: array}`` key-value pairs, one for each file in the archive. - If the file is a ``.npz`` file, the returned value supports the context manager protocol in a similar fashion to the open function:: with load('foo.npz') as data: a = data['a'] The underlying file descriptor is closed when exiting the 'with' block. Examples -------- Store data to disk, and load it again: >>> np.save('/tmp/123', np.array([[1, 2, 3], [4, 5, 6]])) >>> np.load('/tmp/123.npy') array([[1, 2, 3], [4, 5, 6]]) Store compressed data to disk, and load it again: >>> a=np.array([[1, 2, 3], [4, 5, 6]]) >>> b=np.array([1, 2]) >>> np.savez('/tmp/123.npz', a=a, b=b) >>> data = np.load('/tmp/123.npz') >>> data['a'] array([[1, 2, 3], [4, 5, 6]]) >>> data['b'] array([1, 2]) >>> data.close() Mem-map the stored array, and then access the second row directly from disk: >>> X = np.load('/tmp/123.npy', mmap_mode='r') >>> X[1, :] memmap([4, 5, 6]) trbRhtlatin1Rs.encoding must be 'ASCII', 'latin1', or 'bytes'iitencodingt fix_importssPKiRORGRHtmodes>allow_pickle=False, but file does not contain non-pickled datas'Failed to interpret file %s as a pickleN(RhRjR(Rgt isinstanceRRYR=Rt ValueErrortsyst version_infotdictR[RR\RZtseektmint startswithRCt open_memmapR]tpickleR#tIOErrortreprRS( R?t mmap_modeRGRlRkRORMRHt _ZIP_PREFIXtNR_ttmp((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR# sJf      cC`st}t|trI|jds1|d}nt|d}t}nSt|r|jjds~|j|jd}n|jd}t}n|}t j ddkrt d|}nd}z/t j|}tj||d|d|Wd|r |jnXdS( s` Save an array to a binary file in NumPy ``.npy`` format. Parameters ---------- file : file, str, or pathlib.Path File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string or Path, a ``.npy`` extension will be appended to the file name if it does not already have one. allow_pickle : bool, optional Allow saving object arrays using Python pickles. Reasons for disallowing pickles include security (loading pickled data can execute arbitrary code) and portability (pickled objects may not be loadable on different Python installations, for example if the stored objects require libraries that are not available, and not all pickled data is compatible between Python 2 and Python 3). Default: True fix_imports : bool, optional Only useful in forcing objects in object arrays on Python 3 to be pickled in a Python 2 compatible way. If `fix_imports` is True, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. arr : array_like Array data to be saved. See Also -------- savez : Save several arrays into a ``.npz`` archive savetxt, load Notes ----- For a description of the ``.npy`` format, see the module docstring of `numpy.lib.format` or the NumPy Enhancement Proposal http://docs.scipy.org/doc/numpy/neps/npy-format.html Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> np.save(outfile, x) >>> outfile.seek(0) # Only needed here to simulate closing & reopening file >>> np.load(outfile) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) s.npytwbiiRlRGRHN(RgRnRRIRYR=RtnametparentRpRqRrRNtnpt asanyarrayRt write_arrayRS(R?tarrRGRlRORMRH((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR%s*3     cO`st|||tdS(s Save several arrays into a single file in uncompressed ``.npz`` format. If arguments are passed in with no keywords, the corresponding variable names, in the ``.npz`` file, are 'arr_0', 'arr_1', etc. If keyword arguments are given, the corresponding variable names, in the ``.npz`` file will match the keyword names. Parameters ---------- file : str or file Either the file name (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the ``.npz`` extension will be appended to the file name if it is not already there. args : Arguments, optional Arrays to save to the file. Since it is not possible for Python to know the names of the arrays outside `savez`, the arrays will be saved with names "arr_0", "arr_1", and so on. These arguments can be any expression. kwds : Keyword arguments, optional Arrays to save to the file. Arrays will be saved in the file with the keyword names. Returns ------- None See Also -------- save : Save a single array to a binary file in NumPy format. savetxt : Save an array to a file as plain text. savez_compressed : Save several arrays into a compressed ``.npz`` archive Notes ----- The ``.npz`` file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in ``.npy`` format. For a description of the ``.npy`` format, see `numpy.lib.format` or the NumPy Enhancement Proposal http://docs.scipy.org/doc/numpy/neps/npy-format.html When opening the saved ``.npz`` file with `load` a `NpzFile` object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the ``.files`` attribute), and for the arrays themselves. Examples -------- >>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> y = np.sin(x) Using `savez` with \*args, the arrays are saved with default names. >>> np.savez(outfile, x, y) >>> outfile.seek(0) # Only needed here to simulate closing & reopening file >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_1', 'arr_0'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Using `savez` with \**kwds, the arrays are saved with the keyword names. >>> outfile = TemporaryFile() >>> np.savez(outfile, x=x, y=y) >>> outfile.seek(0) >>> npzfile = np.load(outfile) >>> npzfile.files ['y', 'x'] >>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) N(t_savezRg(R?R@tkwds((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR&sNcO`st|||tdS(s Save several arrays into a single file in compressed ``.npz`` format. If keyword arguments are given, then filenames are taken from the keywords. If arguments are passed in with no keywords, then stored file names are arr_0, arr_1, etc. Parameters ---------- file : str or file Either the file name (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the ``.npz`` extension will be appended to the file name if it is not already there. args : Arguments, optional Arrays to save to the file. Since it is not possible for Python to know the names of the arrays outside `savez`, the arrays will be saved with names "arr_0", "arr_1", and so on. These arguments can be any expression. kwds : Keyword arguments, optional Arrays to save to the file. Arrays will be saved in the file with the keyword names. Returns ------- None See Also -------- numpy.save : Save a single array to a binary file in NumPy format. numpy.savetxt : Save an array to a file as plain text. numpy.savez : Save several arrays into an uncompressed ``.npz`` file format numpy.load : Load the files created by savez_compressed. Notes ----- The ``.npz`` file format is a zipped archive of files named after the variables they contain. The archive is compressed with ``zipfile.ZIP_DEFLATED`` and each file in the archive contains one variable in ``.npy`` format. For a description of the ``.npy`` format, see `numpy.lib.format` or the NumPy Enhancement Proposal http://docs.scipy.org/doc/numpy/neps/npy-format.html When opening the saved ``.npz`` file with `load` a `NpzFile` object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the ``.files`` attribute), and for the arrays themselves. Examples -------- >>> test_array = np.random.rand(3, 2) >>> test_vector = np.random.rand(4) >>> np.savez_compressed('/tmp/123', a=test_array, b=test_vector) >>> loaded = np.load('/tmp/123.npz') >>> print(np.array_equal(test_array, loaded['a'])) True >>> print(np.array_equal(test_vector, loaded['b'])) True N(RR=(R?R@R((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR'Ts=cC`sTddl}ddl}t|trF|jds~|d}q~n8t|r~|jjds~|j|jd}q~n|}xSt|D]E\} } d| } | |j krt d| n| || tcS`stt|S(N(RR(RQ((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRRcS`stt|S(N(tcomplexR(RQ((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRRN( ttypet issubclassRtbool_tuint64tint64tintegert longdoubletfloatingRtbytes_RR(tdtypeRttyp((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt_getconvs&  t#c #`s.dk r}tttfr3tgngD]} t| ^q:dDtjdjn|} dk rtn|dk r.yt|} Wnt k r|g} nXxK| D]C} yt | Wqt k r } dt | f| _ qXqW| }nt }yt|rRt|}nt|r t}|jdrddl}t|j|}q|jdrddl}t|j|}qtjddkrtt|d }qtt|}n t|}Wnt k r6td nXg}fd fd fd }ztj|}t|}xt|D]}t |qWd}y)x"|st |}||}qWWn4t!k rd}g}t"j#d|ddnXt$|p!|}|\}}t$|dkrmg|D]}t|^qR}n=gt|D] }|^qz}|dkr|t%fg}nx]| pij&D]I\}}|ry|j'|}Wqtk rqqXn|||>> from io import StringIO # StringIO behaves like a file object >>> c = StringIO("0 1\n2 3") >>> np.loadtxt(c) array([[ 0., 1.], [ 2., 3.]]) >>> d = StringIO("M 21 72\nF 35 58") >>> np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'), ... 'formats': ('S1', 'i4', 'f4')}) array([('M', 21, 72.0), ('F', 35, 58.0)], dtype=[('gender', '|S1'), ('age', '>> c = StringIO("1,0,2\n3,0,4") >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True) >>> x array([ 1., 3.]) >>> y array([ 2., 4.]) cs`s|]}tj|VqdS(N(tretescape(t.0tcomment((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pys Zst|s\usecols must be an int or a sequence of ints but it contains at least one element of type %ss.gziNs.bz2itUs1fname must be a string, file handle, or generatorc `sc|jdkr|j}t|dkr:|jgdfS|dtfg}t|dkrx@|jdddD]%}||dd||fg}qvWn|jgttj|j|fSng}g}x{|jD]p}|j |\}}|\}} |j ||j dkr8|j | q|j t|| fqW||fSdS(s;Unpack a structured data-type, and produce re-packing info.iiiiN( tnamesRNtshapeR[tbasetlistRRtprodtfieldstextendtndimRJ( tdtRtpackingtdimttypestfieldttpRtflat_dtt flat_packing(tflatten_dtype_internal(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRs& &) c`s|dkr|dS|tkr*t|S|tkr@t|Sd}g}x?|D]7\}}|j||||!|||7}qSWt|SdS(s6Pack items into nested lists based on re-packing info.iN(RNttupleRRJ(RcRtstarttrettlengtht subpacking(t pack_items(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRs     !c`sdt|}dk r:jt|ddd}n|jd}|r\|jSgSdS(sChop off comments, strip, and split at delimiter. Note that although the file is opened as text, this function returns bytes. tmaxsplitiis N(RRNRtstrip(tline(tcommentst delimitertregex_comments(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyt split_lines  " Rsloadtxt: Empty input file: "%s"t stacklevelis"Wrong number of columns at line %diis"Illegal value of ndmin keyword: %s(ii(ii(iii(6RNRnRRRRtcompiletjoinRt TypeErrortopindexRR@RgRR;RR=RItgzipRatGzipFiletbz2tBZ2FileRpRqRYRoRRRtrangetnextt StopIterationtwarningstwarnR[RRcRRt itertoolstchainRKRJRStarrayRRtsqueezet atleast_1dt atleast_2dtTR(#RRRRt converterstskiprowstusecolstunpacktndminRtuser_converterstusecols_as_listtcol_idxtetfownRtfhRtXRtdefconvRt first_valst first_lineR|t dtype_typesRRtconvRtvalstline_numRRcR((RRRRRsB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRsg                 "   (   ."     s%.18et s Rs# cC`st|trt|}nt|}t}t|rKt|}nt|rt}|jdrddl } | j |d} qt j ddkrt |d} qt |d} n$t |dr|} n tdztj|}|jd krK|jjdkr6tj|j}d } qXt|jj} n |jd } tj|} t|ttfkrt|| krtd t|nt|jt t|} nt|tr|j!d }td |}|d krD| r%d ||fg| }n |g| }|j|} q| rc|d| krc|q| r|| kr|q|} ntd|ft|dkr|j"dd|}| j#t$|||n| rSx|D]^}g}x.|D]&}|j%|j&|j%|j'qW| j#t$| t||qWnixf|D]^}y%| j#t$| t||WqZt(k rt(dt|j| fqZXqZWt|dkr|j"dd|}| j#t$|||nWd|r| j)nXdS(s Save an array to a text file. Parameters ---------- fname : filename or file handle If the filename ends in ``.gz``, the file is automatically saved in compressed gzip format. `loadtxt` understands gzipped files transparently. X : array_like Data to be saved to a text file. fmt : str or sequence of strs, optional A single format (%10.5f), a sequence of formats, or a multi-format string, e.g. 'Iteration %d -- %10.5f', in which case `delimiter` is ignored. For complex `X`, the legal options for `fmt` are: a) a single specifier, `fmt='%.4e'`, resulting in numbers formatted like `' (%s+%sj)' % (fmt, fmt)` b) a full string specifying every real and imaginary part, e.g. `' %.4e %+.4ej %.4e %+.4ej %.4e %+.4ej'` for 3 columns c) a list of specifiers, one per column - in this case, the real and imaginary part must have separate specifiers, e.g. `['%.3e + %.3ej', '(%.15e%+.15ej)']` for 2 columns delimiter : str, optional String or character separating columns. newline : str, optional String or character separating lines. .. versionadded:: 1.5.0 header : str, optional String that will be written at the beginning of the file. .. versionadded:: 1.7.0 footer : str, optional String that will be written at the end of the file. .. versionadded:: 1.7.0 comments : str, optional String that will be prepended to the ``header`` and ``footer`` strings, to mark them as comments. Default: '# ', as expected by e.g. ``numpy.loadtxt``. .. versionadded:: 1.7.0 See Also -------- save : Save an array to a binary file in NumPy ``.npy`` format savez : Save several arrays into an uncompressed ``.npz`` archive savez_compressed : Save several arrays into a compressed ``.npz`` archive Notes ----- Further explanation of the `fmt` parameter (``%[flag]width[.precision]specifier``): flags: ``-`` : left justify ``+`` : Forces to precede result with + or -. ``0`` : Left pad the number with zeros instead of space (see width). width: Minimum number of characters to be printed. The value is not truncated if it has more characters. precision: - For integer specifiers (eg. ``d,i,o,x``), the minimum number of digits. - For ``e, E`` and ``f`` specifiers, the number of digits to print after the decimal point. - For ``g`` and ``G``, the maximum number of significant digits. - For ``s``, the maximum number of characters. specifiers: ``c`` : character ``d`` or ``i`` : signed decimal integer ``e`` or ``E`` : scientific notation with ``e`` or ``E``. ``f`` : decimal floating point ``g,G`` : use the shorter of ``e,E`` or ``f`` ``o`` : signed octal ``s`` : string of characters ``u`` : unsigned decimal integer ``x,X`` : unsigned hexadecimal integer This explanation of ``fmt`` is not complete, for an exhaustive specification see [1]_. References ---------- .. [1] `Format Specification Mini-Language `_, Python Documentation. Examples -------- >>> x = y = z = np.arange(0.0,5.0,1.0) >>> np.savetxt('test.out', x, delimiter=',') # X is an array >>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays >>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation s.gziNR~iRRs%fname must be a string or file handleisfmt has wrong shape. %st%s'fmt has wrong number of %% formats: %ss (%s+%sj)isinvalid fmt: %rs s?Mismatch between array dtype ('%s') and format specifier ('%s')(*RnRRRgRR;RR=RIRRYRpRqthasattrRoRtasarrayRRRRNRRR[tdescrRt iscomplexobjRRRR3RRtcounttreplaceRRRJtrealtimagRRS(RRtfmtRtnewlinetheadertfooterRtown_fhRRtncolt iscomplex_XRt n_fmt_charsterrortrowtrow2tnumber((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR'ss        !       ( % !"cC`st}t|ds-t|d}t}nzt|dsWtjt|}nt|tj s{tj |}n|j |j }|rt|dt  rtj ||j d}tj|d|}||_ ntj|d|}|SWd|r|jnXdS(s Construct an array from a text file, using regular expression parsing. The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to fields of the structured array. Parameters ---------- file : str or file File name or file object to read. regexp : str or regexp Regular expression used to parse the file. Groups in the regular expression correspond to fields in the dtype. dtype : dtype or list of dtypes Dtype for the structured array. Returns ------- output : ndarray The output array, containing the part of the content of `file` that was matched by `regexp`. `output` is always a structured array. Raises ------ TypeError When `dtype` is not a valid dtype for a structured array. See Also -------- fromstring, loadtxt Notes ----- Dtypes for structured arrays can be specified in several forms, but all forms specify at least the data type and field name. For details see `doc.structured_arrays`. Examples -------- >>> f = open('test.dat', 'w') >>> f.write("1312 foo\n1534 bar\n444 qux") >>> f.close() >>> regexp = r"(\d+)\s+(...)" # match [digits, whitespace, anything] >>> output = np.fromregex('test.dat', regexp, ... [('num', np.int64), ('key', 'S3')]) >>> output array([(1312L, 'foo'), (1534L, 'bar'), (444L, 'qux')], dtype=[('num', '>> output['num'] array([1312, 1534, 444], dtype=int64) RZRitmatchiRN(RgRRYR=RRRRnRRtfindallRZRRRRS(R?tregexpRRtseqtnewdtypetoutput((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyR(s$7  t_sf%icY`s|d*k r?|r!tdn|dkr?tdq?n|d*k rZt|}nt|trxt|}nt|tttfrt|}n|rddlm }m }n|pi}t|t st dt |nt}yt|rt|}nt|trtjddkrYttjjj|d}nttjjj|d }t}n t|}Wn't k rt d t |nXtd |d |d |j}td| d| d|d| }xt|D]t|qWd*}ycx\|s~t|}| tkro||krodj|j |d}qon||}q#WWn4t!k rd}g}t"j#d|ddnX| tkr|dj$}||kr|d=qn| d*k rhy,g| j dD]} | j$^q } Wqht%k rdyt| } Wqet k r`| g} qeXqhXnt&| pt|}!| tkr|g|D]} t'| j$^q} d}nRt(| r|g| j dD]} | j$^q} n| r || } n|d*k rKt)|d|d| d| d| d|d| }n| d*k rft| } n| rnx_t*| D]Q\}"t(|"r| j+|"| }?|>j$|?k^q nt&|5|kr+ Pq+ q+ W|rh |j:n|d*krs xt*|D]\}@g|5D]}At;|A^q }By|@j<|BWq t=k rk d}Ct>t;|5}Bxwt*|BD]e\}2}(y|@j?|(Wq t@tfk rc |Cd7}C|C|2d||(f;}Ct@|Cq Xq Wq Xq Wnt&|9}D|Ddkrt&|5|D|}Ed|!}F|dkrt&g|9D] } | d|E|kr | ^q }G|9|D|G }9||G8}ng|9D]\}H|F|Hf^q }Ct&|Cr|CjAdd d!j|C}C|rlt|Cqt"j#|CtBddqn|dkr|5| }5|r|7| }7qn|rtt1gt*|D]=\}3gt>t;|5D]}I|3jC|I^q^q}5n\tt1gt*|D]=\}3gt>t;|5D]}I|3jD|I^qP^q.}5|5}J|d*kr]g|D]}3|3j ^q}Kgt*|KD]-\}>|>t d"tjEfkr^q}Lx2|LD]*d#tFfd$|JD|K`_. Examples --------- >>> from io import StringIO >>> import numpy as np Comma delimited file with mixed dtype >>> s = StringIO("1,1.3,abcde") >>> data = np.genfromtxt(s, dtype=[('myint','i8'),('myfloat','f8'), ... ('mystring','S5')], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '>> s.seek(0) # needed for StringIO example only >>> data = np.genfromtxt(s, dtype=None, ... names = ['myint','myfloat','mystring'], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '>> s.seek(0) >>> data = np.genfromtxt(s, dtype="i8,f8,S5", ... names=['myint','myfloat','mystring'], delimiter=",") >>> data array((1, 1.3, 'abcde'), dtype=[('myint', '>> s = StringIO("11.3abcde") >>> data = np.genfromtxt(s, dtype=None, names=['intvar','fltvar','strvar'], ... delimiter=[1,3,5]) >>> data array((1, 1.3, 'abcde'), dtype=[('intvar', 'ksRtOcs`s|]}|jVqdS(N(tchar(RR!((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pys ss4Nested fields involving objects are not supported...c3`s|]}t|VqdS(N(R[(RR(R(sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pys sN(((RRNRoRRnRRRRtnumpy.maR"R#RrRRRgRR;RRpRqRaRtlibt _datasourceRYR=R t _handymanR RRRRRRRRR3R[RRRRRR RRRcRRKRJRR RtupdateRRt IndexErrorRSRt iterupgradeR RtupgradeR tinsertRt _loose_callt _strict_calltstring_tmaxtsett_checkedRRRtNotImplementedErrortviewR,t_maskRR(YRRRRt skip_headert skip_footerRR,tfilling_valuesRRR&R'R)R%R(R+Rtusemasktlooset invalid_raisetmax_rowsR"R#Rtown_fhdtfhdRtvalidate_namest first_valuesRtfvalR!tnbcolstcurrentR tuser_missing_valuesR4Rtmisstvaluetentryt user_valuetuser_filling_valuestntfillt dtype_flattzipitRt uc_updatetjRR0trowstappend_to_rowstmaskstappend_to_maskstinvalidtappend_to_invalidRtvaluestnbvaluestvtmt convertert_mtcurrent_columnterrmsgt nbinvalidtnbrowsttemplatetnbinvalid_skippedtnbt_rtdatat column_typest strcolidxtcRtddtypetmdtypeR t outputmasktttrowmaskst ishomogeneoustttypeRtmval((RsB/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/npyio.pyRKs      !         "     ,   %  1      &# (    "                   ::4              (   !    2  %       # &   VS ' ( +,5%   .4 / # (   " %  cK`st|dsf       L4  1   P Q @:    :  X      y