
    	g                         d Z ddlmZmZmZ ddlZddlmZ dee	ee	   f   dee	ej                  ej                     f   fdZy)z|
Module to load the minimal information from a Stan CSV file.
Only the header row and data are read, no metadata is parsed.
    )ListTupleUnionN	filenamesreturnc                    t        | t              s| g} d}t        t        |             D cg c]  }d }}t	        |       D ]  \  }}t        |d      5 }|j                         x}j                  d      r#	 |j                         x}j                  d      r#|dk(  r|}n||k7  rt        d      t        j                  |dd      ||<   ddd        |j                         t        j                  |d	      fS c c}w # 1 sw Y   xY w)
ad  
    Reads CSV files like those produced by Stan, returning the header and data.

    If multiple files are given, the data is stacked along the first axis,
    so in typical usage, the shape of the returned data will be
    ``(n_chains, n_samples, n_params)``.

    Parameters
    ----------
    filenames : Union[str, List[str]]
        Path to the CSV file(s) to read.

    Returns
    -------
    Tuple[str, npt.NDArray[np.float64]]
        The header row and data from the CSV file(s).

    Raises
    ------
    ValueError
        If multiple files are given and the headers do not match between them.
     Nr#zHeaders do not match,)	delimitercommentsr   )axis)
isinstancelistrangelen	enumerateopenreadline
startswith
ValueErrornploadtxtstripstack)r   header_dataiffdfile_headers           G/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/stanio/csv.pyread_csvr%      s   0 i&K	F9>s9~9N*OA4*OD*O)$ B1!S\ 	BR"$++-/;;;C@ #%++-/;;;C@|$;& !788jjsSADG	B 	BB <<>288Dq111 +P	B 	Bs   	C=AD3DD	)__doc__typingr   r   r   numpyr   numpy.typingnptstrNDArrayfloat64r%        r$   <module>r0      sO    & %  '2c49n- '2%S[[=T8T2U '2r/   