a
    |=ic
                     @   s   d dl Z dd Zdd ZdS )    Nc                 C   sX  t | du|du|dugdkr&td|dur|d |d  }tt|d|}|dkr\d} n4||krjd} n&t|}||kr|}n|d |d f}|durt|tr|\}}n| }}tt|d|d }tt|d|d }t|d | t|d | f} | du rd }	}
nt| tr,| \}	}
n|  }	}
|
dk sH|	dk rPt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_sizeZchunk_countZtotal_chunk_countnynxZmax_chunk_countZfactorsZy_chunk_countZx_chunk_countZy_chunk_sizeZx_chunk_size r   `/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/contourpy/chunk.pycalc_chunk_sizes   s8    


$


r   c                 C   sJ   t t | }| | dkr&|d8 }q| | }||kr>||fS ||fS d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   N)r
   r   sqrt)nijr   r   r   r   >   s    
r   )r
   r   r   r   r   r   r   <module>   s   :