ó
    Eñi(  ã                   ó*   • S SK rSS jr " S S5      rg)é    Nc                 óx  • SSK Jn  [        R                  " U R                  [        R
                  5      (       d  [        S5      eU R                  nU R                  S5      n Uc  [        R                  " XRR                  S9nO,UR                  U:w  a  [        SU SUR                   S35      e UR                  5       nS	Ul        UR                  U R                  SS9nUR                  UR                  SS9nU" XX5        U$ ! [         a'    [        S
UR                   SUR                   S35      ef = f)a…  Map values from input array from input_vals to output_vals.

Parameters
----------
input_arr : array of int, shape (M[, ...])
    The input label image.
input_vals : array of int, shape (K,)
    The values to map from.
output_vals : array, shape (K,)
    The values to map to.
out : array, same shape as `input_arr`
    The output array. Will be created if not provided. It should
    have the same dtype as `output_vals`.

Returns
-------
out : array, same shape as `input_arr`
    The array of mapped values.

Notes
-----
If `input_arr` contains values that aren't covered by `input_vals`, they
are set to 0.

Examples
--------
>>> import numpy as np
>>> import skimage as ski
>>> ski.util.map_array(
...    input_arr=np.array([[0, 2, 2, 0], [3, 4, 5, 0]]),
...    input_vals=np.array([1, 2, 3, 4, 6]),
...    output_vals=np.array([6, 7, 8, 9, 10]),
... )
array([[0, 7, 7, 0],
       [8, 9, 0, 0]])
é   )Ú
_map_arrayz7The dtype of an array to be remapped should be integer.éÿÿÿÿ©ÚdtypezbIf out array is provided, it should have the same shape as the input array. Input array has shape z", provided output array has shape Ú.)r   z`If out array is provided, it should be either contiguous or 1-dimensional. Got array with shape z and strides F©Úcopy)Ú_remapr   ÚnpÚ
issubdtyper   ÚintegerÚ	TypeErrorÚshapeÚreshapeÚemptyÚ
ValueErrorÚviewÚAttributeErrorÚstridesÚastype)Ú	input_arrÚ
input_valsÚoutput_valsÚoutr   Ú
orig_shapeÚout_views          ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/skimage/util/_map_array.pyÚ	map_arrayr       s6  € õJ #ä�=Š=˜Ÿ™¬"¯*©*×5Ñ5ÜÐQÓRÐRà—‘€Jð ×!Ñ! "Ó%€IØ
�{Ü�hŠh�z×):Ñ):Ñ;‰Ø	�‰�jÓ	 Üð6Ø6@°\ð B&Ø&)§i¡i [°ð3ó
ð 	
ð

Ø—8‘8“:ˆØˆŒð ×"Ñ" 9§?¡?¸Ð"Ð?€JØ×$Ñ$ S§Y¡Y°UÐ$Ð;€KÙˆy JÔ<Ø€Jøô ó 
Üð6Ø69·i±i°[ð AØ—{‘{�m 1ð&ó
ð 	
ð
ús   Â2D Ä1D9c                   ó\   • \ rS rSrSrS rS rSS jr\S 5       r	S r
S	 rS
 rS rS rSrg)ÚArrayMapéL   uï  Class designed to mimic mapping by NumPy array indexing.

This class is designed to replicate the use of NumPy arrays for mapping
values with indexing:

>>> values = np.array([0.25, 0.5, 1.0])
>>> indices = np.array([[0, 0, 1], [2, 2, 1]])
>>> values[indices]
array([[0.25, 0.25, 0.5 ],
       [1.  , 1.  , 0.5 ]])

The issue with this indexing is that you need a very large ``values``
array if the values in the ``indices`` array are large.

>>> values = np.array([0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0])
>>> indices = np.array([[0, 0, 10], [0, 10, 10]])
>>> values[indices]
array([[0.25, 0.25, 1.  ],
       [0.25, 1.  , 1.  ]])

Using this class, the approach is similar, but there is no need to
create a large values array:

>>> in_indices = np.array([0, 10])
>>> out_values = np.array([0.25, 1.0])
>>> values = ArrayMap(in_indices, out_values)
>>> values
ArrayMap(array([ 0, 10]), array([0.25, 1.  ]))
>>> print(values)
ArrayMap:
  0 â†’ 0.25
  10 â†’ 1.0
>>> indices = np.array([[0, 0, 10], [0, 10, 10]])
>>> values[indices]
array([[0.25, 0.25, 1.  ],
       [0.25, 1.  , 1.  ]])

Parameters
----------
in_values : array of int, shape (K,)
    The source values from which to map.
out_values : array, shape (K,)
    The destination values from which to map.
c                 ó8   • Xl         X l        SU l        S U l        g )Né   )Ú	in_valuesÚ
out_valuesÚ_max_str_linesÚ_array)Úselfr&   r'   s      r   Ú__init__ÚArrayMap.__init__z   s   € Ø"ŒØ$ŒØˆÔØˆ�ó    c                 óH   • [         R                  " U R                  5      S-   $ )z<Return one more than the maximum label value being remapped.r   )r   Úmaxr&   ©r*   s    r   Ú__len__ÚArrayMap.__len__€   s   € ä�vŠv�d—n‘nÓ%¨Ñ)Ð)r-   Nc                 óÔ   • Uc  U R                   R                  n[        R                  " [        R                  " U R
                  5      S-   US9nU R                   X0R
                  '   U$ )z¤Return an array that behaves like the arraymap when indexed.

This array can be very large: it is the size of the largest value
in the ``in_vals`` array, plus one.
r   r   )r'   r   r   Úzerosr/   r&   )r*   r   r   Úoutputs       r   Ú	__array__ÚArrayMap.__array__„   sO   € ð ‰=Ø—O‘O×)Ñ)ˆEÜ—’œ"Ÿ&š& §¡Ó0°1Ñ4¸EÑBˆØ!%§¡ˆ�~‰~ÑØˆr-   c                 ó.   • U R                   R                  $ ©N)r'   r   r0   s    r   r   ÚArrayMap.dtype�   s   € à�‰×$Ñ$Ð$r-   c                 ó`   • S[        U R                  5       S[        U R                  5       S3$ )Nz	ArrayMap(z, Ú))Úreprr&   r'   r0   s    r   Ú__repr__ÚArrayMap.__repr__”   s+   € Øœ4 §¡Ó/Ð0°´4¸¿¹Ó3HÐ2IÈÐKÐKr-   c                 óÂ  • [        U R                  5      U R                  S-   ::  af  [        [        U R                  5      5      nSR	                  S/U Vs/ s H%  nSU R                  U    SU R
                  U    3PM'     sn-   5      nU$ [        [        SU R                  S-  5      5      n[        [        U R                  * S-  S5      5      nSR	                  S/U Vs/ s H%  nSU R                  U    SU R
                  U    3PM'     sn-   S/-   U Vs/ s H%  nSU R                  U    SU R
                  U    3PM'     sn-   5      nU$ s  snf s  snf s  snf )	Nr   Ú
z	ArrayMap:z  u    â†’ r   é   z  ...)Úlenr&   r(   ÚrangeÚjoinr'   Úlist)r*   ÚrowsÚiÚstringÚrows0Úrows1s         r   Ú__str__ÚArrayMap.__str__—   sj  € Üˆt�~‰~Ó $×"5Ñ"5¸Ñ"9Ó9Üœ˜TŸ^™^Ó,Ó-ˆDØ—Y‘YØ�ÙNRÓSÊdÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÓDÉdÑSñTóˆFð ˆô œ˜q $×"5Ñ"5¸Ñ":Ó;Ó<ˆEÜœ × 3Ñ 3Ð3°qÑ8¸!Ó<Ó=ˆEØ—Y‘YØ�ÙNSÓTÊeÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÓDÉeÑTñUà�)ññ OTÓTÊeÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÓDÉeÑTñUóˆFð ˆùò Tùò UùâTs   Á,E
Ã#,E
Ä,E
c                 ó$   • U R                  U5      $ r9   )Ú__getitem__)r*   Úarrs     r   Ú__call__ÚArrayMap.__call__©   s   € Ø×Ñ Ó$Ð$r-   c                 ó0  • [         R                  " U5      nU(       a  [         R                  " U/5      nOq[        U[        5      (       a\  UR
                  =(       d    SnUR                  b  UR                  O
[        U 5      nUR                  n[         R                  " X4U5      nUR                  [        :X  a  [         R                  " U5      n[        UU R                  R                  UR                  SS9U R                   5      nU(       a  US   nU$ )Nr   Fr
   )r   ÚisscalarÚarrayÚ
isinstanceÚsliceÚstartÚstoprC   ÚstepÚaranger   ÚboolÚflatnonzeror    r&   r   r'   )r*   ÚindexÚscalarrX   rY   rZ   r   s          r   rO   ÚArrayMap.__getitem__¬   sË   € Ü—’˜UÓ#ˆÞÜ—H’H˜e˜WÓ%‰EÜ˜œu×%Ñ%Ø—K‘K×$ 1ˆEØ!&§¡Ñ!7�5—:’:¼SÀ»YˆDØ—:‘:ˆDÜ—I’I˜e¨4Ó0ˆEØ�;‰;œ$ÓÜ—N’N 5Ó)ˆEäØØ�N‰N×!Ñ! %§+¡+°EÐ!Ð:Ø�O‰Oó
ˆö Ø�a‘&ˆCØˆ
r-   c                 óê   • U R                   c  U R                  5       U l         X R                   U'   [        R                  " U R                   5      U l        U R                   U R                     U l        g r9   )r)   r6   r   r]   r&   r'   )r*   ÚindicesÚvaluess      r   Ú__setitem__ÚArrayMap.__setitem__Â   sN   € Ø�;‰;ÑØŸ.™.Ó*ˆDŒKØ%�‰�GÑÜŸš¨¯©Ó4ˆŒØŸ+™+ d§n¡nÑ5ˆ�r-   )r)   r(   r&   r'   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   r1   r6   Úpropertyr   r>   rL   rQ   rO   rd   Ú__static_attributes__© r-   r   r"   r"   L   sE   † ñ+òZò*ô
ð ñ%ó ð%òLòò$%òõ,6r-   r"   r9   )Únumpyr   r    r"   rm   r-   r   Ú<module>ro      s   ðÛ ôE÷P{6ò {6r-   