CoolFace
Apppublic

umair894/quickstart-trackio

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
histogram.cpython-312.pyc45 linesDownload Raw Back to __pycache__
1�

2�1�hi��,�ddlmZddlZGd�d�Zy)�)�AnyNc�B�eZdZdZdZ			d3dededzdefd�Zde	fd	�Z4y)�	HistogramaL5    Histogram data type for Trackio, compatible with wandb.Histogram.6 7    Example:8        ```python9        import trackio10        import numpy as np11 12        # Create histogram from sequence13        data = np.random.randn(1000)14        trackio.log({"distribution": trackio.Histogram(data)})15 16        # Create histogram from numpy histogram17        hist, bins = np.histogram(data, bins=30)18        trackio.log({"distribution": trackio.Histogram(np_histogram=(hist, bins))})19 20        # Specify custom number of bins21        trackio.log({"distribution": trackio.Histogram(data, num_bins=50)})22        ```23 24    Args:25        sequence: Optional sequence of values to create histogram from26        np_histogram: Optional pre-computed numpy histogram (hist, bins) tuple27        num_bins: Number of bins for the histogram (default 64, max 512)28    ztrackio.histogramN�sequence�np_histogram�num_binsc�P�|�
|�td��|�
|�td��t|d�}|�X|\|_|_t	j29|j�|_t	j30|j�|_yt	j31|�j
�}|t	j|�}t|�dk(r5t	jg�|_t	jg�|_yt	j||��\|_|_y)Nz,Must provide either sequence or np_histogramz-Cannot provide both sequence and np_histogramir)�bins)32�33ValueError�min�	histogramr34�np�asarray�flatten�isfinite�len�array)�selfrrr�datas     �</usr/local/lib/python3.12/dist-packages/trackio/histogram.py�__init__zHistogram.__init__#s������ 4��K�L�L���L�$<��L�M�M��x��%���#�(4�%�D�N�D�I��Z�Z����7�D�N��35�36�4�9�9�-�D�I��:�:�h�'�/�/�1�D�����D�)�*�D��4�y�A�~�!#���"�����H�H�R�L��	�,.�L�L��H�,M�)����	��returnc��|j|jj�|jj�d�S)z,Convert histogram to dictionary for storage.)�_typer37�values)�TYPEr38�tolistr
)rs r�_to_dictzHistogram._to_dict>s5���Y�Y��I�I�$�$�&��n�n�+�+�-�39�	40r)NN�@)�__name__�41__module__�__qualname__�__doc__rr�tuple�intr�dictr�rrrrsN���4�D��%)��	N��N��d�l�N��	N�642�$�43rr)�typingr�numpyrrr(rr�<module>r+s����>44�>45r