Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_ratio.cpython-313.pyc60 linesDownload Raw Back to __pycache__
1�

2�j���z�SSKJr SSKJr SSKJrJrJrJrJ	r	 "SS\	5r3S\S\\4S\\4S	jrS\S5\\S\\S\\S\\46S
jr
SS\S7\\S\\\S\\4Sjjr\S:XaHSSKJr \"SS55r\"S\"SSS5\"SSS5\"SSS5/5r\"\"\55 gg)�)�Fraction)�ceil)�cast�List�Optional�Sequence�Protocolc�J�\rSrSr%SrSr\\\S'Sr	\\S'Sr8\\S'Srg)	�Edge�z1Any object that defines an edge (such as Layout).N�size��ratio�minimum_size�)�__name__�9__module__�__qualname__�__firstlineno__�__doc__r
r�int�__annotations__rr�__static_attributes__r��QD:\code\apps\devtools\python\user_packages\Python313\site-packages\rich/_ratio.pyrrs&��;��D�(�3�-���E�3�N��L�#�rr�total�edges�returnc���UVs/sHo"R=(d SPM nn[nSU;Ga[[X155VVVs/sHunupbUbM
XR4PM nnnnU[	SU55-10nUS::a8[X15VVs/sHupbUcUR11=(d SOUPM! snn$U"U[	SU555n	UH1upRX�R-UR12::dM#UR13X5' O7 U"S5n14UH&upR[X�R-U15-S5upjXcU'M( O	SU;aGM[[[U5$s snfs snnnfs snnf)a`Divide total space to satisfy size, ratio, and minimum_size, constraints.16 17The returned list of integers should add up to total in most cases, unless it is18impossible to satisfy all the constraints. For instance, if there are two edges19with a minimum size of 20 each and `total` is 30 then the returned list will be20greater than total. In practice, this would mean that a Layout object would21clip the rows that would overflow the screen height.22 23Args:24    total (int): Total number of characters.25    edges (List[Edge]): Edges within total space.26 27Returns:28    List[int]: Number of characters for each edge.29Nc3�6# �UHo=(d Sv� M g7f)rNr)�.0r
s  r�	<genexpr>� ratio_resolve.<locals>.<genexpr>,s���<�e�d�	��	�e�s�rrc3�P# �UHupUR=(d Sv� M g7f)rN)r)r!�_�edges   rr"r#5s���K�N���D�J�J�O�!�O�N�s�$&)r
r�	enumerate�zip�sumrr�divmodrrr)rrr&�sizes�	_Fraction�indexr
�flexible_edges�	remaining�portion�	remainders           r�
ratio_resolver2s���".3�3�U�T�i�i��4��U�E�3��I��%�-�(1��U�1B�'C�30�'C�#��|���
�U�M�'C�	�31��C�<�e�<�<�<�	���>�#&�e�"3��"3�J�D�.2�\�$�#�#�(�q��t�C�"3��
�32��s�K�N�K�K�33��34*�K�E����#�t�'8�'8�8�#�0�0����	*�"�!��I�-���"(��:�:�)=�	�)I�1�"M���#�e�� .�
�E�%�-�H��S�	�5�!�!��S
4��35��s�E�36E"�E"�&E)�ratios�maximums�valuesc�b�[X5VVs/sHupEU(aUOSPM nnn[U5nU(dUSS$Un/nURn	[XU5HIupJnU(a4US:�a.[U37[	XG-U-55nU	"X�-385 X|-nXd-nMAU	"U5 MK U$s snnf)aDDivide an integer total in to parts based on ratios.39 40Args:41    total (int): The total to divide.42    ratios (List[int]): A list of integer ratios.43    maximums (List[int]): List of maximums values for each slot.44    values (List[int]): List of values45 46Returns:47    List[int]: A list of integers guaranteed to sum to total.48rN)r(r)�append�min�round)
rr3r4r5r�_max�total_ratio�total_remaining�resultr7�maximum�value�distributeds
             r�ratio_reducerAKs���7:�&�6K�
L�6K�{�u�t�e��"�6K�F�
L��f�+�K���a�y���O��F�
�]�]�F�!$�V�v�!>�����[�1�_��g�u�U�-D�{�-R�'S�T�K��5�&�'��*�O�� �K��5�M�"?��M��Ms�B+N�minimumsc�x�U(a([X5VVs/sHup4U(aUOSPM nnn[U5nUS:�dS5eUn/nURnUcS/[U5-n	OUn	[X5H8up:US:�a[	U49[X6-U-55nOUnU"U5 XS-nXk-nM: U$s snnf)a Distribute an integer total in to parts based on ratios.50 51Args:52    total (int): The total to divide.53    ratios (List[int]): A list of integer ratios.54    minimums (List[int]): List of minimum values for each slot.55 56Returns:57    List[int]: A list of integers guaranteed to sum to total.58rzSum of ratios must be > 0)r(r)r7�len�maxr)rr3rBr�_minr;r<�distributed_totalr7�	_minimums�minimumr@s            r�ratio_distributerJks����:=�f�:O�P�:O�;�5�4�%�Q�&�:O��P��f�+�K���?�7�7�7�?��O�#%��
�
%�
%�F����C�#�f�+�%�	��	��f�0�����?��g�t�E�,C�k�,Q�'R�S�K�)�K��{������&��1����'Qs�B6�__main__)�	dataclassc�F�\rSrSr%Sr\\\S'Sr\\S'Sr	\\S'Sr59g)�E�Nr
rrrr)rrrrr
rrrrrrrrrrNrN�s#��"��h�s�m�"���s����c�rrN�nr)N)�	fractionsr�mathr�typingrrrrr	rrr2rArJr�dataclassesrLrN�resolved�printr)rrr�<module>rWs����;�;��8��:"��:"�X�d�^�:"��S�	�:"�z����S�	��-1�#�Y��@D�S�	��	�#�Y��BDH�!��!��S�	�!�-5�d�3�i�-@�!�	�#�Y�!�H�z��%������60�S�1�T�1�a�=�!�D�!�Q�-��4��A��"O�P�H�	�#�h�-��r
codekingpro/portable-devtools · Team Ai