*m] d Z dZddlZddlmc mZ ddlm Z m Z ddZd Zd Z d Zdd Z G d d Z G d d Zd Z G d de Z G d de Z G d de Z G d d ZddZdS )zBA collection of functions designed to help I/O with ascii files. zrestructuredtext en N)asbytes asunicodec d t | t u r|d}| | } | S )ak Decode bytes from binary input streams. Defaults to decoding from 'latin1'. That differs from the behavior of np.compat.asunicode that decodes from 'ascii'. Parameters ---------- line : str or bytes Line to be decoded. encoding : str Encoding used to decode `line`. Returns ------- decoded_line : str Nlatin1)typebytesdecode)lineencodings f/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/numpy/lib/_iotools.py_decode_liner s6 $ DzzUH{{8$$K c D | dz n# t t f$ r Y dS w xY wdS )z2 Check whether obj behaves like a string. FT TypeError ValueErrorobjs r _is_string_liker % s> bz" uu4 c D | dz n# t t f$ r Y dS w xY wdS )z8 Check whether obj behaves like a bytes object. r FTr r s r _is_bytes_liker 0 s> c z" uu4r c > | j pdD ]}| | j dS dS )a Returns whether one or several fields of a dtype are nested. Parameters ---------- ndtype : dtype Data-type of a structured array. Raises ------ AttributeError If `ndtype` does not have a `names` attribute. Examples -------- >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)]) >>> np.lib._iotools.has_nested_fields(dt) False NTF)names)ndtypenames r has_nested_fieldsr ; s8 * " $<)44 *5r Fc | j }|9|r/| j gt t j | j z S | j gS g }|D ]:}| j | }t |d | }| | ;|S )aX Unpack a structured data-type by collapsing nested fields and/or fields with a shape. Note that the field names are lost. Parameters ---------- ndtype : dtype The datatype to collapse flatten_base : bool, optional If True, transform a field with a shape into several fields. Default is False. Examples -------- >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float), ... ('block', int, (2, 3))]) >>> np.lib._iotools.flatten_dtype(dt) [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64')] >>> np.lib._iotools.flatten_dtype(dt, flatten_base=True) [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64')] Nr ) r baseintnpprodshapefields flatten_dtypeextend)r flatten_baser typesfieldinfoflat_dts r r' r' V s B LE} >K=3rwv|'<'<#=#===} " "E='D#DG\::GLL!!!!r c <