
    h                    D    S SK Jr  S SKr            SS jrSS jrg)    )annotationsNc                   [        U SLUSLUSL/5      S:  a  [        S5      eUS:  d  US:  a  [        SU SU S35      eUbO  US-
  US-
  -  n[        [        US5      U5      nUS:X  a  Sn O%X%:X  a  S	n O[	        U5      nX4:  a  UnO
US   US   4nUb  [        U[        5      (       a  Uu  pxOU=px[        [        US5      US-
  5      n[        [        US5      US-
  5      n[        R                  " US-
  U-  5      [        R                  " US-
  U-  5      4n U c  S=pO[        U [        5      (       a  U u  pOU =pU
S:  d  U	S:  a  [        S
5      eX4$ )a  Calculate chunk sizes.

Args:
    chunk_size (int or tuple(int, int), optional): Chunk size in (y, x) directions, or the same
        size in both directions if only one is specified. Cannot be negative.
    chunk_count (int or tuple(int, int), optional): Chunk count in (y, x) directions, or the
        same count in both directions if only one is specified. If less than 1, set to 1.
    total_chunk_count (int, optional): Total number of chunks. If less than 1, set to 1.
    ny (int): Number of grid points in y-direction.
    nx (int): Number of grid points in x-direction.

Return:
    tuple(int, int): Chunk sizes (y_chunk_size, x_chunk_size).

Note:
    Zero or one of ``chunk_size``, ``chunk_count`` and ``total_chunk_count`` should be
    specified.
N   zGOnly one of chunk_size, chunk_count and total_chunk_count should be set   z'(ny, nx) must be at least (2, 2), not (z, )r   )r   r   zchunk_size cannot be negative)	sum
ValueErrorminmaxtwo_factors
isinstancetuplemathceil)
chunk_sizechunk_counttotal_chunk_countnynxmax_chunk_countfactorsy_chunk_countx_chunk_county_chunk_sizex_chunk_sizes              A/var/www/html/env/lib/python3.13/site-packages/contourpy/chunk.pycalc_chunk_sizesr      s   2 Jd"Kt$;=NVZ=Z[\_``bcc	AvaB2$bANOO$a4"Q$-$5q 9?K!J1J!"34Gw%&qz71:6k5))+6(M=,77MCq12a48Cq12a48iiA 67BqDMCY9Z[
&''|	J	&	&%/"l&00a<!+899%%    c                    U S:  a  [        SU  35      e[        R                  " [        R                  " U 5      5      nX-  S:w  a  US-  nX-  S:w  a  M  X-  nX:  a  X4$ X!4$ )a6  Split an integer into two integer factors.

The two factors will be as close as possible to the sqrt of n, and are returned in decreasing
order.  Worst case returns (n, 1).

Args:
    n (int): The integer to factorize, must be positive.

Return:
    tuple(int, int): The two factors of n, in decreasing order.
r   z)two_factors expects positive integer not r   )r	   r   r   sqrt)nijs      r   r   r   I   sk     	1uDQCHII		$))A,A
%1*	Q %1*	Auttr   )r   int | tuple[int, int] | Noner   r$   r   z
int | Noner   intr   r%   returntuple[int, int])r!   r%   r&   r'   )
__future__r   r   r   r    r   r   <module>r*      sU    " @&,@&-@& "@& 		@&
 	@& @&Fr   