
    LKi:              	       \    S SK JrJrJr  S SKJr   S	S\\   S\\   S\\\      S\4S jjr	g)
    )ListOptionalTuple)SparseVectorNindicesvalueslabelsreturnc                 .   U (       d  [        / / SS9$ UbF  [        [        XU5      S S9n[        U6 u  pEn[        [        U5      [        U5      [        U5      S9$ [        [        X5      S S9n[        U6 u  pE[        [        U5      [        U5      SS9$ )a  Normalize and create a SparseVector by sorting indices and values together.

This function takes raw indices and values (which may be unsorted or have duplicates)
and returns a properly constructed SparseVector with sorted indices.

Args:
    indices: List of dimension indices (may be unsorted)
    values: List of values corresponding to each index
    labels: Optional list of string labels corresponding to each index

Returns:
    SparseVector with indices sorted in ascending order

Raises:
    ValueError: If indices and values have different lengths
    ValueError: If there are duplicate indices (after sorting)
    ValueError: If indices are negative
    ValueError: If values are not numeric
    ValueError: If labels is provided and has different length than indices
N)r   r   r	   c                     U S   $ Nr    xs    g/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/chromadb/utils/sparse_embedding_utils.py<lambda>)normalize_sparse_vector.<locals>.<lambda>#   s    AaD    )keyc                     U S   $ r   r   r   s    r   r   r   +   s    !A$r   )r   sortedziplist)r   r   r	   sorted_triplessorted_indicessorted_valuessorted_labelssorted_pairss           r   normalize_sparse_vectorr      s    2 Br$?? GV <.Q7:N7K4}(&&
 	
 c'2G(+\(:%(&
 	
r   )N)
typingr   r   r   chromadb.base_typesr   intfloatstrr   r   r   r   <module>r%      sM    ( ( , #',
#Y,
K,
 T#Y,
 	,
r   