
    [h                     (   S r  SSKr\" \" \\R                  R                  S5      5      5      r\S:  a  \	" S5      eSr
SSKJrJr  SSKrS	\\\4   S
\\\4   4S jrS\S
\4S jrS\\\4   S
\4S jrS\S\\\4   S
S4S jrg!   Sr
SSKr NQ= f)z'
Utilities for writing Stan Json files
    N.)   r   r   zujson version too oldTF)AnyMappingdreturnc                 l    U R                  5        VVs0 s H  u  pU[        U5      _M     snn$ s  snnf )N)itemsprocess_value)r   kvs      ^C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\stanio/json.pyprocess_dictionaryr      s,    ,-GGI6IDAA}QI666s   0valc           
      d   U c  g [        U [        5      (       a  [        U 5      $ [        U [        5      (       a  U R                  U R
                  /$ [        U [        5      (       a  [        U 5      $ [        U [        5      (       a9  [        [        [        S[        U 5      S-   5      [        [        U 5      5      5      $ [        U [        5      (       a  U  Vs/ s H  n[        U5      PM     sn$ [        [!        U 5      SS5      nSU;   d  SU;   d  SU;   Ga  ["        R$                  " U 5      nUR&                  R(                  S;   a  UR+                  5       $ UR&                  R(                  S:X  aa  ["        R,                  " ["        R.                  " UR                  5      ["        R.                  " UR
                  5      /S	S
9R+                  5       $ UR&                  R(                  S:X  a#  UR1                  [        5      R+                  5       $ [        UR+                  5       5      $ U $ s  snf )N   
__module__ numpyxarraypandasiufc)axisb)
isinstanceboolintcomplexrealimagdictr   tupleziprangelenmapr   listgetattrtypenp
asanyarraydtypekindtoliststackasarrayastype)r   ioriginal_module	numpy_vals       r   r   r      s   
{#t3x#w#((###t!#&&#uCaSA.M30GHII#t*-.#Qa #..d3ir:O?"&&MM#&	??5(##%%??3&88RZZ	7INN9ST[]^eegg??3&##C(//11 Y--/00J' /s   H-datac                 @    [         R                  " [        U 5      5      $ )a  
Convert a mapping of strings to data to a JSON string.

Values can be any numeric type, a boolean (converted to int),
or any collection compatible with :func:`numpy.asarray`, e.g a
:class:`pandas.Series`.

Produces a string compatible with the
`Json Format for Cmdstan
<https://mc-stan.org/docs/cmdstan-guide/json.html>`__

:param data: A mapping from strings to values. This can be a dictionary
    or something more exotic like an :class:`xarray.Dataset`. This will be
    copied before type conversion, not modified
)jsondumpsr   )r7   s    r   dump_stan_jsonr;   ;   s      ::(.//    pathc                 2   [        U S5       n[        (       a!  [        R                  " [	        U5      U5        OE[        R
                  " 5       R                  [	        U5      5       H  nUR                  U5        M     SSS5        g! , (       d  f       g= f)a`  
Dump a mapping of strings to data to a JSON file.

Values can be any numeric type, a boolean (converted to int),
or any collection compatible with :func:`numpy.asarray`, e.g a
:class:`pandas.Series`.

Produces a file compatible with the
`Json Format for Cmdstan
<https://mc-stan.org/docs/cmdstan-guide/json.html>`__

:param path: File path for the created json. Will be overwritten if
    already in existence.

:param data: A mapping from strings to values. This can be a dictionary
    or something more exotic like an :class:`xarray.Dataset`. This will be
    copied before type conversion, not modified
wN)openUJSON_AVAILABLEr9   dumpr   JSONEncoder
iterencodewrite)r=   r7   fdchunks       r   write_stan_jsonrH   N   sb    & 
dCB?II(.3))+667I$7OP Q	 
s   A2B
B)__doc__ujsonr9   r$   r(   r   __version__split
uj_versionImportErrorrA   typingr   r   r   r,   strr   r   r;   rH    r<   r   <module>rR      s   	s3 0 0 6 6s ;<=JI122O
   7'#s(+ 7S0A 7
s s D0c* 0s 0& #  WS#X%6  4  GOs   <B B