
    9ii                         S SK Jr  S SKrS SKrS SKrS SKrS SKr/ SQr\R                  " \R                  SS9r	\S 5       r
\S 5       rg)    )contextmanagerN)all_warningsexpected_warningswarn   )
stacklevelc               #     #    SSK n U R                  5       nU(       a*  U R                  U5       H  n0 US   R                  S'   M     A[	        [
        R                  R                  5       5       H   u  p4 UR                  R                  5         M"     [        R                  " SS9 n[        R                  " S5        Uv   SSS5        g! [         a     Mi  f = f! , (       d  f       g= f7f)a  
Context for use in testing to ensure that all warnings are raised.

Examples
--------
>>> import warnings
>>> def foo():
...     warnings.warn(RuntimeWarning("bar"), stacklevel=2)

We raise the warning once, while the warning filter is set to "once".
Hereafter, the warning is invisible, even with custom filters:

>>> with warnings.catch_warnings():
...     warnings.simplefilter('once')
...     foo()                         # doctest: +SKIP

We can now run ``foo()`` without a warning being raised:

>>> from numpy.testing import assert_warns
>>> foo()                             # doctest: +SKIP

To catch the warning, we call in the help of ``all_warnings``:

>>> with all_warnings():
...     assert_warns(RuntimeWarning, foo)
r   N__warningregistry__T)recordalways)inspectcurrentframegetouterframesf_localslistsysmodulesitemsr
   clearAttributeErrorwarningscatch_warningssimplefilter)r   framefmod_namemodws         Y/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/_shared/_warnings.pyr   r      s     <    "E''.A35AaDMM/0 /ckk//12	##))+ 3 
	 	 	-h' 
.	-  		 
.	-sB   A3C.6CC.(C	C.
CC.CC.
C+'C.c           	   #     #    [        U [        5      (       a  [        S5      eU c  Sv   g[        R                  R                  SS5      nUR                  5       S:X  a  SnO+UR                  5       S:X  a  SnO[        [        U5      5      n[        5        nUv   SU ;   a  U R                  S5        SU ;   a  M  U  Vs/ s H  nS	UR                  S
5      ;  d  M  UPM     nnU H  nSnU  HJ  n[        R                  " U[        UR                  5      5      c  M0  SnXt;   d  M9  UR                  U5        ML     U(       d  M^  U(       a  Mg  [        S[        UR                  5       35      e   U(       a2  [        U5      S:  a#  SnSU UR!                  U5       3n	[        U	5      eSSS5        gs  snf ! , (       d  f       g= f7f)a  Context for use in testing to catch known warnings matching regexes

Parameters
----------
matching : None or a list of strings or compiled regexes
    Regexes for the desired warning to catch
    If matching is None, this behaves as a no-op.

Examples
--------
>>> import numpy as np
>>> rng = np.random.default_rng()
>>> image = rng.integers(0, 2**16, size=(100, 100), dtype=np.uint16)
>>> # rank filters are slow when bit-depth exceeds 10 bits
>>> from skimage import filters
>>> with expected_warnings(['Bad rank filter performance']):
...     median_filtered = filters.rank.median(image)

Notes
-----
Uses `all_warnings` to ensure all warnings are raised.
Upon exiting, it checks the recorded warnings for the desired matching
pattern(s).
Raises a ValueError if any match was not found or an unexpected
warning was raised.
Allows for three types of behaviors: `and`, `or`, and `optional` matches.
This is done to accommodate different build environments or loop conditions
that may produce different warnings.  The behaviors can be combined.
If you pass multiple patterns, you get an orderless `and`, where all of the
warnings must be raised.
If you use the `|` operator in a pattern, you can catch one of several
warnings.
Finally, you can use `|\A\Z` in a pattern to signify it as optional.

zA``matching`` should be a list of strings and not a string itself.NSKIMAGE_TEST_STRICT_WARNINGS1trueTfalseFz\A\Z|zUnexpected warning: r   
zNo warning raised matching:)
isinstancestr
ValueErrorosenvirongetlowerboolintr   removesplitresearchmessagelenjoin)
matchingstrict_warningsr   m	remainingr   foundmatchnewlinemsgs
             r   r   r   J   s    J (C  R
 	

 
jjnn%CSIO&(				 G	+s?34	1 hOOD! h (H1G1773<,GQ	HDE!99UC$56B E)!((/	 "
 uu #7DLL8I7J!KLL  I 2G/yi9P8QRCS/!) 
 I 
sU   BG"F7;F7?F2F2"7F7F7&F7F7AF7)	G2F77
GG)
contextlibr   r   r   r2   	functoolsr*   __all__partialr   r   r        r   <module>rE      s_    % 
  	  	
7
 15 6 6r J" J"rD   