
    J/Ph                          d dl Z d dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
 d dlmZmZmZ d Zd Zd Zd Zd	 Zd
 Zd Zd Z G d dee          Zedk    r ej                     dS dS )    N)jitnjit)typeserrorsutils)captured_stdoutTestCaseEnableNRTStatsMixinc                 $    t          |            d S Nprintxs    V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_print.pyprint_valuer      s    	!HHHHH    c                 :    t          | |         j                   d S r   )r   r   )arris     r   print_array_itemr      s    	#a&(OOOOOr   c                 (    t          | ||           d S r   r   abcs      r   print_valuesr      s    	!QNNNNNr   c                  "    t                       d S r   r    r   r   print_emptyr       s    	GGGGGr   c                 (    t          | dd           d S )Nhop!g      @r   r   s    r   print_stringr#      s    	!VSr   c                 "    t          | |g|R   d S r   r   r   s      r   print_varargr%      s    	!QOOOOOOOr   c                 $    t          | d|g|R   d S )Nr"   r   r   s      r   print_string_varargr'      s"    	!VQr   c                 @      fd} t          d                     S )Nc                       S r   r   r   s   r   print_closurez)make_print_closure.<locals>.print_closure!   s    r   Tnopython)r   )r   r*   s   ` r   make_print_closurer-       s7        3a   r   c                       e Zd Zd Zd Z ej        d          d             Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd ZdS )	TestPrintc                 2    t          |f          t                    }|D ]u}t                      5   ||           |                     t          j                                        t          |          dz              d d d            n# 1 swxY w Y   vd S )N
)r   r   r   assertEqualsysstdoutgetvaluestr)selftypvaluescfuncvals        r   check_valueszTestPrint.check_values(   s    cV[)) 	I 	IC "" I Ic


  !4!4!6!6C4HHHI I I I I I I I I I I I I I I	I 	Is   ABB	B	c                 0   |                      t          j        d           |                      t          j        d           |                      t          j        d           |                      t          j        d           |                      t          j        ddt          d          f           |                      t          j        d           |                      t          j	        d	          t          j        d
d	          f            t          t          j        f          t                    }t                      5   |d           t           j                                        }d}|                     |                    |                     |                     |                    d                     ddd           n# 1 swxY w Y   t          j        t          j        dd          } t          |f          t                    }t                      5   |t          j        dt          j                             |                     t           j                                        d           ddd           dS # 1 swxY w Y   dS )z8
        Test printing a single argument value.
        )   )r>   r?      g3/mlg3/m)r>      r@   l   {        )TFg      ?g@xDnan)y      ?      ?msd   g?z1.10000002384r1   Nr>   C
   dtypez[0 1 2 3 4 5 6 7 8 9]
)r<   r   int32int64uint64booleanfloat64float	complex64NPTimedeltanptimedelta64r   float32r   r   r3   r4   r5   
assertTrue
startswithendswithArrayaranger2   )r7   r:   gotexpect	arraytypes        r   test_print_valueszTestPrint.test_print_values/   s   
 	%+y111%+ (= 	> 	> 	> 	%, )J 	K 	K 	K%-777%-#{E%LL)IJJJ%/7333%+D11BN34M4M3OPPP&em%&&{33 	0 	0E#JJJ*%%''C$FOOCNN622333OOCLL..///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 KQ44	"i\"";// 	8 	8E")Bbh///000SZ002268 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s&   A<GGG"AJJJz,Issue with intermittent NRT leak, see #9355.c                 ,   |                                  5  g d}|                     |          5  |                     t          j        t          j        d          |f           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N)r>            T)	reflected)assertNoNRTLeakassertRefCountr<   r   Listintp)r7   r   s     r   test_print_nrt_typezTestPrint.test_print_nrt_typeP   s:    !!## 	P 	PA$$Q'' P P!!%*UZ4"H"H"H1$OOOP P P P P P P P P P P P P P P	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps4   B	6A1%B	1A5	5B	8A5	9B		BBc           	         t          j        dg          }t          j        t          t	          dd                    |          }t
          } t          d          |          }t	          t          |                    D ]}t                      5   |||           | 	                    t          j                                        t          ||         d                   dz              d	d	d	           n# 1 swxY w Y   d	S )
z:
        Test printing a Numpy character sequence
        )r   S4r>   	   rG   Tr+   r   r1   N)rQ   rH   
frombuffer	bytearrayranger   r   lenr   r2   r3   r4   r5   r6   )r7   rH   r   pyfuncr:   r   s         r   test_print_array_itemzTestPrint.test_print_array_item]   s<    +''mIeAqkk22%@@@!"T"""6**s3xx 	Q 	QA "" Q Qc1  !4!4!6!6CF3K8H8H48OPPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q	Q 	Qs   AC::C>	C>	c                 ,   t           } t          t          j        fdz            |          }t	                      5   |ddd           |                     t          j                                        d           d d d            d S # 1 swxY w Y   d S )Nr^   r>      1 2 3
)	r   r   r   re   r   r2   r3   r4   r5   r7   rn   r:   s      r   test_print_multiple_valuesz$TestPrint.test_print_multiple_valuesk   s    'ej]Q&''// 	? 	?E!QNNNSZ0022I>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   A B		BBc                    t           } t          dd          |          }t                      5   |ddd           |                     t          j                                        d           d d d            d S # 1 swxY w Y   d S )NT)r,   nogilr>   rq   r^   rr   )r   r   r   r2   r3   r4   r5   rs   s      r   test_print_nogilzTestPrint.test_print_nogilr   s    .T...v66 	? 	?E!QNNNSZ0022I>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   A A==BBc                 
   t           } t          d          |          }t                      5   |             |                     t          j                                        d           d d d            d S # 1 swxY w Y   d S )Nr   r1   )r    r   r   r2   r3   r4   r5   rs   s      r   test_print_emptyzTestPrint.test_print_emptyy   s    R		&!! 	: 	:EGGGSZ0022D999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   =A88A<?A<c                 "   t           } t          t          j        f          |          }t	                      5   |d           |                     t          j                                        d           d d d            d S # 1 swxY w Y   d S )Nr>   z1 hop! 3.5
)	r#   r   r   re   r   r2   r3   r4   r5   rs   s      r   test_print_stringszTestPrint.test_print_strings   s    #ej]##F++ 	D 	DE!HHHSZ0022NCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   >BBBc                    t           } t          d          |          }t                      5   |ddd           |                     t          j                                        d           d d d            n# 1 swxY w Y   t          } t          d          |          }t                      5   |ddd           |                     t          j                                        d           d d d            d S # 1 swxY w Y   d S )NTr+   r>   )rq   r^   )   y              @z1 (2, 3) 4 5j
z1 hop! (2, 3) 4 5j
)r%   r   r   r2   r3   r4   r5   r'   rs   s      r   test_print_varargzTestPrint.test_print_vararg   s    "T"""6** 	G 	GE!VW%%%SZ00224EFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G %"T"""6** 	L 	LE!VW%%%SZ00224JKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls%   A A;;A?A?4A DDDc                 `   t          d          d             t          d          fd            }t          j        d          }t                      5   ||           |                     t
          j                                        d           d d d            d S # 1 swxY w Y   d S )NTr+   c                 $    t          |            d S r   r   r   s    r   fooz*TestPrint.test_inner_fn_print.<locals>.foo   s    !HHHHHr   c                 4     |             d           d S )Nhellor   )r   r   s    r   barz*TestPrint.test_inner_fn_print.<locals>.bar   s!    CFFFCLLLLLr   r_   z[0 1 2 3 4]
hello
)r   rQ   rX   r   r2   r3   r4   r5   )r7   r   r   r   s      @r   test_inner_fn_printzTestPrint.test_inner_fn_print   s   	d				 	 
		 
d				 	 	 	 
		 IaLL 	L 	LCFFFSZ00224JKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   >B##B'*B'c                     t          d          d             }|                     t          j                  5 } |             d d d            n# 1 swxY w Y   d}|                     |j        j        |           d S )NTr+   c                  (    t          dd           d S )Nr   T)flushr   r   r   r   print_kwargz8TestPrint.test_print_w_kwarg_raises.<locals>.print_kwarg   s    #T""""""r   zKNumba's print() function implementation does not support keyword arguments.)r   assertRaisesr   UnsupportedErrorassertIn	exceptionmsg)r7   r   raisesexpecteds       r   test_print_w_kwarg_raisesz#TestPrint.test_print_w_kwarg_raises   s    	d				# 	# 
		# v677 	6KMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	)f&*H55555s   AAAc                 2   t          d          d             }t                      5   |             |                     t          j                                        d                    dgdz            dz              ddd           dS # 1 swxY w Y   dS )	z9 See: https://github.com/numba/numba/issues/3811
        Tr+   c                  R    t          d                    dgdz                       d S )N r   '  )r   joinr   r   r   r   z/TestPrint.test_print_no_truncation.<locals>.foo   s(    "''3%%-(()))))r   r   r   r   r1   N)r   r   r2   r3   r4   r5   r   )r7   r   s     r   test_print_no_truncationz"TestPrint.test_print_no_truncation   s     
d				* 	* 
		* 	S 	SCEEESZ0022BGGSEEM4J4JT4QRRR	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	Ss   ABBBN)__name__
__module____qualname__r<   r\   unittestskiprf   ro   rt   rw   ry   r{   r~   r   r   r   r   r   r   r/   r/   &   s        I I I8 8 8B X]ABB
P 
P CB
PQ Q Q? ? ?? ? ?: : :D D DL L LL L L"	6 	6 	6S S S S Sr   r/   __main__)r3   numpyrQ   r   numbar   r   
numba.corer   r   r   numba.tests.supportr   r	   r
   r   r   r   r    r#   r%   r'   r-   r/   r   mainr   r   r   <module>r      sS   



              + + + + + + + + + + P P P P P P P P P P              ! ! !TS TS TS TS TS#X TS TS TSl zHMOOOOO r   