a
    >PÎjL  ã                   @  sÀ   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	m
Z
mZmZ d dlmZmZ d dlmZmZ ertd dlmZ dd	dd
œdd„Zddddœdd„Zdd	ddœdd„Zddddœdd„ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚcast)ÚFillTypeÚLineType)Úconcat_codes_or_noneÚconcat_offsets_or_noneÚconcat_points_or_noneÚconcat_points_or_none_with_nan)Úas_fill_typeÚas_line_type)Úcheck_filledÚcheck_linesNzcpy.FillReturnzFillType | str)ÚfilledÚ	fill_typeÚreturnc                 C  s¼  t |ƒ}|tjtjfv r| S t| |ƒ t| d ƒdk r:| S trJttj	| ƒ} t
| d ƒ}|tjkržtrpttj| ƒ} |du r†dgdgf}n|gt| d ƒgf}|S |tjkrætr¸ttj| ƒ} |du rÎdgdgf}n|gt| d ƒgf}|S |tjk�rHt�rttj| ƒ} |du �r dgdgdgf}n$t| d ƒ}|gt| d ƒg|gf}|S |tjk�rªt�rfttj| ƒ} |du �r‚dgdgdgf}n$t| d ƒ}|gt| d ƒg|gf}|S td|› �ƒ‚dS )a¨  Return the specified filled contours with chunked data moved into the first chunk.

    Filled contours that are not chunked (``FillType.OuterCode`` and ``FillType.OuterOffset``) and
    those that are but only contain a single chunk are returned unmodified. Individual polygons are
    unchanged, they are not geometrically combined.

    Args:
        filled (sequence of arrays): Filled contour data, such as returned by
            :meth:`.ContourGenerator.filled`.
        fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` as enum or string
            equivalent.

    Return:
        Filled contours in a single chunk.

    .. versionadded:: 1.2.0
    r   é   Né   zInvalid FillType )r   r   Ú	OuterCodeÚOuterOffsetr   Úlenr   r   ÚcpyZFillReturn_Chunkr	   ÚChunkCombinedCodeZFillReturn_ChunkCombinedCoder   ÚChunkCombinedOffsetZFillReturn_ChunkCombinedOffsetr   ZChunkCombinedCodeOffsetZ"FillReturn_ChunkCombinedCodeOffsetZChunkCombinedOffsetOffsetZ$FillReturn_ChunkCombinedOffsetOffsetÚ
ValueError)r   r   ÚpointsÚret1Úret2Úret3Zouter_offsetsZret4© r   úa/mounts/lovelace/software/anaconda3/envs/metadmg/lib/python3.9/site-packages/contourpy/dechunk.pyÚdechunk_filled   sP    




r!   zcpy.LineReturnzLineType | str)ÚlinesÚ	line_typer   c                 C  s:  t |ƒ}|tjtjfv r| S t| |ƒ t| d ƒdk r:| S trJttj	| ƒ} |tj
kržtrdttj| ƒ} t| d ƒ}|du r†dgdgf}n|gt| d ƒgf}|S |tjkròtr¸ttj| ƒ} t| d ƒ}|du rÚdgdgf}n|gt| d ƒgf}|S |tjk�r(t�rttj| ƒ} t| d ƒ}|gf}|S td|› �ƒ‚dS )aš  Return the specified contour lines with chunked data moved into the first chunk.

    Contour lines that are not chunked (``LineType.Separate`` and ``LineType.SeparateCode``) and
    those that are but only contain a single chunk are returned unmodified. Individual lines are
    unchanged, they are not geometrically combined.

    Args:
        lines (sequence of arrays): Contour line data, such as returned by
            :meth:`.ContourGenerator.lines`.
        line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` as enum or string
            equivalent.

    Return:
        Contour lines in a single chunk.

    .. versionadded:: 1.2.0
    r   r   Nr   zInvalid LineType )r   r   ÚSeparateÚSeparateCoder   r   r   r   r   ZLineReturn_Chunkr   ZLineReturn_ChunkCombinedCoder	   r   r   ZLineReturn_ChunkCombinedOffsetr   ZChunkCombinedNanZLineReturn_ChunkCombinedNanr
   r   )r"   r#   r   r   r   r   r   r   r    Údechunk_linesZ   s>    


r&   zlist[cpy.FillReturn])Úmulti_filledr   r   c                   s.   t ˆ ƒ‰ ˆ tjtjfv r| S ‡ fdd„| D ƒS )aÐ  Return multiple sets of filled contours with chunked data moved into the first chunks.

    Filled contours that are not chunked (``FillType.OuterCode`` and ``FillType.OuterOffset``) and
    those that are but only contain a single chunk are returned unmodified. Individual polygons are
    unchanged, they are not geometrically combined.

    Args:
        multi_filled (nested sequence of arrays): Filled contour data, such as returned by
            :meth:`.ContourGenerator.multi_filled`.
        fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` as enum or string
            equivalent.

    Return:
        Multiple sets of filled contours in a single chunk.

    .. versionadded:: 1.3.0
    c                   s   g | ]}t |ˆ ƒ‘qS r   )r!   )Ú.0r   ©r   r   r    Ú
<listcomp>±   ó    z(dechunk_multi_filled.<locals>.<listcomp>)r   r   r   r   )r'   r   r   r)   r    Údechunk_multi_filled–   s    r,   zlist[cpy.LineReturn])Úmulti_linesr#   r   c                   s.   t ˆ ƒ‰ ˆ tjtjfv r| S ‡ fdd„| D ƒS )aÆ  Return multiple sets of contour lines with all chunked data moved into the first chunks.

    Contour lines that are not chunked (``LineType.Separate`` and ``LineType.SeparateCode``) and
    those that are but only contain a single chunk are returned unmodified. Individual lines are
    unchanged, they are not geometrically combined.

    Args:
        multi_lines (nested sequence of arrays): Contour line data, such as returned by
            :meth:`.ContourGenerator.multi_lines`.
        line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` as enum or string
            equivalent.

    Return:
        Multiple sets of contour lines in a single chunk.

    .. versionadded:: 1.3.0
    c                   s   g | ]}t |ˆ ƒ‘qS r   )r&   )r(   r"   ©r#   r   r    r*   Ï   r+   z'dechunk_multi_lines.<locals>.<listcomp>)r   r   r$   r%   )r-   r#   r   r.   r    Údechunk_multi_lines´   s    r/   )Ú
__future__r   Útypingr   r   Zcontourpy._contourpyr   r   Zcontourpy.arrayr   r   r	   r
   Zcontourpy.enum_utilr   r   Zcontourpy.typecheckr   r   Z
_contourpyr   r!   r&   r,   r/   r   r   r   r    Ú<module>   s   G<