Ë
    Ìih  ã                   óJ   — d dl mZ d dlmZ d dlmZ d dlmZ  G d„ de«      Zy)é    )ÚDecimal)Ú
cmp_to_key)ÚComputation©ÚNumberc                   ó$   — e Zd ZdZdd„Zd„ Zd„ Zy)ÚRankaþ  
    Calculate rank order of the values in a column.

    Uses the "competition" ranking method: if there are four values and the
    middle two are tied, then the output will be `[1, 2, 2, 4]`.

    Null values will always be ranked last.

    :param column_name:
        The name of the column to rank.
    :param comparer:
        An optional comparison function. If not specified ranking will be
        ascending, with nulls ranked last.
    :param reverse:
        Reverse sort order before ranking.
    Nc                 ó.   — || _         || _        || _        y ©N)Ú_column_nameÚ	_comparerÚ_reverse)ÚselfÚcolumn_nameÚcomparerÚreverses       úX/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/agate/computations/rank.pyÚ__init__zRank.__init__   s   € Ø'ˆÔØ!ˆŒØˆ�ó    c                 ó   — t        «       S r   r   )r   Útables     r   Úget_computed_data_typezRank.get_computed_data_type   s	   € Ü‹xˆr   c                 ó´  — |j                   | j                     }| j                  r/t        |j	                  «       t        | j                  «      ¬«      }n|j                  «       }| j                  r|j                  «        i }d}|D ]  }|dz  }||v rŒt        |«      ||<   Œ g }|j                  D ]#  }|j                  ||| j                        «       Œ% |S )z4
        :returns:
            :class:`int`
        )Úkeyr   é   )Úcolumnsr   r   ÚsortedÚvaluesr   Úvalues_sortedr   r   r   ÚrowsÚappend)	r   r   ÚcolumnÚdata_sortedÚranksÚrankÚcÚ
new_columnÚrows	            r   ÚrunzRank.run!   sÔ   € ð
 —‘˜t×0Ñ0Ñ1ˆà�>Š>Ü  §¡£´jÀÇÁÓ6PÔQ‰Kà ×.Ñ.Ó0ˆKà�=Š=Ø×ÑÔ!àˆØˆàò 	%ˆAØ�A‰IˆDà�E‰zØä˜t“}ˆE�!ŠHð	%ð ˆ
à—:‘:ò 	=ˆCØ×Ñ˜e C¨×(9Ñ(9Ñ$:Ñ;Õ<ð	=ð Ðr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r)   © r   r   r	   r	      s   „ ñó  ò
ór   r	   N)	Údecimalr   Ú	functoolsr   Úagate.computations.baser   Úagate.data_typesr   r	   r.   r   r   ú<module>r3      s   ðÝ Ý  å /Ý #ô8ˆ;õ 8r   