
    "	f                    @    d dl mZ d dlZ	 	 	 	 	 	 	 	 	 	 	 	 ddZddZy)    )annotationsNc                b   t        | du|du|dug      dkD  rt        d      |N|dz
  |dz
  z  }t        t        |d      |      }|dk(  rd} n%||k(  rd} nt	        |      }||kD  r|}n
|d   |d   f}|t        |t              r|\  }}n|x}}t        t        |d      |dz
        }t        t        |d      |dz
        }t        j                  |dz
  |z        t        j                  |dz
  |z        f} | dx}	}
nt        | t              r| \  }	}
n| x}	}
|
dk  s|	dk  rt        d      |	|
fS )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.
        chunk_count (int or tuple(int, int), optional): Chunk count in (y, x) directions, or the
            same count in both irections if only one is specified.
        total_chunk_count (int, optional): Total number of chunks.
        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:
        A maximum of one of ``chunk_size``, ``chunk_count`` and ``total_chunk_count`` may be
        specified.
    N   zGOnly one of chunk_size, chunk_count and total_chunk_count should be setr   )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              1/usr/lib/python3/dist-packages/contourpy/chunk.pycalc_chunk_sizesr      sy   2 Jd"Kt$;=NVZ=Z[\_``bcc$a4"Q$-$5q 9?K!J/1J!"34GBw%&qz71:6k5)+6(M=,77MMCq12a48Cq12a48iiA 67BqDMCY9Z[
&''|	J	&%/"l&00|a<!+899%%    c                    t        j                  t        j                  |             }| |z  dk7  r|dz  }| |z  dk7  r| |z  }||kD  r||fS ||fS )a@  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.

    Return:
        tuple(int, int): The two factors of n, in decreasing order.
    r   r   )r   r   sqrt)nijs      r   r
   r
   F   s]     			$))A,A
a%1*	Q a%1*	QA1u!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(      sN    " =&,=&-=& "=& 		=&
 	=& =&@r   