
    ^j^                       d dl mZ d dlmZmZ d dlZd dlZd dlmZ	 dZ
ddZ	 	 	 	 	 	 ddZddZddZdd	Zdd
ZddZ	 	 	 	 	 	 ddZd dZd!dZd"dZd#dZd$dZd%dZd&dZ	 	 	 	 	 	 	 	 d'dZ	 	 	 	 	 	 d(dZ	 d)	 	 	 	 	 d*dZd+dZy),    )annotations)AnycastN   c                    t        j                  | j                  d   ddf| j                        }| ddg df   |dddddf<   | ddg df   |dddddf<   |S )	a  
    Convert an array of boxes to an array of polygons.
    Retains the input datatype.

    Args:
        box: An array of boxes (N, 4), where each box is represented as a
            list of four coordinates in the format `(x_min, y_min, x_max, y_max)`.

    Returns:
        An array of polygons (N, 4, 2), where each polygon is
            represented as a list of four coordinates in the format `(x, y)`.
    r         dtypeN)r   r	   r	   r   )   r   r   r   r   )npzerosshaper   )boxpolygons     q/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/detection/utils/converters.pyxyxy_to_polygonsr      s^     hh		!a+399=G1l?+GAq!G1l?+GAq!GN    c                    t        t        |      \  }}t        j                  ||ft        j                        }t        j                  || j                  t        j                        gd       |S )ae  Generate a mask from a polygon.

    Args:
        polygon: The polygon for which the mask should be generated,
            given as a list of vertices.
        resolution_wh: The width and height of the desired resolution.

    Returns:
        The generated 2D mask, where the polygon is marked with
            `1`s and the rest is filled with `0`s.
    r
   )r   )color)	mapintr   r   uint8cv2fillPolyastypeint32)r   resolution_whwidthheightmasks        r   polygon_to_maskr"      sQ     ]+ME688VUO2884DLLrxx01>Kr   c                    | j                         }| dddf   | dddf   z   |dddf<   | dddf   | dddf   z   |dddf<   |S )a  
    Converts bounding box coordinates from `(x, y, width, height)`
    format to `(x_min, y_min, x_max, y_max)` format.

    Args:
        xywh: A numpy array of shape `(N, 4)` where each row
            corresponds to a bounding box in the format `(x, y, width, height)`.

    Returns:
        A numpy array of shape `(N, 4)` where each row corresponds
            to a bounding box in the format `(x_min, y_min, x_max, y_max)`.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> xywh = np.array([
        ...     [10, 20, 30, 40],
        ...     [15, 25, 35, 45]
        ... ])
        >>> sv.xywh_to_xyxy(xywh=xywh)
        array([[10, 20, 40, 60],
               [15, 25, 50, 70]])

        ```
    Nr   r	   r   r   copy)xywhxyxys     r   xywh_to_xyxyr(   4   sX    6 99;Dadd1a4j(DAJadd1a4j(DAJKr   c                    | j                         }| dddf   | dddf   z
  |dddf<   | dddf   | dddf   z
  |dddf<   |S )a
  
    Converts bounding box coordinates from `(x_min, y_min, x_max, y_max)`
    format to `(x, y, width, height)` format.

    Args:
        xyxy: A numpy array of shape `(N, 4)` where each row
            corresponds to a bounding box in the format `(x_min, y_min, x_max,
            y_max)`.

    Returns:
        A numpy array of shape `(N, 4)` where each row corresponds
            to a bounding box in the format `(x, y, width, height)`.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> xyxy = np.array([
        ...     [10, 20, 40, 60],
        ...     [15, 25, 50, 70]
        ... ])
        >>> sv.xyxy_to_xywh(xyxy=xyxy)
        array([[10, 20, 30, 40],
               [15, 25, 35, 45]])

        ```
    Nr	   r   r   r   r$   )r'   r&   s     r   xyxy_to_xywhr*   U   sX    8 99;Dadd1a4j(DAJadd1a4j(DAJKr   c                   | j                         }| dddf   | dddf   dz  z
  |dddf<   | dddf   | dddf   dz  z
  |dddf<   | dddf   | dddf   dz  z   |dddf<   | dddf   | dddf   dz  z   |dddf<   |S )aP  
    Converts bounding box coordinates from `(center_x, center_y, width, height)`
    format to `(x_min, y_min, x_max, y_max)` format.

    Args:
        xcycwh: A numpy array of shape `(N, 4)` where each row
            corresponds to a bounding box in the format `(center_x, center_y, width,
            height)`.

    Returns:
        A numpy array of shape `(N, 4)` where each row corresponds
            to a bounding box in the format `(x_min, y_min, x_max, y_max)`.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> xcycwh = np.array([
        ...     [50.0, 50.0, 20.0, 30.0],
        ...     [30.0, 40.0, 10.0, 15.0]
        ... ])
        >>> sv.xcycwh_to_xyxy(xcycwh=xcycwh)
        array([[40. , 35. , 60. , 65. ],
               [25. , 32.5, 35. , 47.5]])

        ```
    Nr   r	   r   r   r$   )xcycwhr'   s     r   xcycwh_to_xyxyr-   w   s    8 ;;=D1q!tq 00DAJ1q!tq 00DAJ1q!tq 00DAJ1q!tq 00DAJKr   c                r   | j                   dk(  rt        j                  dt              S | j                  \  }}}}||z
  }||z
  }||dz  z   }||dz  z   }t        j
                  ||t        j                  |t              |dk7        }	t        j                  |||	|f      }
|
j                  t              S )a^  
    Converts bounding box coordinates from `(x_min, y_min, x_max, y_max)`
    into measurement space to format `(center x, center y, aspect ratio, height)`,
    where the aspect ratio is `width / height`.

    Args:
        xyxy: Bounding box in format `(x1, y1, x2, y2)`.
            Expected shape is `(N, 4)`.
    Returns:
        Bounding box in format
            `(center x, center y, aspect ratio, height)`. Shape `(N, 4)`.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> xyxy = np.array([
        ...     [10, 20, 40, 60],
        ...     [15, 25, 50, 70]
        ... ])
        >>> sv.xyxy_to_xcycarh(xyxy=xyxy)  # doctest: +ELLIPSIS
        array([[25.        , 40.        ,  0.75      , 40.        ],
               [32.5       , 47.5       ,  0.77..., 45.        ]])

        ```

    r   )r   r   r
   r	   )outwhere)	sizer   emptyfloatTdivide
zeros_likecolumn_stackr   )r'   x1y1x2y2r   r    center_xcenter_yaspect_ratioresults              r   xyxy_to_xcycarhr@      s    8 yyA~xxe,,VVNBBGE"WFEAI~HFQJH99MM%u-k	L __h,GHF==r   c                   | j                   \  }}}| j                  dk(  rt        j                  |dft              S t        t        j                  t        j                     | j                  d            }t        t        j                  t        j                     | j                  d            }|j                  d      }|dz
  |dddddf   j                  d      z
  }|j                  d      }|dz
  |dddddf   j                  d      z
  }	t        j                  ||||	fd      j                  t              }
d|
|j                  d       <   |
S )	a  
    Converts a 3D `np.array` of 2D bool masks into a 2D `np.array` of bounding boxes.

    Args:
        masks: A 3D `np.array` of shape `(N, H, W)` containing 2D bool masks.

    Returns:
        A 2D `np.array` of shape `(N, 4)` containing the bounding boxes
            `(x_min, y_min, x_max, y_max)` for each mask.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> masks = np.array([
        ...     [[False, False, False],
        ...      [False,  True,  True],
        ...      [False,  True,  True]],
        ... ])
        >>> sv.mask_to_xyxy(masks)
        array([[1, 1, 2, 2]])

        ```
    r   r   r
   r	   axisr   N)r   r1   r   r   r   r   nptNDArraybool_anyargmaxstackr   )masksnr    r   rows_anycols_anyx_minx_maxy_miny_maxr'   s              r   mask_to_xyxyrS      s1   2 {{AvuzzQxxAc**
 CKK)599!9+<=HCKK)599!9+<=HOOO#EAIDbD)00a088EOOO#EQJ!TrT'*11q199E88UE5%0q9@@ED"#D(,,A,
	Kr   c                   |\  }}| j                   d   }t        j                  |||ft              }t	        |       D ]  \  }\  }}}	}
t        dt        |            }t        dt        |            }t        |dz
  t        |	            }	t        |dz
  t        |
            }
|	|k\  sk|
|k\  sqd||||
dz   ||	dz   f<    |S )a1  
    Converts a 2D `np.ndarray` of bounding boxes into a 3D `np.ndarray` of bool masks.

    Args:
        boxes: A 2D `np.ndarray` of shape `(N, 4)` containing bounding boxes
            `(x_min, y_min, x_max, y_max)`.
        resolution_wh: A tuple `(width, height)` specifying the resolution of
            the output masks.

    Returns:
        A 3D `np.ndarray` of shape `(N, height, width)` containing 2D bool masks
            for each bounding box.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> boxes = np.array([[0, 0, 2, 2]])
        >>> sv.xyxy_to_mask(boxes, (5, 5))
        array([[[ True,  True,  True, False, False],
                [ True,  True,  True, False, False],
                [ True,  True,  True, False, False],
                [False, False, False, False, False],
                [False, False, False, False, False]]])
        >>> boxes = np.array([[0, 0, 1, 1], [3, 3, 4, 4]])
        >>> sv.xyxy_to_mask(boxes, (5, 5))
        array([[[ True,  True, False, False, False],
                [ True,  True, False, False, False],
                [False, False, False, False, False],
                [False, False, False, False, False],
                [False, False, False, False, False]],
        <BLANKLINE>
               [[False, False, False, False, False],
                [False, False, False, False, False],
                [False, False, False, False, False],
                [False, False, False,  True,  True],
                [False, False, False,  True,  True]]])

        ```
    r   r
   r   T)r   r   r   bool	enumeratemaxr   min)boxesr   r   r    rL   rK   irO   rQ   rP   rR   s              r   xyxy_to_maskr[      s    V "ME6AAHHa't4E+4U+; B''E5%As5z"As5z"EAIs5z*FQJE
+E>eun=AE!UUQY&	(99:B Lr   c                (   t        j                  | j                  t        j                        t         j
                  t         j                        \  }}|D cg c]/  }|j                  d   t        k\  rt        j                  |d      1 c}S c c}w )a  
    Converts a binary mask to a list of polygons.

    Args:
        mask: A binary mask represented as a 2D NumPy array of shape `(H, W)`,
            where H and W are the height and width of the mask, respectively.

    Returns:
        A list of polygons, where each polygon is represented by a NumPy array
            of shape `(N, 2)`, containing the `x`, `y` coordinates of the
            points. Polygons with fewer points than `MIN_POLYGON_POINT_COUNT = 3`
            are excluded from the output.
    r   r   rB   )
r   findContoursr   r   r   	RETR_TREECHAIN_APPROX_SIMPLEr   MIN_POLYGON_POINT_COUNTsqueeze)r!   contours_contours       r   mask_to_polygonsre   3  su     ""BHHs}}c.E.EKHa
  ==66 	

7#  s   4Bc                J   g }d}|t        |       k  rd}d}d}|rh|t        |       k\  rt        d|       t        | |         dz
  }||dz  d|z  z  z  }t        |dz        }|dz  }|dz  }|s|d	z  r|d
d|z  z  z  }|rh|j	                  |       |t        |       k  r|S )u0  Decode a COCO base-48 string to raw (delta-encoded) integers.

    Implements the variable-length base-48 codec from the COCO API
    (pycocotools). Each integer is encoded across one or more 6-bit
    characters: bits 0-4 carry data; bit 5 signals continuation; bit 4
    of the final character signals a negative value.

    This is the pure codec layer — call :func:`_delta_decode` on the
    result to obtain absolute run-length counts.

    Args:
        s: COCO compressed RLE string.

    Returns:
        Raw delta-encoded integers, one per run.

    Raises:
        ValueError: If the string is truncated mid-integer.

    Examples:
        ```pycon
        >>> from supervision.detection.utils.converters import _base48_decode
        >>> _base48_decode("52203")
        [5, 2, 2, 0, 3]

        ```
    r   Tz<Malformed compressed RLE string: unexpected end at position 0             r      rD   )len
ValueErrorordrU   append)svaluesrZ   xkmorecs          r   _base48_decoderv   L  s    8 F	A
c!f*CF{ RSTRUV  AaD	BA!d(A&&AD>DFAFAQXRAE]"  	a! c!f*" Mr   c                    g }| D ]G  }d}|s|dz  }|dz  }|dz  r|dk7  n|dk7  }|r|dz  }|j                  t        |dz                |r@I d	j                  |      S )
ar  Encode raw (delta-encoded) integers to a COCO base-48 string.

    The inverse of :func:`_base48_decode`. Applies the same variable-length
    base-48 codec used by pycocotools.

    Apply :func:`_delta_encode` to absolute run-length counts before calling
    this function to produce a valid COCO compressed RLE string.

    Args:
        values: Raw (delta-encoded) integers to encode.

    Returns:
        COCO base-48 encoded string.

    Examples:
        ```pycon
        >>> from supervision.detection.utils.converters import _base48_encode
        >>> _base48_encode([5, 2, 2, 0, 3])
        '52203'

        ```
    Trh   ri   rk   rD   r   rj   rg    )ro   chrjoin)rq   charsrr   rt   ru   s        r   _base48_encoder|   ~  s|    . E &DA!GA!"TAGaDT	LLQV% & 775>r   c                v    t        |       }t        dt        |            D ]  }||xx   ||dz
     z  cc<    |S )a  Undo COCO delta encoding: ``counts[i] += counts[i - 2]`` for ``i > 2``.

    The COCO compressed RLE format stores run lengths as deltas relative to
    the count two positions earlier (starting at index 3). This function
    converts those relative values back to absolute run lengths.

    Args:
        values: Raw delta-encoded integers from :func:`_base48_decode`.

    Returns:
        Absolute run-length counts (alternating background / foreground).

    Examples:
        ```pycon
        >>> from supervision.detection.utils.converters import _delta_decode
        >>> _delta_decode([5, 2, 2, 0, 3])
        [5, 2, 2, 2, 5]

        ```
    r   r	   listrangerl   )rq   countsrZ   s      r   _delta_decoder     sB    * &\F1c&k" #q	VAE]"	#Mr   c                r    t        |       }t        dt        |            D ]  }| |   | |dz
     z
  ||<    |S )aT  Apply COCO delta encoding: ``d[i] = counts[i] - counts[i - 2]`` for ``i > 2``.

    The inverse of :func:`_delta_decode`. Converts absolute run lengths to
    the relative representation required by the COCO compressed RLE format.

    Args:
        counts: Absolute run-length counts (alternating background / foreground).

    Returns:
        Delta-encoded integers ready for :func:`_base48_encode`.

    Examples:
        ```pycon
        >>> from supervision.detection.utils.converters import _delta_encode
        >>> _delta_encode([5, 2, 2, 2, 5])
        [5, 2, 2, 0, 3]

        ```
    r   r	   r~   )r   deltasrZ   s      r   _delta_encoder     sF    ( &\F1c&k" .1Iq1u-q	.Mr   c                .    t        | t        t        f      S )u  Return ``True`` if ``rle`` is a COCO compressed RLE (``str`` or ``bytes``).

    Use this to branch between the compressed-string pipeline
    (:func:`_base48_decode` → :func:`_delta_decode`) and the uncompressed
    integer-list / array pipeline before calling :func:`rle_to_mask`.

    Args:
        rle: Candidate RLE value to inspect.

    Returns:
        ``True`` for ``str`` or ``bytes`` inputs; ``False`` otherwise.

    Examples:
        ```pycon
        >>> from supervision.detection.utils.converters import is_compressed_rle
        >>> is_compressed_rle("52203")
        True
        >>> is_compressed_rle([5, 2, 2, 2, 5])
        False

        ```
    )
isinstancestrbytes)rles    r   is_compressed_rler     s    . cC<((r   c                   t        j                  | t         j                        j                  d      }t	        |      dk(  r&t        j
                  dgt         j                        S t        j                  |j                  t         j                              }t        j                  |dk7        d   dz   }t        j                  dg|t	        |      gf      }t        j                  |      j                  t         j                        }|d   r+t        j                  t        j                  d      g|f      }|S )ab  Encode a 2D boolean mask as COCO F-order run lengths (int32 array).

    Pixels are scanned column-by-column (Fortran order), matching the COCO /
    pycocotools RLE convention. The first value is always the count of leading
    ``False`` pixels (may be 0 if the mask starts with ``True``).

    This is the shared low-level encoder used by both :func:`mask_to_rle` and
    :class:`~supervision.detection.compact_mask.CompactMask`.

    Args:
        mask_2d: 2D boolean array of shape ``(H, W)``.

    Returns:
        int32 array of run lengths starting with the False count.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> from supervision.detection.utils.converters import _mask_to_rle_counts
        >>> mask = np.array([[False, True], [True, False]])
        >>> _mask_to_rle_counts(mask).tolist()
        [1, 2, 1]

        ```
    r
   Forderr   r   )r   asarrayrG   ravelrl   arrayr   diffviewr   r0   concatenater   )mask_2dflatchanges
boundaries	positionsrun_lengthss         r   _mask_to_rle_countsr     s    4 ::gRXX.4434?D
4yA~xx288,,ggdii)*G'Q,'*Q.JZ#d)=>I'')$++BHH5KAwnnrxx{m[%ABr   c                d   t        j                  t        |             dz  dk(  }t        j                  ||       }||z  }t        |      |k  r$t        j                  |d|t        |      z
  f      }t        t        j                  t         j                     |d| j                  ||d            S )a  Decode COCO F-order run lengths back to a 2D boolean mask.

    This is the shared low-level decoder used by both :func:`rle_to_mask` and
    :class:`~supervision.detection.compact_mask.CompactMask`.

    Args:
        rle: int32 array of run lengths as produced by :func:`_mask_to_rle_counts`.
        height: Height of the output mask.
        width: Width of the output mask.

    Returns:
        2D boolean array of shape ``(height, width)``.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> from supervision.detection.utils.converters import _rle_counts_to_mask
        >>> rle = np.array([0, 1, 2, 1], dtype=np.int32)
        >>> _rle_counts_to_mask(rle, 2, 2)
        array([[ True, False],
               [False,  True]])

        ```
    r	   r   r   Nr   r   )
r   arangerl   repeatpadr   rE   rF   rG   reshape)r   r    r   is_truer   
num_pixelss         r   _rle_counts_to_maskr     s    6 iiC!A%*G"$))GS"9D%J
4y:vvdQ
SY 678BHHtKZ088c8R r   c                   t        | t              r| j                  d      } t        | t              r8t	        j
                  t        t        |             t        j                        }n[t        | t              r&t	        j
                  | t        j                        }n%t	        j                  | t        j                        }|\  }}||z  t	        j                  |      k7  rt        d      t        |||      S )u  
    Converts a COCO run-length encoding (RLE) to a binary mask.

    Implements the COCO RLE format used by ``pycocotools``: pixels are counted
    in **column-major (Fortran) order** — top-to-bottom within each column,
    left-to-right across columns. This is the opposite of the row-major order
    used by NumPy's default ``'C'`` layout. Passing RLE data produced by a
    different row-major convention will yield an incorrect mask.

    Args:
        rle: The COCO RLE data in one of the following formats:

            - A 1D array or list of integers (uncompressed COCO RLE, where
              values at even indices are background run-lengths and values at
              odd indices are foreground run-lengths, both counted column-major).
            - A compressed COCO RLE string or bytes, as produced by
              ``pycocotools.mask.encode``.
        resolution_wh: The width (w) and height (h)
            of the desired binary mask.

    Returns:
        The generated 2D Boolean mask of shape `(h, w)`, where the foreground object is
            marked with `True`'s and the rest is filled with `False`'s.

    Raises:
        ValueError: If the sum of pixels encoded in RLE differs from the
            number of pixels in the expected mask (computed based on resolution_wh).

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> mask = sv.rle_to_mask([5, 2, 2, 2, 5], (4, 4))
        >>> mask  # doctest: +NORMALIZE_WHITESPACE
        array([[False, False, False, False],
               [False,  True,  True, False],
               [False,  True,  True, False],
               [False, False, False, False]])

        >>> mask = sv.rle_to_mask("52203", (4, 4))
        >>> mask  # doctest: +NORMALIZE_WHITESPACE
        array([[False, False, False, False],
               [False,  True,  True, False],
               [False,  True,  True, False],
               [False, False, False, False]])

        ```
    zutf-8r
   zhthe sum of the number of pixels in the RLE must be the same as the number of pixels in the expected mask)r   r   decoder   r   r   r   rv   r   r   r   sumrm   r   )r   r   r   r   r    s        r   rle_to_maskr   ?  s    h #ujj!#s(*.-.bhh)
 
C	#RXX.Crxx0!ME6v~';
 	

 vvu55r   c                    | j                   dk(  sJ d       | j                  dk7  sJ d       t        t        t           t        |       j                               }|rt        t        |            S |S )u  
    Converts a binary mask into a COCO run-length encoding (RLE).

    Produces RLE in the COCO format used by ``pycocotools``: pixels are counted
    in **column-major (Fortran) order** — top-to-bottom within each column,
    left-to-right across columns. The output is directly compatible with
    ``pycocotools.mask.decode`` and COCO annotation JSON files.

    Args:
        mask: 2D binary mask where `True` indicates foreground
            object and `False` indicates background.
        compressed: If ``True``, return a compressed COCO RLE string
            compatible with ``pycocotools``. If ``False`` (default),
            return a list of integers.

    Returns:
        The COCO run-length encoded mask. When ``compressed`` is ``False``,
            values of a list with even indices represent the number of pixels
            assigned as background (`False`), values of a list with odd indices
            represent the number of pixels assigned as foreground object (`True`),
            both counted in column-major order.
            When ``compressed`` is ``True``, a COCO compressed RLE string.

    Raises:
        AssertionError: If input mask is not 2D or is empty.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> mask = np.array([
        ...     [True, True, True, True],
        ...     [True, True, True, True],
        ...     [True, True, True, True],
        ...     [True, True, True, True],
        ... ])
        >>> rle = sv.mask_to_rle(mask)
        >>> [int(x) for x in rle]
        [0, 16]

        ```

        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> mask = np.array([
        ...     [False, False, False, False],
        ...     [False, True,  True,  False],
        ...     [False, True,  True,  False],
        ...     [False, False, False, False],
        ... ])
        >>> rle = sv.mask_to_rle(mask)
        >>> [int(x) for x in rle]
        [5, 2, 2, 2, 5]

        >>> sv.mask_to_rle(mask, compressed=True)
        '52203'

        ```

    ![mask_to_rle](https://media.roboflow.com/supervision-docs/
    mask-to-rle.png){ align=center width="800" }
    r	   zInput mask must be 2Dr   zInput mask cannot be empty)	ndimr1   r   r   r   r   tolistr|   r   )r!   
compressedr   s      r   mask_to_rler     sh    D 99>222>99>777>T#Y(;D(A(H(H(JKFmF344Mr   c                    t        j                  | d      \  }}t        j                  | d      \  }}t        j                  ||||g      S )ag  
    Converts a polygon represented by a NumPy array into a bounding box.

    Args:
        polygon: A polygon represented by a NumPy array of shape `(N, 2)`,
            containing the `x`, `y` coordinates of the points.

    Returns:
        A 1D NumPy array containing the bounding box
            `(x_min, y_min, x_max, y_max)` of the input polygon.
    r   rB   )r   rX   rW   r   )r   rO   rQ   rP   rR   s        r   polygon_to_xyxyr     sD     66'*LE566'*LE588UE5%011r   )r   npt.NDArray[np.number]returnr   )r   r   r   tuple[int, int]r   znpt.NDArray[np.uint8])r&   r   r   r   )r'   r   r   r   )r,   r   r   r   )r'   r   r   znpt.NDArray[np.floating])rK   npt.NDArray[np.bool_]r   znpt.NDArray[np.int_])rY   r   r   r   r   r   )r!   r   r   zlist[npt.NDArray[np.int32]])rp   r   r   	list[int])rq   r   r   r   )rq   r   r   r   )r   r   r   r   )r   objectr   rU   )r   znpt.NDArray[Any]r   npt.NDArray[np.int32])r   r   r    r   r   r   r   r   )r   z6npt.NDArray[np.integer[Any]] | list[int] | str | bytesr   r   r   r   )F)r!   r   r   rU   r   zlist[int] | str)r   r   r   r   )
__future__r   typingr   r   r   numpyr   numpy.typingrE   r`   r   r"   r(   r*   r-   r@   rS   r[   re   rv   r|   r   r   r   r   r   r   r   r    r   r   <module>r      s   "  
   &#" *BD!H, ^+\8!82A88v2/d!H64)4&R"	"(+"47""JG6	?G6"G6 G6V 5:H
H-1HHV2r   