
    ܙd9                         d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
mZmZ d dlmZmZ ed             Z G d de          Zed	k    r ej                     dS dS )
    N)contextmanager)jitgenerated_jit	vectorizeguvectorize)NumbaDeprecationWarningNumbaPendingDeprecationWarningNumbaWarning)TestCaseneeds_setuptoolsc               #      K   t          j        d          5 } t          j        dt                     t          j        dt                     | V  d d d            d S # 1 swxY w Y   d S )NTrecordignorecategoryalways)warningscatch_warningssimplefilterr
   r   )ws    =lib/python3.11/site-packages/numba/tests/test_deprecations.py!_catch_numba_deprecation_warningsr      s      		 	-	-	- h>>>>h1HIIII                 s   ;A  A$'A$c                      e Zd Zd Zej        d             Zej        d             Zej        d             Zej        d             Z	ej        d             Z
ej        d             Zej        d             Zej        d	             Zej        d
             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Zeej        d                         Zeej        d                         ZdS )TestDeprecationc                 F   |                      t          |          d           |                      |d         j        |           |                     |t	          |d         j                             |                     dt	          |d         j                             d S )N   r   https://numba.readthedocs.io)assertEquallenr   assertInstrmessage)selfr   expected_strr   s       r   check_warningzTestDeprecation.check_warning   s    X***!-x888lC(;$<$<===4c(1+:M6N6NOOOOO    c                     t                      5 }t          j        ddt                     d } t	          |                       d}|                     ||t                     d d d            d S # 1 swxY w Y   d S )Nr   z4.*The 'nopython' keyword argument was not supplied.*)r#   r   c                      g S N r+   r'   r   fooz-TestDeprecation.test_jitfallback.<locals>.foo&   s    	r'   PFall-back from the nopython compilation path to the object mode compilation path)r   r   filterwarningsr   r   r&   r$   r   r,   msgs       r   test_jitfallbackz TestDeprecation.test_jitfallback   s     /00 	@A#H.L-DG G G G
  CHHJJJ+C q#'>???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   AA11A58A5c                     t                      5 }t          d             } |             d}|                     ||t                     d d d            d S # 1 swxY w Y   d S )Nc                      d S r*   r+   r+   r'   r   r,   z@TestDeprecation.test_default_missing_nopython_kwarg.<locals>.foo5       r'   0The 'nopython' keyword argument was not suppliedr   r   r&   r   r/   s       r   #test_default_missing_nopython_kwargz3TestDeprecation.test_default_missing_nopython_kwarg/   s     /00 		@A  S CEEEDCq#'>???		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@s   9AAAc                     t                      5 }t          d          d             } |             d}|                     ||t                     d d d            d S # 1 swxY w Y   d S )NFnopythonc                      d S r*   r+   r+   r'   r   r,   z?TestDeprecation.test_explicit_false_nopython_kwarg.<locals>.fooE   r4   r'   2The keyword argument 'nopython=False' was suppliedr6   r/   s       r   "test_explicit_false_nopython_kwargz2TestDeprecation.test_explicit_false_nopython_kwarg>   s    
 /00 		@A%     !  CEEEFCq#'>???		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@ 		@s   AAA"%A"c                     t                      5 }t          d          d             } |             d d d            n# 1 swxY w Y   |                     |           d S )NTforceobjc                  "    t                       d S r*   objectr+   r'   r   r,   zSTestDeprecation.test_default_missing_nopython_kwarg_silent_if_forceobj.<locals>.fooU   s    r'   )r   r   assertFalser$   r   r,   s      r   6test_default_missing_nopython_kwarg_silent_if_forceobjzFTestDeprecation.test_default_missing_nopython_kwarg_silent_if_forceobjN   s    
 /00 	A$    CEEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $?AAc                     t                      5 }t          d          d             }d d d            n# 1 swxY w Y   |                     |           d S )Nfloat64(float64)c                     | dz   S Nr   r+   as    r   r,   zOTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reported.<locals>.fooe       1ur'   r   r   rD   rE   s      r   2test_vectorize_missing_nopython_kwarg_not_reportedzBTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reported^   s    
 /00 	A)**  +*	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   488c                     t                      5 }t          dd          d             }d d d            n# 1 swxY w Y   d}|                     ||t                     d S )NrH   Fr9   c                     | dz   S rJ   r+   rK   s    r   r,   zFTestDeprecation.test_vectorize_nopython_false_is_reported.<locals>.foor   rM   r'   r<   r   r   r&   r   r/   s       r   )test_vectorize_nopython_false_is_reportedz9TestDeprecation.test_vectorize_nopython_false_is_reportedk   s    
 /00 	A)E:::  ;:	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 C1c#:;;;;;   6::c                     t                      5 }t          d          d             }d d d            n# 1 swxY w Y   d}|                     ||t                     d S )NrH   c                 (    t                       | dz   S rJ   rB   rK   s    r   r,   zWTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reported.<locals>.foo       1ur'   r-   rS   r/   s       r   :test_vectorize_objmode_missing_nopython_kwarg_not_reportedzJTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reportedy   s     /00 	A)**  +*	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'1c#:;;;;;rP   c                 `   t                      5 }t          dd          d             }d d d            n# 1 swxY w Y   |                     t          |          d           d}|                     |d         g|t
                     d}|                     |d	         g|t
                     d S )
NrH   Fr9   c                 (    t                       | dz   S rJ   rB   rK   s    r   r,   zNTestDeprecation.test_vectorize_objmode_nopython_false_is_reported.<locals>.foo   rX   r'      r<   r   r-   r   )r   r   r   r    r&   r   r/   s       r   1test_vectorize_objmode_nopython_false_is_reportedzATestDeprecation.test_vectorize_objmode_nopython_false_is_reported   s     /00 	A )E:::  ;:		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Q###BAaD63(?@@@'AaD63(?@@@@@rU   c                     t                      5 }t          dd          d             }d d d            n# 1 swxY w Y   |                     |           d S )NrH   Tr?   c                 (    t                       | dz   S rJ   rB   rK   s    r   r,   zRTestDeprecation.test_vectorize_objmode_direct_compilation_no_warnings.<locals>.foo   rX   r'   rN   rE   s      r   5test_vectorize_objmode_direct_compilation_no_warningszETestDeprecation.test_vectorize_objmode_direct_compilation_no_warnings   s     /00 	A)D999  :9	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rU   c                     t                      5 }t          ddd          d             }d d d            n# 1 swxY w Y   |                     |           d S )NrH   TF)r@   r:   c                 (    t                       | dz   S rJ   rB   rK   s    r   r,   zZTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warnings.<locals>.foo   rX   r'   rN   rE   s      r   =test_vectorize_objmode_compilation_nopython_false_no_warningszMTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warnings   s    
 /00 	A)D5III  JI	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   7;;c                     t                      5 }t          dd          d             }d d d            n# 1 swxY w Y   |                     |           d S )NrH   paralleltargetc                     | dz   S rJ   r+   xs    r   r,   zETestDeprecation.test_vectorize_parallel_true_no_warnings.<locals>.foo   rM   r'   rN   rE   s      r   (test_vectorize_parallel_true_no_warningsz8TestDeprecation.test_vectorize_parallel_true_no_warnings   s    
 /00 	A)*===  >=	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	rU   c                     t                      5 }t          ddd          d             }d d d            n# 1 swxY w Y   |                     |           d S )NrH   rf   Trh   r:   c                     | dz   S rJ   r+   rj   s    r   r,   zSTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warnings.<locals>.foo   rM   r'   rN   rE   s      r   6test_vectorize_parallel_true_nopython_true_no_warningszFTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warnings   s     /00 	A)*tLLL  ML	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	rd   c                     t                      5 }t          ddd          d             }d d d            n# 1 swxY w Y   d}|                     ||t                     d S )NrH   rf   Frn   c                     | dz   S rJ   r+   rj   s    r   r,   zNTestDeprecation.test_vectorize_parallel_true_nopython_false_warns.<locals>.foo   rM   r'   r<   rS   r/   s       r   1test_vectorize_parallel_true_nopython_false_warnszATestDeprecation.test_vectorize_parallel_true_nopython_false_warns   s     /00 	A)*uMMM  NM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 C1c#:;;;;;rd   c                    t                      5 }t          dd          fd            }d d d d            n# 1 swxY w Y   |                     |           t                      5 }t          dd          fd            }t          d             d d d            n# 1 swxY w Y   d}|                     ||t
                     d S )	NrH   Tr?   c                       | dz             S rJ   r+   rk   bars    r   r,   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.foo       s1q5zz!r'   c                      d S r*   r+   )argss    r   rw   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.bar   s    r'   c                       | dz             S rJ   r+   rv   s    r   r,   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.foo   rx   r'   c                     | S r*   r+   rj   s    r   rw   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.bar   s    r'   r5   )r   r   rD   r   r&   r   )r$   r   r,   r0   rw   s       @r   =test_vectorize_calling_jit_with_nopython_false_warns_from_jitzMTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit   s    /00 	A)D999" " " " :9"  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 /00 	A)D999" " " " :9"   S	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 A1c#:;;;;;s!    <A A *-B##B'*B'c                     t                      5 }t          dd          d             }d d d            n# 1 swxY w Y   |                     |           d S )N void(float64[::1], float64[::1])(n)->(n)c                     | dz  } d S rJ   r+   rL   bs     r   rw   zKTestDeprecation.test_guvectorize_implicit_nopython_no_warnings.<locals>.bar  s    Qr'   r   r   rD   r$   r   rw   s      r   .test_guvectorize_implicit_nopython_no_warningsz>TestDeprecation.test_guvectorize_implicit_nopython_no_warnings  s     /00 	A;ZHH  IH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   599c                     t                      5 }t          ddd          d             }d d d            n# 1 swxY w Y   |                     |           d S )Nr   r   Tr?   c                 ,    t                       | dz  } d S rJ   rB   r   s     r   rw   zBTestDeprecation.test_guvectorize_forceobj_no_warnings.<locals>.bar       Qr'   r   r   s      r   %test_guvectorize_forceobj_no_warningsz5TestDeprecation.test_guvectorize_forceobj_no_warnings  s     /00 	A;Z"&( ( ( ( (		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rd   c                     t                      5 }t          ddd          d             }d d d            n# 1 swxY w Y   |                     |           d S )Nr   r   rf   rg   c                     | dz  } d S rJ   r+   r   s     r   rw   zTTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warnings.<locals>.bar!  s     Qr'   r   r   s      r   7test_guvectorize_parallel_implicit_nopython_no_warningszGTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warnings  s     /00 	A;Z *, , , , ,		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rd   c                     t                      5 }t          dddd          d             }d d d            n# 1 swxY w Y   |                     |           d S )Nr   r   rf   T)rh   r@   c                 ,    t                       | dz  } d S rJ   rB   r   s     r   rw   zKTestDeprecation.test_guvectorize_parallel_forceobj_no_warnings.<locals>.bar0  r   r'   r   r   s      r   .test_guvectorize_parallel_forceobj_no_warningsz>TestDeprecation.test_guvectorize_parallel_forceobj_no_warnings(  s     /00 	A ;Z *T; ; ; ; ;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   8<<c                    d }d }||fD ]g}|j                             d          } t          |          dg          }t          j        d          5 }t          j        dt                     t          j        d	t                       t          d
          |          |           | 	                    t          |          d           | 	                    |d         j        t                     t          |d         j                  }d}|                     ||           d|z  }|                     ||           |                     d|           d d d            n# 1 swxY w Y   id S )Nc                 ,    |                      d          S rJ   )appendrK   s    r   foo_listzFTestDeprecation.test_reflection_of_mutable_container.<locals>.foo_list;  s    88A;;r'   c                 ,    |                      d          S rJ   )addrK   s    r   foo_setzETestDeprecation.test_reflection_of_mutable_container.<locals>.foo_set>  s    5588Or'   foo_
   Tr   r   r   r   r9   r   r   z?Encountered the use of a type that is scheduled for deprecationz!'reflected %s' found for argumentr   )__name__stripevalr   r   r   r
   r	   r   r   r    r   r"   r#   r!   )	r$   r   r   f	containerinpr   warn_msgr0   s	            r   $test_reflection_of_mutable_containerz4TestDeprecation.test_reflection_of_mutable_container8  s   	 	 		 	 	 G$ 	H 	HA
((00I!$y//2&))C(555 H%hFFFF%h/MO O O O%"T"""1%%c***  Q+++  10NOOOqt|,,%c8,,,<yHc8,,,<hGGGH H H H H H H H H H H H H H H	H 	Hs   DE''E+	.E+	c                     t                      5 }t          d             t          d          fd            } |             |                     |dt                     d d d            d S # 1 swxY w Y   d S )Nc                      d S )Nc                      d S r*   r+   r+   r'   r   <lambda>zATestDeprecation.test_generated_jit.<locals>.bar.<locals>.<lambda>Z  s     r'   r+   r+   r'   r   rw   z/TestDeprecation.test_generated_jit.<locals>.barX  s
    $}$r'   Tr9   c                                     d S r*   r+   )rw   s   r   r,   z/TestDeprecation.test_generated_jit.<locals>.foo\  s    r'   z!numba.generated_jit is deprecated)r   r   r   r&   r   )r$   r   r,   rw   s      @r   test_generated_jitz"TestDeprecation.test_generated_jitS  s     /00 	8A% % ]% $      CEEEq"E68 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   AA//A36A3c                     t          j        d          5 }t          j        dt                     dd l}d}|                     ||t                     d d d            d S # 1 swxY w Y   d S )NTr   r   r   r   )The 'pycc' module is pending deprecation.)r   r   r   r	   
numba.pyccr&   )r$   r   numbar%   s       r   test_pycc_modulez TestDeprecation.test_pycc_modulee  s    
 $D111 	PQ!(+IK K K KGLq,0NOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   >A!!A%(A%c                     t          j        d          5 }t          j        dt                     ddlm} d}|                     ||t                     d d d            d S # 1 swxY w Y   d S )NTr   r   r   r   )CCr   )r   r   r   r	   r   r   r&   )r$   r   r   r%   s       r   test_pycc_CCzTestDeprecation.test_pycc_CCr  s    
 $D111 	PQ!(+IK K K K%%%%%%GLq,0NOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   A A##A'*A'N)r   
__module____qualname__r&   r   run_test_in_subprocessr1   r7   r=   rF   rO   rT   rY   r]   r`   rc   rl   rp   rs   r}   r   r   r   r   r   r   r   r   r   r+   r'   r   r   r      s       P P P $@ @ %$@& $@ @ %$@ $@ @ %$@ $  %$ $
 
 %$
 $< < %$< $< < %$<  $A A %$A0 $
 
 %$
 $  %$ $	 	 %$	 $  %$ $	< 	< %$	< $< < %$<> $	 	 %$	 $  %$ $
 
 %$
 $  %$ $H H %$H4 $8 8 %$8" $	P 	P %$ 	P $	P 	P %$ 	P 	P 	Pr'   r   __main__)r   unittest
contextlibr   r   r   r   r   r   numba.core.errorsr   r	   r
   numba.tests.supportr   r   r   r   r   mainr+   r'   r   <module>r      s     % % % % % % < < < < < < < < < < < <M M M M M M M M M M : : : : : : : :   jP jP jP jP jPh jP jP jPZ zHMOOOOO r'   