a
    d=icq	  ã                   @   s2   d Z ddlZddlZedƒZedƒZddd„ZdS )	a»  A module providing a function for serializing JSON values with Infinity.

Python provides no way to override how json.dumps serializes
Infinity/-Infinity/NaN; if allow_nan is true, it encodes them as
Infinity/-Infinity/NaN, in violation of the JSON spec and in violation
of what JSON.parse accepts. If it's false, it throws a ValueError,
Neither subclassing JSONEncoder nor passing a function in the |default|
keyword argument overrides this.
é    NÚinfz-infúutf-8c                    sÆ   t | tƒr| S t | tƒrD| tkr$dS | tkr0dS t | ¡r>dS | S n~t | tƒrX|  ˆ ¡S t | t	t
fƒrx‡ fdd„| D ƒS t | tƒr˜‡ fdd„t| ƒD ƒS t | tƒr¾t ‡ fdd„|  ¡ D ƒ¡S | S d	S )
aƒ  Makes Python object appropriate for JSON serialization.

    - Replaces instances of Infinity/-Infinity/NaN with strings.
    - Turns byte strings into unicode strings.
    - Turns sets into sorted lists.
    - Turns tuples into lists.

    Args:
      obj: Python data structure.
      encoding: Charset used to decode byte strings.

    Returns:
      Unicode JSON data structure.
    ÚInfinityz	-InfinityÚNaNc                    s   g | ]}t |ˆ ƒ‘qS © ©ÚCleanse©Ú.0Úi©Úencodingr   ún/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/backend/json_util.pyÚ
<listcomp>@   ó    zCleanse.<locals>.<listcomp>c                    s   g | ]}t |ˆ ƒ‘qS r   r   r	   r   r   r   r   B   r   c                 3   s&   | ]\}}t |ˆ ƒt |ˆ ƒfV  qd S )Nr   )r
   ÚkÚvr   r   r   Ú	<genexpr>D   s   zCleanse.<locals>.<genexpr>N)Ú
isinstanceÚintÚfloatÚ	_INFINITYÚ_NEGATIVE_INFINITYÚmathÚisnanÚbytesÚdecodeÚlistÚtupleÚsetÚsortedÚdictÚcollectionsÚOrderedDictÚitems)Úobjr   r   r   r   r   #   s*    






ÿr   )r   )Ú__doc__r"   r   r   r   r   r   r   r   r   r   Ú<module>   s
   