
    M/Ph                     &    d Z ddlZddlmZ ddZdS )zR
Input/Output tools for working with binary data.

See Also
--------
numpy.lib.io
    N)get_file_obj%.18e c                    t          | d          5 }t          j        |          }|j        dk    rB|j        j        t          j        |          j        }d}n't          |j        j	                  }n|j
        d         }t          |t          t          f          rHt          |          |k    rt          dt          |          z            |                    |          }nwt          |t                    rb|                    d          dk    r|g|z  }|                    |          }n-|                    d          |k    rt          d|z            |}||j        j        r|j        j        }|+|                    |                    |          dz              |D ]*}|                    |t          |          z  dz              +	 ddd           dS # 1 swxY w Y   dS )a
  
    Save an array to a text file.

    This is just a copy of numpy.savetxt patched to support structured arrays
    or a header of names.  Does not include py3 support now in savetxt.

    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.
    names : list, optional
        If given names will be the column header in the text file.
    fmt : str or sequence of strs
        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.
    delimiter : str
        Character separating columns.

    See Also
    --------
    save : Save an array to a binary file in NumPy ``.npy`` format
    savez : Save several arrays into a ``.npz`` compressed archive

    Notes
    -----
    Further explanation of the `fmt` parameter
    (``%[flag]width[.precision]specifier``):

    flags:
        ``-`` : left justify

        ``+`` : Forces to preceed 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`` : str 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
           <http://docs.python.org/library/string.html#
           format-specification-mini-language>`_, Python Documentation.

    Examples
    --------
    >>> savetxt('test.out', x, delimiter=',')   # x is an array
    >>> savetxt('test.out', (x,y,z))   # x,y,z equal sized 1D arrays
    >>> savetxt('test.out', x, fmt='%1.4e')   # use exponential notation
    w   Nzfmt has wrong shape.  %s%z'fmt has wrong number of %% formats.  %s
)r   npasarrayndimdtypenames
atleast_2dTlendescrshape
isinstancelisttupleAttributeErrorstrjoincountwrite)	fnameXr   fmt	delimiterfhncolformatrows	            Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/iolib/foreign.pysavetxtr&      s"   p 
eS	!	! '1RJqMM 6Q;;w}$M!$$& 17=))71:D cD%=)) 	3xx4$%?#c((%JKKK^^C((FFS!! 	yy~~""gdl",,34''$%N'*&+ , , ,  =QW]=GMEHHY^^E**T1222 	1 	1CHHVeCjj(4/0000	1M'1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1 '1s   F>GG!$G!)Nr   r   )__doc__numpyr   statsmodels.iolib.openfiler   r&        r%   <module>r,      sS         3 3 3 3 3 31 1 1 1 1 1r+   