Team Ai
Apppublic

Shivam249/function-gemma

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

2jUIi7	��,�ddlmZddlZGd�d�Zy)�)�SequenceNc�t�eZdZdZdZ			d3dejeezee	zdzde4dzde	fd�Zdefd	�Z
y)�	Histograma�5    Histogram data type for Trackio, compatible with wandb.Histogram.6 7    Args:8        sequence (`np.ndarray` or `Sequence[float]` or `Sequence[int]`, *optional*):9            Sequence of values to create the histogram from.10        np_histogram (`tuple`, *optional*):11            Pre-computed NumPy histogram as a `(hist, bins)` tuple.12        num_bins (`int`, *optional*, defaults to `64`):13            Number of bins for the histogram (maximum `512`).14 15    Example:16        ```python17        import trackio18        import numpy as np19 20        # Create histogram from sequence21        data = np.random.randn(1000)22        trackio.log({"distribution": trackio.Histogram(data)})23 24        # Create histogram from numpy histogram25        hist, bins = np.histogram(data, bins=30)26        trackio.log({"distribution": trackio.Histogram(np_histogram=(hist, bins))})27 28        # Specify custom number of bins29        trackio.log({"distribution": trackio.Histogram(data, num_bins=50)})30        ```31    ztrackio.histogramN�sequence�np_histogram�num_binsc�P�|�
|�td��|�
|�td��t|d�}|�X|\|_|_t	j32|j�|_t	j33|j�|_yt	j34|�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)35�36ValueError�min�	histogramr37�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��38�39�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.)�_typer40�values)�TYPEr41�tolistr
)rs r�_to_dictzHistogram._to_dictAs5���Y�Y��I�I�$�$�&��n�n�+�+�-�42�	43r)NN�@)�__name__�44__module__�__qualname__�__doc__rr�ndarrayr�float�int�tupler�dictr�rrrrsk���:�D�IM�%)��	N��*�*�x���.��#��>��E�N��d�l�N��	N�645�$�46rr)�typingr�numpyrrr*rr�<module>r-s����A47�A48r